blob: af21a0ef8d893c1e7611be733a67d181b15d0f52 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
gaurank kathpaliab654f702020-01-03 15:07:17 +05302 * Copyright (c) 2012-2020 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
Abhinav Kumar4d44f632019-08-02 13:55:54 +0530155#ifdef WLAN_FEATURE_SAE
156v_U8_t ccp_rsn_oui_80[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x08};
157v_U8_t ccp_rsn_oui_90[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x09};
158#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +0530159/* OWE https://tools.ietf.org/html/rfc8110 */
160uint8_t ccp_rsn_oui_18[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x12};
Abhinav Kumar4d44f632019-08-02 13:55:54 +0530161
Shailender Karmuchia734f332013-04-19 14:02:48 -0700162#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700163// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700164#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
165#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700166#endif
167
168#define BEACON_FRAME_IES_OFFSET 12
169
Abhishek Singh78c691f2017-11-30 13:48:44 +0530170/* The time after add bss, in which SAP should start ECSA to move to SCC */
171#define ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL 1500
Abhishek Singh10e17cf2018-03-12 14:34:22 +0530172/*
173 * Time in ms after disconnect, in which the SAP should move to non DFS channel.
174 * This will avoid multiple SAP channel switch if disconnet is followed by
175 * connect.
176 */
177#define ECSA_DFS_CHAN_CHANGE_DEFER_TIME 200
Abhishek Singh78c691f2017-11-30 13:48:44 +0530178
Chet Lanctot186b5732013-03-18 10:26:30 -0700179#ifdef WLAN_FEATURE_11W
180void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
181 tANI_U32 nFrameLength,
182 tANI_U8* pbFrames,
183 tANI_U8 frameType );
184#endif
185
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800186#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700187static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
188 tANI_U8 state,
189 tANI_U16 measInterval );
190static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800191static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
192static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700193
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800194#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700195
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530196static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
197 tCsrRoamInfo *pRoamInfo,
198 tANI_U32 roamId,
199 eRoamCmdStatus roamStatus,
200 eCsrRoamResult roamResult );
201
Abhinav Kumar118efd02019-08-07 16:41:07 +0530202#if defined(WLAN_FEATURE_SAE) && \
203 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
204/**
205 * wlan_hdd_sae_callback() - Sends SAE info to supplicant
206 * @adapter: pointer adapter context
207 * @roam_info: pointer to roam info
208 *
209 * This API is used to send required SAE info to trigger SAE in supplicant.
210 *
211 * Return: None
212 */
213static void wlan_hdd_sae_callback(hdd_adapter_t *adapter,
214 tCsrRoamInfo *roam_info)
215{
216 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
217 int flags;
218 struct sir_sae_info *sae_info = roam_info->sae_info;
219 struct cfg80211_external_auth_params params = {0};
220
221 if (wlan_hdd_validate_context(hdd_ctx))
222 return;
223 if (!sae_info) {
224 hddLog(LOGE, FL("SAE info in NULL"));
225 return;
226 }
227 flags = vos_get_gfp_flags();
228
229 params.key_mgmt_suite = 0x00;
230 params.key_mgmt_suite |= 0x0F << 8;
231 params.key_mgmt_suite |= 0xAC << 16;
232 params.key_mgmt_suite |= 0x8 << 24;
233
234 params.action = NL80211_EXTERNAL_AUTH_START;
235 vos_mem_copy(params.bssid, sae_info->peer_mac_addr.bytes,
236 VOS_MAC_ADDR_SIZE);
237 vos_mem_copy(params.ssid.ssid, sae_info->ssid.ssId, sae_info->ssid.length);
238 params.ssid.ssid_len = sae_info->ssid.length;
239
240 cfg80211_external_auth_request(adapter->dev, &params, flags);
241 hddLog(LOG1, FL("SAE: sent cmd"));
242}
243#else
244static void wlan_hdd_sae_callback(hdd_adapter_t *adapter,
245 tCsrRoamInfo *roam_info)
246{ }
247#endif
248
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530249v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
250 eConnectionState connState )
251{
252 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530253 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
254 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 pHddStaCtx->conn_info.connState = connState;
256}
257
258// returns FALSE if not connected.
259// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
260// returns the connection state. Can specify NULL if you dont' want to get the actual state.
261
Shailender Karmuchia734f332013-04-19 14:02:48 -0700262static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
263 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700264{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700265 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700266 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700267
Jeff Johnson295189b2012-06-20 16:38:30 -0700268 // get the connection state.
269 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700270 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700271 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700272 eConnectionState_IbssConnected == connState ||
273 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 {
275 fConnected = VOS_TRUE;
276 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 {
279 fConnected = VOS_FALSE;
280 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700281
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 if ( pConnState )
283 {
284 *pConnState = connState;
285 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700286
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 return( fConnected );
288}
289
290v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
291{
292 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700293}
Jeff Johnson295189b2012-06-20 16:38:30 -0700294
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530295eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
296{
297 v_U8_t staChannel = 0;
298
299 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
300 {
301 staChannel = pHddStaCtx->conn_info.operationChannel;
302 }
303
304 if ( staChannel > 0 && staChannel < 14 )
305 return eCSR_BAND_24;
306 else if (staChannel >= 36 && staChannel <= 165 )
307 return eCSR_BAND_5G;
308 else /* If station is not connected return as eCSR_BAND_ALL */
309 return eCSR_BAND_ALL;
310}
311
312
Jeff Johnson295189b2012-06-20 16:38:30 -0700313//TODO - Not used anyhwere. Can be removed.
314#if 0
315//
316v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
317{
318 v_BOOL_t fConnectedInfra = FALSE;
319 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700320
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700322 {
323 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 {
325 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700326 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700328
Jeff Johnson295189b2012-06-20 16:38:30 -0700329 return( fConnectedInfra );
330}
331#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
334{
335 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700338
339 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 {
341 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
342 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700343
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 return( fConnected );
345}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700346
Jeff Johnson295189b2012-06-20 16:38:30 -0700347inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
348{
349 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700350
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700352
353 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700354 {
355 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
356 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700357
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 return( fConnected );
359}
360
361static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
362{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700363 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 {
365 case eCSR_BSS_TYPE_INFRASTRUCTURE:
366 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
367 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700368
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 case eCSR_BSS_TYPE_IBSS:
370 case eCSR_BSS_TYPE_START_IBSS:
371 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
372 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700373
374 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700375 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700376 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 default:
378 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700379 break;
380 }
381
Jeff Johnson295189b2012-06-20 16:38:30 -0700382}
383
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530384/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530385 * hdd_copy_ht_caps()- Populate kernel HT caps structure object
386 * @hdd_ht_cap: HT capabilities of kernel type
387 * @roam_ht_cap: HT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530388 *
389 * Return: None
390 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530391void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
392 tDot11fIEHTCaps *roam_ht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530393{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530394 uint32_t i, temp_ht_cap;
395
396 vos_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
397
398 if (roam_ht_cap->advCodingCap)
399 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
400 if (roam_ht_cap->supportedChannelWidthSet)
401 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
402 temp_ht_cap = roam_ht_cap->mimoPowerSave &
403 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
404 if (temp_ht_cap)
405 hdd_ht_cap->cap_info |=
406 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
407 if (roam_ht_cap->greenField)
408 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
409 if (roam_ht_cap->shortGI20MHz)
410 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
411 if (roam_ht_cap->shortGI40MHz)
412 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
413 if (roam_ht_cap->txSTBC)
414 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
415 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
416 IEEE80211_HT_CAP_RX_STBC_SHIFT);
417 if (temp_ht_cap)
418 hdd_ht_cap->cap_info |=
419 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
420 if (roam_ht_cap->delayedBA)
421 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
422 if (roam_ht_cap->maximalAMSDUsize)
423 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
424 if (roam_ht_cap->dsssCckMode40MHz)
425 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
426 if (roam_ht_cap->psmp)
427 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
428 if (roam_ht_cap->stbcControlFrame)
429 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
430 if (roam_ht_cap->lsigTXOPProtection)
431 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
432
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530433 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
434 if (roam_ht_cap->maxRxAMPDUFactor)
435 hdd_ht_cap->ampdu_params_info |=
436 IEEE80211_HT_AMPDU_PARM_FACTOR;
437 temp_ht_cap = roam_ht_cap->mpduDensity &
438 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
439 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
440 if (temp_ht_cap)
441 hdd_ht_cap->ampdu_params_info |=
442 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
443
444 /* 802.11n HT extended capabilities masks */
445 if (roam_ht_cap->pco)
446 hdd_ht_cap->extended_ht_cap_info |=
447 IEEE80211_HT_EXT_CAP_PCO;
448 temp_ht_cap = roam_ht_cap->transitionTime &
449 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
450 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
451 if (temp_ht_cap)
452 hdd_ht_cap->extended_ht_cap_info |=
453 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
454 temp_ht_cap = roam_ht_cap->mcsFeedback &
455 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
456 if (temp_ht_cap)
457 hdd_ht_cap->extended_ht_cap_info |=
458 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
459
460 /* tx_bf_cap_info capabilities */
461 if (roam_ht_cap->txBF)
462 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
463 if (roam_ht_cap->rxStaggeredSounding)
464 hdd_ht_cap->tx_BF_cap_info |=
465 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
466 if (roam_ht_cap->txStaggeredSounding)
467 hdd_ht_cap->tx_BF_cap_info |=
468 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
469 if (roam_ht_cap->rxZLF)
470 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
471 if (roam_ht_cap->txZLF)
472 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
473 if (roam_ht_cap->implicitTxBF)
474 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
475 temp_ht_cap = roam_ht_cap->calibration &
476 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
477 if (temp_ht_cap)
478 hdd_ht_cap->tx_BF_cap_info |=
479 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
480 if (roam_ht_cap->explicitCSITxBF)
481 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
482 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
483 hdd_ht_cap->tx_BF_cap_info |=
484 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
485 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
486 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
487 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
488 if (temp_ht_cap)
489 hdd_ht_cap->tx_BF_cap_info |=
490 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
491 temp_ht_cap =
492 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
493 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
494 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
495 if (temp_ht_cap)
496 hdd_ht_cap->tx_BF_cap_info |=
497 temp_ht_cap <<
498 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
499 temp_ht_cap =
500 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
501 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
502 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
503 if (temp_ht_cap)
504 hdd_ht_cap->tx_BF_cap_info |=
505 temp_ht_cap <<
506 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
507 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
508 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
509 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
510 if (temp_ht_cap)
511 hdd_ht_cap->tx_BF_cap_info |=
512 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
513 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
514 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
515 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
516 if (temp_ht_cap)
517 hdd_ht_cap->tx_BF_cap_info |=
518 temp_ht_cap <<
519 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
520 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
521 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
522 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
523 if (temp_ht_cap)
524 hdd_ht_cap->tx_BF_cap_info |=
525 temp_ht_cap <<
526 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
527
528 /* antenna selection */
529 if (roam_ht_cap->antennaSelection)
530 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
531 if (roam_ht_cap->explicitCSIFeedbackTx)
532 hdd_ht_cap->antenna_selection_info |=
533 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
534 if (roam_ht_cap->antennaIndicesFeedbackTx)
535 hdd_ht_cap->antenna_selection_info |=
536 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
537 if (roam_ht_cap->explicitCSIFeedback)
538 hdd_ht_cap->antenna_selection_info |=
539 ANTENNA_SEL_INFO_EXP_CSI_FB;
540 if (roam_ht_cap->antennaIndicesFeedback)
541 hdd_ht_cap->antenna_selection_info |=
542 ANTENNA_SEL_INFO_ANT_ID_FB;
543 if (roam_ht_cap->rxAS)
544 hdd_ht_cap->antenna_selection_info |=
545 ANTENNA_SEL_INFO_RX_AS;
546 if (roam_ht_cap->txSoundingPPDUs)
547 hdd_ht_cap->antenna_selection_info |=
548 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
549
550 /* mcs data rate */
551 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
552 hdd_ht_cap->mcs.rx_mask[i] =
553 roam_ht_cap->supportedMCSSet[i];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530554
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530555 hdd_ht_cap->mcs.rx_highest =
556 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
557 ((short) (roam_ht_cap->supportedMCSSet[10]));
558 hdd_ht_cap->mcs.tx_params =
559 roam_ht_cap->supportedMCSSet[12];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530560
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530561}
562
563
564#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
565#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
566#define VHT_CAP_RXSTBC_MASK_SHIFT 8
567#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
568#define VHT_CAP_BEAMFORMEE_STS_MASK \
569 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
570#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
571#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
572 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
573#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
574#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
575 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
576#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
577
578/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530579 * hdd_copy_vht_caps()- Populate kernel VHT caps structure object
580 * @hdd_ht_cap: VHT capabilities of kernel type
581 * @roam_ht_cap: VHT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530582 *
583 * Return: None
584 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530585void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
586 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530587{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530588 uint32_t temp_vht_cap;
589
590 vos_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
591
592 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
593 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
594 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
595 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
596 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
597 if (temp_vht_cap)
598 if (roam_vht_cap->supportedChannelWidthSet &
599 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
600 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
601 hdd_vht_cap->vht_cap_info |=
602 temp_vht_cap <<
603 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
604 if (roam_vht_cap->supportedChannelWidthSet &
605 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
606 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
607 hdd_vht_cap->vht_cap_info |=
608 temp_vht_cap <<
609 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
610 if (roam_vht_cap->ldpcCodingCap)
611 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
612 if (roam_vht_cap->shortGI80MHz)
613 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
614 if (roam_vht_cap->shortGI160and80plus80MHz)
615 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
616 if (roam_vht_cap->txSTBC)
617 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
618 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
619 VHT_CAP_RXSTBC_MASK_SHIFT);
620 if (temp_vht_cap)
621 hdd_vht_cap->vht_cap_info |=
622 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
623 if (roam_vht_cap->suBeamFormerCap)
624 hdd_vht_cap->vht_cap_info |=
625 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
626 if (roam_vht_cap->suBeamformeeCap)
627 hdd_vht_cap->vht_cap_info |=
628 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
629 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
630 (VHT_CAP_BEAMFORMEE_STS_MASK);
631 if (temp_vht_cap)
632 hdd_vht_cap->vht_cap_info |=
633 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
634 temp_vht_cap = roam_vht_cap->numSoundingDim &
635 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
636 if (temp_vht_cap)
637 hdd_vht_cap->vht_cap_info |=
638 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
639 if (roam_vht_cap->muBeamformerCap)
640 hdd_vht_cap->vht_cap_info |=
641 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
642 if (roam_vht_cap->muBeamformeeCap)
643 hdd_vht_cap->vht_cap_info |=
644 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
645 if (roam_vht_cap->vhtTXOPPS)
646 hdd_vht_cap->vht_cap_info |=
647 IEEE80211_VHT_CAP_VHT_TXOP_PS;
648 if (roam_vht_cap->htcVHTCap)
649 hdd_vht_cap->vht_cap_info |=
650 IEEE80211_VHT_CAP_HTC_VHT;
651 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
652 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
653 if (temp_vht_cap)
654 hdd_vht_cap->vht_cap_info |=
655 temp_vht_cap <<
656 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
657 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
658 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
659 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
660 if (temp_vht_cap)
661 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
662 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
663 if (roam_vht_cap->rxAntPattern)
664 hdd_vht_cap->vht_cap_info |=
665 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
666 if (roam_vht_cap->txAntPattern)
667 hdd_vht_cap->vht_cap_info |=
668 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
669 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
670 hdd_vht_cap->supp_mcs.rx_highest =
671 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
672 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
673 hdd_vht_cap->supp_mcs.tx_highest =
674 ((uint16_t)roam_vht_cap->txSupDataRate);
675}
676
677/* ht param */
678#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
679#define HT_PARAM_SERVICE_INT_GRAN 0xe0
680#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
681
682/* operatinon mode */
683#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
684
685/* stbc_param */
686#define HT_STBC_PARAM_MCS 0x007f
687
688/**
689 * hdd_copy_ht_operation()- copy HT operation element from roam info to
690 * hdd station context.
691 * @hdd_sta_ctx: pointer to hdd station context
692 * @roam_info: pointer to roam info
693 *
694 * Return: None
695 */
696static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
697 tCsrRoamInfo *roam_info)
698{
699 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
700 struct ieee80211_ht_operation *hdd_ht_ops =
701 &hdd_sta_ctx->conn_info.ht_operation;
702 uint32_t i, temp_ht_ops;
703
704 vos_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
705
706 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
707
708 /* HT_PARAMS */
709 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
710 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
711 if (temp_ht_ops)
712 hdd_ht_ops->ht_param |= temp_ht_ops;
713 else
714 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
715 if (roam_ht_ops->recommendedTxWidthSet)
716 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
717 if (roam_ht_ops->rifsMode)
718 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
719 if (roam_ht_ops->controlledAccessOnly)
720 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
721 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
722 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
723 if (temp_ht_ops)
724 hdd_ht_ops->ht_param |= temp_ht_ops <<
725 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
726
727 /* operation mode */
728 temp_ht_ops = roam_ht_ops->opMode &
729 IEEE80211_HT_OP_MODE_PROTECTION;
730 switch (temp_ht_ops) {
731 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
732 hdd_ht_ops->operation_mode |=
733 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
734 break;
735 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
736 hdd_ht_ops->operation_mode |=
737 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
738 break;
739 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
740 hdd_ht_ops->operation_mode |=
741 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
742 break;
743 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
744 default:
745 hdd_ht_ops->operation_mode |=
746 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
747 }
748 if (roam_ht_ops->nonGFDevicesPresent)
749 hdd_ht_ops->operation_mode |=
750 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
751 if (roam_ht_ops->transmitBurstLimit)
752 hdd_ht_ops->operation_mode |=
753 HT_OP_MODE_TX_BURST_LIMIT;
754 if (roam_ht_ops->obssNonHTStaPresent)
755 hdd_ht_ops->operation_mode |=
756 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
757
758 /* stbc_param */
759 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
760 HT_STBC_PARAM_MCS;
761 if (temp_ht_ops)
762 hdd_ht_ops->stbc_param |= temp_ht_ops;
763 if (roam_ht_ops->dualCTSProtection)
764 hdd_ht_ops->stbc_param |=
765 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
766 if (roam_ht_ops->secondaryBeacon)
767 hdd_ht_ops->stbc_param |=
768 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
769 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
770 hdd_ht_ops->stbc_param |=
771 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
772 if (roam_ht_ops->pcoActive)
773 hdd_ht_ops->stbc_param |=
774 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
775 if (roam_ht_ops->pcoPhase)
776 hdd_ht_ops->stbc_param |=
777 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
778
779 /* basic MCs set */
780 for (i = 0; i < 16; ++i)
781 hdd_ht_ops->basic_set[i] =
782 roam_ht_ops->basicMCSSet[i];
783}
784
785/**
786 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
787 * hdd station context.
788 * @hdd_sta_ctx: pointer to hdd station context
789 * @roam_info: pointer to roam info
790 *
791 * Return: None
792 */
793static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
794 tCsrRoamInfo *roam_info)
795{
796 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
797 struct ieee80211_vht_operation *hdd_vht_ops =
798 &hdd_sta_ctx->conn_info.vht_operation;
799
800 vos_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
801
802 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
803 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
804 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
805 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
806}
807
808
809/**
810 * hdd_save_bss_info() - save connection info in hdd sta ctx
811 * @adapter: Pointer to adapter
812 * @roam_info: pointer to roam info
813 *
814 * Return: None
815 */
816static void hdd_save_bss_info(hdd_adapter_t *adapter,
817 tCsrRoamInfo *roam_info)
818{
819 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
820
821 hdd_sta_ctx->conn_info.freq = vos_chan_to_freq(
822 hdd_sta_ctx->conn_info.operationChannel);
823 if (roam_info->vht_caps.present) {
824 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530825 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
826 &roam_info->vht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530827 } else {
828 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
829 }
830 if (roam_info->ht_caps.present) {
831 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530832 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps, &roam_info->ht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530833 } else {
834 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
835 }
836 if (roam_info->reassoc)
837 hdd_sta_ctx->conn_info.roam_count++;
838 if (roam_info->hs20vendor_ie.present) {
839 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
840 vos_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
841 &roam_info->hs20vendor_ie,
842 sizeof(roam_info->hs20vendor_ie));
843 } else {
844 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
845 }
846 if (roam_info->ht_operation.present) {
847 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
848 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
849 } else {
850 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
851 }
852 if (roam_info->vht_operation.present) {
853 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
854 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
855 } else {
856 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
857 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +0530858 /* Cache last connection info */
859 vos_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
860 sizeof(connection_info_t));
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530861}
862
Jeff Johnson295189b2012-06-20 16:38:30 -0700863void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
864{
865 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
866 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700867
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700869
870 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700872 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
874 {
875 VOS_ASSERT( pRoamInfo->pBssDesc );
876 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
877
878 // Save the Station ID for this station from the 'Roam Info'.
879 //For IBSS mode, staId is assigned in NEW_PEER_IND
880 //For reassoc, the staID doesn't change and it may be invalid in this structure
881 //so no change here.
882 if( !pRoamInfo->fReassocReq )
883 {
884 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
885 }
886 }
887 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700888 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700890 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 else
892 {
893 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
894 // or we can't function.
895 VOS_ASSERT( 0 );
896 }
897
898 // notify WMM
899 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
900
901 if( !pRoamInfo->u.pConnectedProfile )
902 {
903 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
904 }
905 else
906 {
907 // Get Multicast Encryption Type
908 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
909 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
910 // Get Unicast Encrytion Type
911 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
912 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
913
914 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
915
916 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
917
918 // Save the ssid for the connection
919 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530920
921 // Save dot11mode in which STA associated to AP
922 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530923
924 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 }
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530926 hdd_save_bss_info(pAdapter, pRoamInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700927 }
928
Jeff Johnson295189b2012-06-20 16:38:30 -0700929 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700930 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932}
933
934#if defined(WLAN_FEATURE_VOWIFI_11R)
935/*
936 * Send the 11R key information to the supplicant.
937 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800938 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700939 * for the same purpose.)
940 *
941 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
942 * this contains the R1KHID, R0KHID and the MDID.
943 * For FT, this consists of the Reassoc Rsp FTIEs.
944 * This is the Assoc Response.
945 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700946static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 tCsrRoamInfo *pCsrRoamInfo)
948{
949 union iwreq_data wrqu;
950 char *buff;
951 unsigned int len = 0;
952 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700953
954 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700955 {
956 hddLog(LOGE,
957 "%s: pCsrRoamInfo->nAssocRspLength=%d",
958 __func__, (int)pCsrRoamInfo->nAssocRspLength);
959 return;
960 }
961
Shailender Karmuchia734f332013-04-19 14:02:48 -0700962 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700964 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700966 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 return;
968 }
969
970 // pFTAssocRsp needs to point to the IEs
971 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
972 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
973 (unsigned int)pFTAssocRsp[0],
974 (unsigned int)pFTAssocRsp[1]);
975
976 // We need to send the IEs to the supplicant.
977 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700978 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700979 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700980 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 return;
982 }
983
984 // Send the Assoc Resp, the supplicant needs this for initial Auth.
985 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700986 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700988 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
990
991 kfree(buff);
992}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700993#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700994
995#ifdef WLAN_FEATURE_VOWIFI_11R
996
997/*---------------------------------------------------
998 *
999 * Send the FTIEs, RIC IEs during FT. This is eventually
1000 * used to send the FT events to the supplicant
1001 *
1002 * At the reception of Auth2 we send the RIC followed
1003 * by the auth response IEs to the supplicant.
1004 * Once both are received in the supplicant, an FT
1005 * event is generated to the supplicant.
1006 *
1007 *---------------------------------------------------
1008 */
1009void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
1010{
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 tANI_U16 auth_resp_len = 0;
1012 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1014
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05301015#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001016 struct cfg80211_ft_event_params ftEvent;
1017 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1018 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
1019 struct net_device *dev = pAdapter->dev;
1020#else
1021 char *buff;
1022 union iwreq_data wrqu;
1023 tANI_U16 str_len;
1024#endif
1025
Gopichand Nakkala66923aa2013-03-06 23:17:24 +05301026#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301027 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1028 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001029
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +05301030 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
1031 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301032 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001033 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301034 hddLog(LOGW,
1035 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1036 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001037 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001038
1039 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301040 ftEvent.ric_ies_len = ric_ies_length;
1041 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001042
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301043 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001044 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001045
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301046 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001047 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301048 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001049 return;
1050 }
1051
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301052 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301053
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301054 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001055
1056 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
1057 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
1058
Jeff Johnson59a121e2013-11-30 09:46:08 -08001059 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
1060 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
1061 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301062 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001063 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
1064 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1065 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001066
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301067 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001068
1069#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301070 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001071 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301072 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301074 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 return;
1076 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301077 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001078
Shailender Karmuchia734f332013-04-19 14:02:48 -07001079 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301081 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001082 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301083 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301085 hddLog(LOGW,
1086 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1087 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 }
1089 else
1090 {
1091 wrqu.data.length = str_len + ric_ies_length;
1092 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1093 }
1094
1095 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301096 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301098 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
1099 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001100
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301101 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301103 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +05301104 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 return;
1106 }
1107
1108 wrqu.data.length = str_len + auth_resp_len;
1109 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1110
1111 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001112#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001113}
1114
1115#endif /* WLAN_FEATURE_VOWIFI_11R */
1116
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001117#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001118
1119/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001120 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 * (This keeps the supplicant "up to date" on the current channel.)
1122 *
1123 * The current (new AP) channel information is passed in.
1124 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001125static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 tCsrRoamInfo *pCsrRoamInfo)
1127{
1128 union iwreq_data wrqu;
1129 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001130
Shailender Karmuchia734f332013-04-19 14:02:48 -07001131
1132 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 {
1134 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001135 "%s: pCsrRoamInfo->pBssDesc=%pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 __func__, descriptor);
1137 return;
1138 }
1139
1140 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -08001141 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 memset(&wrqu, '\0', sizeof(wrqu));
1143 wrqu.freq.m = descriptor->channelId;
1144 wrqu.freq.e = 0;
1145 wrqu.freq.i = 0;
1146 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1147}
1148
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001149#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001150
1151void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
1152{
1153 union iwreq_data wrqu;
1154 u8 *pBeaconIes;
1155 u8 currentLen = 0;
1156 char *buff;
1157 int totalIeLen = 0, currentOffset = 0, strLen;
1158
1159 memset(&wrqu, '\0', sizeof(wrqu));
1160
1161 if (0 == pCsrRoamInfo->nBeaconLength)
1162 {
1163 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
1164 return;
1165 }
1166 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001167 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001168 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001169 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001170 return;
1171 }
1172
1173 // pBeaconIes needs to point to the IEs
1174 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
1175 (unsigned int)pBeaconIes[0],
1176 (unsigned int)pBeaconIes[1]);
1177 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001178
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 // We need to send the IEs to the supplicant.
1180 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001181 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001182 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001183 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001184 return;
1185 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001186 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001187
1188 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
1189 currentLen = strLen + 1;
1190
1191 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1192 do
1193 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001194 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 * max size and send it to supplicant. Changes are done in supplicant to handle this */
1196 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
1197 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
1198 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
1199 currentOffset += currentLen;
1200 totalIeLen -= currentLen;
1201 wrqu.data.length = strLen + 1 + currentLen;
1202 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -07001203 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 else
1205 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
1206
1207 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
1208 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1209 } while (totalIeLen > 0);
1210
1211 kfree(buff);
1212}
1213
1214static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
1215{
1216 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1217 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1218 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1219 union iwreq_data wrqu;
1220 int we_event;
1221 char *msg;
1222 int type = -1;
1223
Shailender Karmuchia734f332013-04-19 14:02:48 -07001224#if defined (WLAN_FEATURE_VOWIFI_11R)
1225 // Added to find the auth type on the fly at run time
1226 // rather than with cfg to see if FT is enabled
1227 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
1229#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001230
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001232 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001234
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
1236 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301237 /* In case of roaming ; We are not doing disconnect.
1238 * If disconnect is not being done for roam; We will not
1239 * decrease count for Active sessions. We should not increase active
1240 * active session in case of roaming.
1241 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +05301242 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +05301243 {
1244 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
1245 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
1247 type = WLAN_STA_ASSOC_DONE_IND;
1248
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001249#ifdef WLAN_FEATURE_P2P_DEBUG
1250 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1251 {
1252 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
1253 {
1254 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
1255 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1256 "Connecting state to Connected State for 8-way "
1257 "Handshake");
1258 }
1259 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
1260 {
1261 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
1262 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1263 "Connecting state to P2P Client Connection Completed");
1264 }
1265 }
1266#endif
Yeshwanth Sriram Guntuka0004c0b2017-12-06 14:43:49 +05301267 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
1268 MAC_ADDRESS_STR,
1269 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1270 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001271 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
1272
Bhargav Shahd0715912015-10-01 18:17:37 +05301273 hdd_manage_delack_timer(pHddCtx);
1274
Jeff Johnson295189b2012-06-20 16:38:30 -07001275 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
1276 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
1277 * and fFTEnable is TRUE */
1278#ifdef WLAN_FEATURE_VOWIFI_11R
1279 // Send FT Keys to the supplicant when FT is enabled
1280 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -07001281 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001282#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001283 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1284 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
1285#endif
1286 )
1287 {
1288 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
1289 }
1290#endif
1291 }
1292 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
1293 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301294 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -07001295 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301297
1298 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1299 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
1300 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 }
1302 else /* Not Associated */
1303 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301304 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1305 "wlan: disconnected");
gaurank kathpalia51801582019-04-05 13:56:55 +05301306 if (pHddCtx->btCoexModeSet) {
1307 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1308 FL("Wlan disconnected, sending DHCP stop indication"));
1309 pHddCtx->btCoexModeSet = FALSE;
1310 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
1311 pAdapter->sessionId);
1312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 type = WLAN_STA_DISASSOC_DONE_IND;
1314 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +05301315
1316 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001318 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001319
1320 msg = NULL;
1321 /*During the WLAN uninitialization,supplicant is stopped before the
1322 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301323 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 {
1325 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001326#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001328 {
1329 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1330 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
1332 }
1333#endif
1334 }
1335 send_btc_nlink_msg(type, 0);
1336}
1337
1338void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
1339{
1340 // Remove staId, bssId and peerMacAddress
1341 pHddStaCtx->conn_info.staId [ 0 ] = 0;
1342 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
1343 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
1344
1345 // Clear all security settings
1346 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1347 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1348 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1349
1350 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001351 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001352
1353 // Set not-connected state
1354 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -07001355
1356 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
1357}
Katya Nigam47528772015-02-11 12:24:49 +05301358
1359VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
1360{
Katya Nigam1fd24402015-02-16 14:52:19 +05301361 v_U8_t ac;
1362 /**Track whether OS TX queue has been disabled.*/
1363 v_BOOL_t txSuspended[NUM_TX_QUEUES];
1364 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +05301365 v_U8_t i;
1366 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1367 hdd_ibss_peer_info_t *pPeerInfo;
1368
1369 if( NULL == pHddStaCtx )
1370 {
1371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1372 "%s: HDD station context NULL ",__func__);
1373 return VOS_STATUS_E_FAILURE;
1374 }
Katya Nigam1fd24402015-02-16 14:52:19 +05301375
Katya Nigam47528772015-02-11 12:24:49 +05301376 pPeerInfo = &pHddStaCtx->ibss_peer_info;
1377 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
1378 {
1379 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1380 "%s: Deinit station not inited %d", __func__, STAId );
1381 return VOS_STATUS_E_FAILURE;
1382 }
1383
1384 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +05301385
1386 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1387 {
1388 tlAC = hdd_QdiscAcToTlAC[ac];
1389 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
1390 }
1391
Katya Nigam47528772015-02-11 12:24:49 +05301392 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1393
Katya Nigam1fd24402015-02-16 14:52:19 +05301394 /* re-init hdd list, since netdev can still open adapter until
1395 * driver gets unloaded
1396 */
1397 for (i = 0; i < NUM_TX_QUEUES; i ++)
1398 {
1399 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
1400 HDD_TX_QUEUE_MAX_LEN);
1401 }
1402
1403 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1404 {
1405 if (txSuspended[ac])
1406 {
1407 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1408 "%s: TX queue re-enabled", __func__);
1409 netif_wake_subqueue(pAdapter->dev, ac);
1410 }
1411 }
Katya Nigam47528772015-02-11 12:24:49 +05301412 return VOS_STATUS_SUCCESS;
1413}
1414
1415static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1416{
1417 VOS_STATUS vosStatus;
1418
1419 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1420 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1421 {
1422 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1423 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1424 "Status= %d [0x%08X]",
1425 __func__, staId, vosStatus, vosStatus );
1426 }
1427
1428 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
1429 if( VOS_STATUS_E_FAILURE == vosStatus )
1430 {
1431 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1432 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
1433 "Status = %d [0x%08X]",
1434 staId, vosStatus, vosStatus );
1435 }
1436
1437 return( vosStatus );
1438}
1439
1440VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
1441{
1442 v_U8_t i = 0;
1443 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1444 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1445
1446 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
1447 {
1448 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1449 "%s: Reinit station %d", __func__, STAId );
1450 return VOS_STATUS_E_FAILURE;
1451 }
1452
1453 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1454 for (i = 0; i < NUM_TX_QUEUES; i ++)
1455 {
1456 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
1457 }
1458
1459 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
1460 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
1461 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
1462
1463 return VOS_STATUS_SUCCESS;
1464}
1465
1466static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
1467 tCsrRoamInfo *pRoamInfo,
1468 v_U8_t staId,
1469 v_MACADDR_t *pPeerMacAddress,
1470 tSirBssDescription *pBssDesc )
1471{
1472 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1473 WLAN_STADescType staDesc = {0};
1474 eCsrEncryptionType connectedCipherAlgo;
1475 v_BOOL_t fConnected;
1476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1477 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1478 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1479
1480 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
1481 {
1482 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1483 "clean up old entry for STA %d", staId);
1484 hdd_ibss_DeregisterSTA( pAdapter, staId );
1485 }
1486
1487 staDesc.ucSTAId = staId;
1488 staDesc.wSTAType = WLAN_STA_IBSS;
1489
1490 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1491 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1492 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1493 // pass when making an Infrastructure connection.
1494 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
1495 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
1496 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1497
1498 if (hdd_wmm_is_active(pAdapter))
1499 {
1500 staDesc.ucQosEnabled = 1;
1501 }
1502 else
1503 {
1504 staDesc.ucQosEnabled = 0;
1505 }
1506 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1507 "HDD SOFTAP register TL QoS_enabled=%d",
1508 staDesc.ucQosEnabled );
1509
1510 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1511 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1512 {
1513 staDesc.ucProtectedFrame = 1;
1514 }
1515 else
1516 {
1517 staDesc.ucProtectedFrame = 0;
1518
1519 }
1520
1521 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
1522
1523 // UMA is Not ready yet, Xlation will be done by TL
1524 staDesc.ucSwFrameTXXlation = 1;
1525 staDesc.ucSwFrameRXXlation = 1;
1526 staDesc.ucAddRmvLLC = 1;
1527 // Initialize signatures and state
1528 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1529 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1530 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
1531
1532 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1533
1534 // Register the Station with TL.
1535 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1536 hdd_rx_packet_cbk,
1537 hdd_tx_complete_cbk,
1538 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
1539 pBssDesc->rssi );
1540 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1541 {
1542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1543 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
1544 vosStatus, vosStatus );
1545 return vosStatus;
1546 }
1547
1548 //Timer value should be in milliseconds
1549 if ( pHddCtx->cfg_ini->dynSplitscan &&
1550 ( VOS_TIMER_STATE_RUNNING !=
1551 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1552 {
1553 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1554 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
1555 }
1556
1557 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
1558 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
1559
1560 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
1561 WLANTL_STA_AUTHENTICATED );
1562
1563 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
1564 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1565
1566 return( vosStatus );
1567}
1568
Jeff Johnson295189b2012-06-20 16:38:30 -07001569/* TODO Revist this function. and data path */
1570static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1571{
1572 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -07001573
Katya Nigam47528772015-02-11 12:24:49 +05301574 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -07001575
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1577 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1578 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05301579 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001581 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001582 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 }
1584 return( vosStatus );
1585}
1586
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301587/**
1588 * hdd_print_bss_info() - print bss info
1589 * @hdd_sta_ctx: pointer to hdd station context
1590 *
1591 * Return: None
1592 */
1593void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
1594{
1595 uint32_t *cap_info;
1596
1597 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"WIFI DATA LOGGER");
1598 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"channel: %d",
1599 hdd_sta_ctx->conn_info.freq);
1600 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"dot11mode: %d",
1601 hdd_sta_ctx->conn_info.dot11Mode);
1602 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"AKM: %d",
1603 hdd_sta_ctx->conn_info.authType);
1604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ssid: %.*s",
1605 hdd_sta_ctx->conn_info.SSID.SSID.length,
1606 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1607 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"roam count: %d",
1608 hdd_sta_ctx->conn_info.roam_count);
1609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ant_info: %d",
1610 hdd_sta_ctx->conn_info.txrate.nss);
1611 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate legacy %d",
1612 hdd_sta_ctx->conn_info.txrate.legacy);
1613 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate mcs: %d",
1614 hdd_sta_ctx->conn_info.txrate.mcs);
1615 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1616 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1617 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ht caps: %x",
1618 *cap_info);
1619 }
1620 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1621 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1622 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"vht caps: %x",
1623 *cap_info);
1624 }
1625 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1626 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"hs20 info: %x",
1627 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1628 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"signal: %d",
1629 hdd_sta_ctx->conn_info.signal);
1630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"noise: %d",
1631 hdd_sta_ctx->conn_info.noise);
1632}
1633
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301634/**
1635 * hdd_check_and_move_if_sap_is_on_dfs_chan() - move the sap to non dfs channel
1636 * @hdd_ctx: pointer to hdd context
1637 * @sta_adapter: pointer to sta adapater
1638 *
1639 * This function is used to check if SAP is operating on DFS channel in stand
1640 * alone mode and move it to non dfs channel
1641 *
1642 * Return: void.
1643 */
1644static void hdd_check_and_move_if_sap_is_on_dfs_chan(hdd_context_t *hdd_ctx,
1645 hdd_adapter_t *sta_adapter)
1646{
1647 hdd_adapter_t *sap_adapter;
1648 ptSapContext sap_ctx;
1649 v_CONTEXT_t vos_ctx;
1650 eNVChannelEnabledType chan_state;
1651
1652 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx)) {
1653 sap_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_SOFTAP);
1654
1655 if (!sap_adapter) {
1656 hddLog(LOG1, FL("SAP not exists, nothing to do"));
1657 return;
1658 }
1659
1660 vos_ctx = hdd_ctx->pvosContext;
1661 if (!vos_ctx) {
1662 hddLog(LOGE, FL("vos_ctx is NULL"));
1663 return;
1664 }
1665 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1666 if (!sap_ctx) {
1667 hddLog(LOG1, FL("sap_ctx not exists"));
1668 return;
1669 }
1670
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301671 if (sap_ctx->sapsMachine != eSAP_STARTED) {
1672 hddLog(LOG1, FL("SAP is not in eSAP_STARTED state"));
1673 return;
1674 }
1675
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301676 chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel);
1677
1678 hddLog(LOG1, "SAP is operating on channel (%hu), chan_state %d",
1679 sap_ctx->channel, chan_state);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301680 if (vos_nv_getChannelEnabledState(sap_ctx->channel) !=
1681 NV_CHANNEL_DFS) {
1682 hddLog(LOG1, "SAP is on non DFS channel. nothing to do");
1683 return;
1684 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301685
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301686 hddLog(LOG1, "Schedule workqueue to move the SAP to non DFS channel");
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301687 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
1688 msecs_to_jiffies(ECSA_DFS_CHAN_CHANGE_DEFER_TIME));
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301689 }
1690}
Jeff Johnson295189b2012-06-20 16:38:30 -07001691
1692static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1693 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1694 eCsrRoamResult roamResult )
1695{
1696 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07001697 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 struct net_device *dev = pAdapter->dev;
1699 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1700 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -07001701 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301702 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001703
1704 // Sanity check
1705 if(dev == NULL)
1706 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301707 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001708 "%s: net_dev is released return", __func__);
1709 return eHAL_STATUS_FAILURE;
1710 }
1711
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301713 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 netif_tx_disable(dev);
1715 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301716 //TxTimeoutCount need to reset in case of disconnect handler
1717 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001718
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301719 wlan_hdd_check_and_stop_mon(pAdapter, false);
1720
Jeff Johnsone7245742012-09-05 17:12:55 -07001721 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301722 /* If only STA mode is on */
1723 if((pHddCtx->concurrency_mode <= 1) &&
1724 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1725 {
1726 pHddCtx->isAmpAllowed = VOS_TRUE;
1727 }
1728
Agarwal Ashish47d18112014-08-04 19:55:07 +05301729 /* Need to apply spin lock before decreasing active sessions
1730 * as there can be chance for double decrement if context switch
1731 * Calls wlan_hdd_disconnect.
1732 */
1733
1734 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301735
1736 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301737 * to kernel. Sending disconnected event to kernel for userspace
1738 * initiated disconnect will be handled by diconnect handler call
1739 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301740 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301741 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301742 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) ||
1743 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301744 {
1745 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1746 FL(" HDD has initiated a disconnect, no need to send"
1747 " disconnect indication to kernel"));
1748 sendDisconInd = FALSE;
1749 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301750 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301752 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301753 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301754 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301755 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1756 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301758 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh78c691f2017-11-30 13:48:44 +05301759 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001761
1762 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001763
1764 // indicate 'disconnect' status to wpa_supplicant...
1765 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 /* indicate disconnected event to nl80211 */
1767 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1768 {
1769 /*During the WLAN uninitialization,supplicant is stopped before the
1770 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301771 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301773 if (sendDisconInd)
1774 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1775 "%s: sent disconnected event to nl80211",
1776 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001777#ifdef WLAN_FEATURE_P2P_DEBUG
1778 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1779 {
1780 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1781 {
1782 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1783 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1784 "and moved to disconnected state");
1785 }
1786 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1787 {
1788 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1789 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1790 "and moved to inactive state");
1791 }
1792 }
1793#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301794 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1795 !pRoamInfo->reasonCode)
1796 wlan_hdd_get_frame_logs(pAdapter,
1797 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301798 /*Only send indication to kernel if not initiated by kernel*/
1799 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301801 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1802 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1803 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301804 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1805 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301806 }
1807 else
1808 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301809 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301810 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301813
1814 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1815 {
1816 hddLog(LOG1,
1817 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1818 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301819 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301820
Jeff Johnson295189b2012-06-20 16:38:30 -07001821 //If the Device Mode is Station
1822 // and the P2P Client is Connected
1823 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001824
1825 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001826 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001827 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 {
1829 //Enable BMPS only of other Session is P2P Client
1830 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001831 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001832
1833 if (NULL != pVosContext)
1834 {
1835 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1836
1837 if(NULL != pHddCtx)
1838 {
1839 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301840 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1841 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301843 if (pHddCtx->hdd_wlan_suspended)
1844 {
1845 hdd_set_pwrparams(pHddCtx);
1846 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301848 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 }
1850 }
1851 }
1852 }
1853 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001854
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301855 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301856 /* Clear PER based roam stats */
1857#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1858 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1859 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1860 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1861 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1862 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1863#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301864#if defined(WLAN_FEATURE_VOWIFI_11R)
1865 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1866#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301867
1868 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1869 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301870 v_U8_t i;
1871
Katya Nigam63ce1772014-09-26 15:53:49 +05301872 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301873 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301874 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1875 {
1876 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301877 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1878 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301879 sta_id, status, status );
1880
1881 status = eHAL_STATUS_FAILURE;
1882 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301883 pHddCtx->sta_to_adapter[sta_id] = NULL;
1884
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301885 /*Clear all the peer sta register with TL.*/
1886 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1887 {
1888 if (0 != pHddStaCtx->conn_info.staId[i])
1889 {
1890 sta_id = pHddStaCtx->conn_info.staId[i];
1891
1892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1893 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301894 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301895 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1896 {
1897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1898 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1899 "Status= %d [0x%x]"),
1900 sta_id, status, status );
1901 status = eHAL_STATUS_FAILURE;
1902 }
1903
Nirav Shah7e3c8132015-06-22 23:51:42 +05301904 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1905 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1906 if (vstatus != VOS_STATUS_SUCCESS) {
1907 hddLog(VOS_TRACE_LEVEL_ERROR,
1908 FL("Not able to remove staid hash %d"),
1909 sta_id);
1910 status = eHAL_STATUS_FAILURE;
1911 } else {
1912 hddLog(VOS_TRACE_LEVEL_INFO,
1913 FL("ibss station removed sta_id %d mac:"
1914 MAC_ADDRESS_STR), sta_id,
1915 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1916 }
1917
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301918 /*set the staid and peer mac as 0, all other reset are
1919 * done in hdd_connRemoveConnectInfo.
1920 */
1921 pHddStaCtx->conn_info.staId[i]= 0;
1922 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1923
1924 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1925 pHddCtx->sta_to_adapter[sta_id] = NULL;
1926 }
1927 }
1928
Katya Nigam63ce1772014-09-26 15:53:49 +05301929 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301930 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301932 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301933 /* clear scan cache for Link Lost */
1934 if (pRoamInfo && !pRoamInfo->reasonCode &&
1935 (eCSR_ROAM_LOSTLINK == roamStatus)) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05301936 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301937 pHddStaCtx->conn_info.bssId);
1938 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1939 pHddStaCtx->conn_info.bssId);
1940 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301941
1942 //We should clear all sta register with TL, for now, only one.
1943 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1944 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1945 {
1946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1947 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1948 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001949 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001950
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301951 status = eHAL_STATUS_FAILURE;
1952 }
1953
1954 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301956
1957#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1958 if (VOS_STATUS_SUCCESS !=
1959 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1960 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1961 {
1962 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1963 "WLANTL_ClearInterfaceStats Failed", __func__);
1964 }
1965 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1966 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1967 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1968 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1969#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Sravan Kumar Kairamf9f95122017-01-18 20:54:05 +05301970 pAdapter->dad = false;
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301971
Jeff Johnson295189b2012-06-20 16:38:30 -07001972 // Clear saved connection information in HDD
1973 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301974
1975 /*
1976 * eConnectionState_Connecting state mean that connection is in progress so
1977 * no need to set state to eConnectionState_NotConnected
1978 */
1979 if ((eConnectionState_Connecting != pHddStaCtx->conn_info.connState)) {
1980 hddLog(LOG1, FL("Set HDD connState to eConnectionState_NotConnected"));
1981 hdd_connSetConnectionState(pHddStaCtx, eConnectionState_NotConnected);
1982 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301983#ifdef WLAN_FEATURE_GTK_OFFLOAD
1984 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1985 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1986 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301987 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1988 sizeof (tSirGtkOffloadParams));
1989 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301990 }
1991#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001992
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001993#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001994 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1995 {
1996 wlan_hdd_tdls_disconnection_callback(pAdapter);
1997 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001998#endif
1999
Jeff Johnson295189b2012-06-20 16:38:30 -07002000 //Unblock anyone waiting for disconnect to complete
2001 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302002 hdd_print_bss_info(pHddStaCtx);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302003
2004 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 return( status );
2006}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302007
2008static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
2009 v_U8_t staId)
2010{
2011 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2012 v_SINT_t i;
2013 v_SIZE_t size;
2014 VOS_STATUS status;
2015 v_BOOL_t granted = VOS_FALSE;
2016
2017 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2018 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
2019 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
2020 {
2021 //Indicate to TL that there is pending data if a queue is non empty
2022 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
2023 {
2024 size = 0;
2025 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
2026 if (size > 0)
2027 {
2028 if (i != WLANTL_AC_HIGH_PRIO)
2029 {
2030 if (VOS_FALSE ==
2031 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
2032 {
2033 hdd_wmm_acquire_access(pAdapter,
2034 (WLANTL_ACEnumType)i, &granted);
2035 pAdapter->psbChanged |= (1 << i);
2036 }
2037 else
2038 granted = VOS_TRUE;
2039 }
2040
2041 if (granted || (i == WLANTL_AC_HIGH_PRIO))
2042 {
2043 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
2044 staId, (WLANTL_ACEnumType)i);
2045 if (!VOS_IS_STATUS_SUCCESS(status))
2046 {
2047 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
2048 "%s: Failure in indicating pkt to TL for QID=%d",
2049 __func__, i);
2050 }
2051 }
2052 }
2053 }
2054 }
2055}
2056
Jeff Johnson295189b2012-06-20 16:38:30 -07002057static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
2058 tCsrRoamInfo *pRoamInfo,
2059 v_U8_t staId,
2060 v_MACADDR_t *pPeerMacAddress,
2061 tSirBssDescription *pBssDesc )
2062{
2063 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2064 WLAN_STADescType staDesc = {0};
2065 eCsrEncryptionType connectedCipherAlgo;
2066 v_BOOL_t fConnected;
2067 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2068 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002069 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002070
2071 if ( NULL == pBssDesc)
2072 {
2073 return VOS_STATUS_E_FAILURE;
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 // Get the Station ID from the one saved during the assocation.
2076 staDesc.ucSTAId = staId;
2077
Katya Nigam47528772015-02-11 12:24:49 +05302078 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002079
Katya Nigam47528772015-02-11 12:24:49 +05302080 // grab the bssid from the connection info in the adapter structure and hand that
2081 // over to TL when registering.
2082 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
2083 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002084
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2086
2087 // set the QoS field appropriately
2088 if (hdd_wmm_is_active(pAdapter))
2089 {
2090 staDesc.ucQosEnabled = 1;
2091 }
2092 else
2093 {
2094 staDesc.ucQosEnabled = 0;
2095 }
2096
2097 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2098 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
2099 {
2100 staDesc.ucProtectedFrame = 1;
2101 }
2102 else
2103 {
2104 staDesc.ucProtectedFrame = 0;
2105
2106 }
2107
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002108#ifdef FEATURE_WLAN_ESE
2109 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
2110#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002111
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 /* check whether replay check is valid for the station or not */
2113 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
2114 {
2115 /* Encryption mode is either TKIP or AES
2116 and replay check is valid for only these
2117 two encryption modes */
2118 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2119 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2120 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
2121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 else
2123 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002124 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002126 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2128 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
2129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002130
2131#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002132 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07002133 if (pAdapter->wapi_info.fIsWapiSta)
2134 {
2135 staDesc.ucIsWapiSta = 1;
2136 }
2137 else
2138 {
2139 staDesc.ucIsWapiSta = 0;
2140 }
2141#endif /* FEATURE_WLAN_WAPI */
2142
2143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2144 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
2145
Jeff Johnson295189b2012-06-20 16:38:30 -07002146 // UMA is Not ready yet, Xlation will be done by TL
2147 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 staDesc.ucSwFrameRXXlation = 1;
2149 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 staDesc.ucQosEnabled );
2152 // Initialize signatures and state
2153 staDesc.ucUcastSig = pRoamInfo->ucastSig;
2154 staDesc.ucBcastSig = pRoamInfo->bcastSig;
2155 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
2156 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002157 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08002158 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 -07002159 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
2160 hdd_rx_packet_cbk,
2161 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 hdd_tx_fetch_packet_cbk, &staDesc,
2163 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002164
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2166 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002168 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002170 return vosStatus;
2171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002172
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002173 if ( cfg_param->dynSplitscan &&
2174 ( VOS_TIMER_STATE_RUNNING !=
2175 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
2176 {
2177 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2178 cfg_param->trafficMntrTmrForSplitScan);
2179 }
2180
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302181 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
2182 // then go to 'authenticated'. For all other authentication types
2183 // (those that donot require upper layer authentication) we can put
2184 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002185 if (staDesc.wSTAType != WLAN_STA_IBSS)
2186 VOS_ASSERT( fConnected );
2187
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302188 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002189 {
2190 // Connections that do not need Upper layer auth, transition TL directly
2191 // to 'Authenticated' state.
2192 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
2193 WLANTL_STA_AUTHENTICATED );
2194
2195 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302196
2197 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002198 }
2199 else
2200 {
2201 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302202 "ULA auth StaId= %d. Changing TL state to CONNECTED"
2203 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002204 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05302205 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002206 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2207 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 return( vosStatus );
2209}
2210
Jeff Johnson295189b2012-06-20 16:38:30 -07002211static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
2212 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
2213{
2214 unsigned int len = 0;
2215 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002216 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 tANI_U32 rspRsnLength = 0;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302218 struct cfg80211_bss* bss;
2219 tCsrRoamConnectedProfile roam_profile;
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 struct ieee80211_channel *chan;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302221 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002222
Agarwal Ashish51325b52014-06-16 16:50:49 +05302223 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002224 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07002225 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002226 }
2227
Agarwal Ashish51325b52014-06-16 16:50:49 +05302228 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002229 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
2230 goto done;
2231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002232
Ashish Kumar Dhanotiya7b48fd92020-02-11 18:14:46 +05302233 if (pCsrRoamInfo->nAssocRspLength < FT_ASSOC_RSP_IES_OFFSET) {
2234
2235 hddLog(LOGE, "%s: Invalid assoc response length %d",
2236 __func__, pCsrRoamInfo->nAssocRspLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002237 goto done;
2238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
2240 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2241 pCsrRoamInfo->nAssocReqLength);
2242 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002243 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002244
2245 //pFTAssocRsp needs to point to the IEs
2246 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002247 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 (unsigned int)pFTAssocRsp[0],
2249 (unsigned int)pFTAssocRsp[1]);
2250
2251 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08002252 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Ashish Kumar Dhanotiya7b48fd92020-02-11 18:14:46 +05302253 if (len > IW_GENERIC_IE_MAX) {
2254 hddLog(LOGE, "%s: Invalid assoc response length %d",
2255 __func__, pCsrRoamInfo->nAssocRspLength);
2256 goto done;
2257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002260 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002261
Abhishek Singh5a597e62016-12-05 15:16:30 +05302262 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
2263 (int) pCsrRoamInfo->pBssDesc->channelId);
2264 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
2265 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
2266 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2267 chan, pCsrRoamInfo->bssid,
2268 &roam_profile.SSID.ssId[0],
2269 roam_profile.SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302270 hdd_send_roamed_ind(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 reqRsnIe, reqRsnLength,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302272 rspRsnIe, rspRsnLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002273
2274done:
2275 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07002276}
Jeff Johnson295189b2012-06-20 16:38:30 -07002277
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302278void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
2279{
2280 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2281 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2282 tCsrRoamInfo roamInfo;
2283 roamInfo.fAuthRequired = FALSE;
2284 vos_mem_copy(roamInfo.bssid,
2285 pHddStaCtx->roam_info.bssid,
2286 WNI_CFG_BSSID_LEN);
2287 vos_mem_copy(roamInfo.peerMac,
2288 pHddStaCtx->roam_info.peerMac,
2289 WNI_CFG_BSSID_LEN);
2290
2291 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
2292 &roamInfo,
2293 pHddStaCtx->roam_info.roamId,
2294 pHddStaCtx->roam_info.roamStatus,
2295 eCSR_ROAM_RESULT_AUTHENTICATED);
2296 if (halStatus != eHAL_STATUS_SUCCESS)
2297 {
2298 hddLog(LOGE, "%s: Set Key complete failure", __func__);
2299 }
2300 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
2301}
2302
Abhishek Singh78c691f2017-11-30 13:48:44 +05302303/**
2304 * hdd_schedule_ecsa_chan_change_work() - schedule ecsa chan change work
2305 * @hal: hal context
2306 * @sta_session_id: sta session id
2307 *
2308 * Return: void.
2309 */
2310static void
2311hdd_schedule_ecsa_chan_change_work(hdd_context_t *hdd_ctx,
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302312 uint8_t sta_session_id)
Abhishek Singh78c691f2017-11-30 13:48:44 +05302313{
2314 v_TIME_t conn_start_time;
2315 int32_t time_diff;
2316
2317 conn_start_time = sme_get_connect_strt_time(hdd_ctx->hHal, sta_session_id);
2318 time_diff = vos_timer_get_system_time() - conn_start_time;
2319
2320 if (time_diff < 0)
2321 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL;
2322 else if (time_diff > ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL)
2323 time_diff = 0;
2324 else
2325 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL - time_diff;
2326
2327 hddLog(LOG1, FL("schedule ecsa_chan_change_work after %d ms"), time_diff);
2328 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
2329 msecs_to_jiffies(time_diff));
2330}
2331
Shailender Karmuchia734f332013-04-19 14:02:48 -07002332static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2333 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002334 eCsrRoamResult roamResult )
2335{
2336 struct net_device *dev = pAdapter->dev;
2337 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2338 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302339 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05302340 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002341 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2342 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002343#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 int ft_carrier_on = FALSE;
2345#endif
2346 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302347 v_BOOL_t hddDisconInProgress = FALSE;
2348
2349 /* HDD has initiated disconnect, do not send connect result indication
2350 * to kernel as it will be handled by __cfg80211_disconnect.
2351 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05302352 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
2353 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
2354 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2355 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302356 {
2357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2358 FL(" Disconnect from HDD in progress "));
2359 hddDisconInProgress = TRUE;
2360 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002361
Jeff Johnson295189b2012-06-20 16:38:30 -07002362 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
2363 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302364 if ( !hddDisconInProgress )
2365 {
2366 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05302367 "%s: Set HDD connState to eConnectionState_Associated",
2368 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302369 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
2370 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002371
c_hpothu44ff4e02014-05-08 00:13:57 +05302372 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 // Save the connection info from CSR...
2374 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05302375
2376#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2377 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
2378 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
2379 !hddDisconInProgress &&
2380 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
2381 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
2382 sme_set_per_roam_rxconfig(pHddCtx->hHal,
2383 pHddStaCtx->conn_info.staId[0],
2384 pHddCtx->cfg_ini->rateDownThreshold,
2385 pHddCtx->cfg_ini->rateUpThreshold,
2386 pHddCtx->cfg_ini->PERroamTriggerPercent,
2387 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
2388 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
2389#endif
2390
Jeff Johnson295189b2012-06-20 16:38:30 -07002391#ifdef FEATURE_WLAN_WAPI
2392 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
2393 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
2394 {
2395 pAdapter->wapi_info.fIsWapiSta = 1;
2396 }
2397 else
2398 {
2399 pAdapter->wapi_info.fIsWapiSta = 0;
2400 }
2401#endif /* FEATURE_WLAN_WAPI */
2402
2403 // indicate 'connect' status to userspace
2404 hdd_SendAssociationEvent(dev,pRoamInfo);
2405
2406
Shailender Karmuchia734f332013-04-19 14:02:48 -07002407 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002408 INIT_COMPLETION(pAdapter->linkup_event_var);
2409
2410 /*
2411 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
2412 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 -07002413 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 know that the device is getting activated properly.
2415 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002416#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05302417 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07002418 {
2419#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002420 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002421 pAdapter->isLinkUpSvcNeeded = TRUE;
2422
Shailender Karmuchia734f332013-04-19 14:02:48 -07002423 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002424 pAdapter->isLinkUpSvcNeeded = TRUE;
2425
2426 // Switch on the Carrier to activate the device
2427 netif_carrier_on(dev);
2428
2429 // Wait for the Link to up to ensure all the queues are set properly by the kernel
2430 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
2431 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002432 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 {
2434 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
2435 }
2436
2437 // Disable Linkup Event Servicing - no more service required from the net device notifier call
2438 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002439#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002441 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002442 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002444 }
2445#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05302446 /* Check for STAID */
2447 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
2448 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2449 else
2450 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002451
2452 //For reassoc, the station is already registered, all we need is to change the state
2453 //of the STA in TL.
2454 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05302455 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 if( !pRoamInfo->fReassocReq )
2457 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002458 struct cfg80211_bss *bss;
2459#ifdef WLAN_FEATURE_VOWIFI_11R
2460 u8 *pFTAssocRsp = NULL;
2461 unsigned int assocRsplen = 0;
2462 u8 *pFTAssocReq = NULL;
2463 unsigned int assocReqlen = 0;
2464 struct ieee80211_channel *chan;
2465#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002468
2469 /* add bss_id to cfg80211 data base */
2470 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2471 if (NULL == bss)
2472 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302473 hddLog(LOGE,
2474 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05302475 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302476 if (!hddDisconInProgress) {
2477 /*
2478 * Here driver was not able to update cfg80211 database
2479 * this can happen if connected channel is not valid,
2480 * i.e reg domain was changed during connection.
2481 * Queue disconnect for the session if disconnect is
2482 * not in progress.
2483 */
2484 hddLog(LOGE, FL("Disconnecting..."));
2485 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2486 pAdapter->sessionId,
2487 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 return eHAL_STATUS_FAILURE;
2490 }
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302491
2492 //Association Response
2493 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames +
2494 pRoamInfo->nBeaconLength +
2495 pRoamInfo->nAssocReqLength);
2496 if (pFTAssocRsp != NULL)
2497 {
2498 // pFTAssocRsp needs to point to the IEs
2499 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2500 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
2501 (unsigned int)pFTAssocRsp[0],
2502 (unsigned int)pFTAssocRsp[1]);
2503 assocRsplen =
2504 pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2505 }
2506 else
2507 {
2508 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
2509 assocRsplen = 0;
2510 }
2511
2512 //Association Request
2513 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
2514 pRoamInfo->nBeaconLength);
2515 if (pFTAssocReq != NULL)
2516 {
2517 if(!ft_carrier_on)
2518 {
2519 // pFTAssocReq needs to point to the IEs
2520 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
2521 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
2522 (unsigned int)pFTAssocReq[0],
2523 (unsigned int)pFTAssocReq[1]);
2524 assocReqlen =
2525 pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
2526 }
2527 else
2528 {
2529 /* This should contain only the FTIEs */
2530 assocReqlen = pRoamInfo->nAssocReqLength;
2531 }
2532 }
2533 else
2534 {
2535 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
2536 assocReqlen = 0;
2537 }
2538
2539 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
2540 assocRsplen);
2541
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002542#ifdef WLAN_FEATURE_VOWIFI_11R
2543 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002544 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07002545 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002546 if(ft_carrier_on)
2547 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302548 if ( !hddDisconInProgress )
2549 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05302550 struct cfg80211_bss *roam_bss;
2551
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302552 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002553 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302554 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002555 (int)pRoamInfo->pBssDesc->channelId);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302556 if (pHddCtx->cfg_ini &&
2557 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302558 {
2559 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2560 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05302561 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2562 chan, pRoamInfo->bssid,
2563 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2564 pRoamInfo->u.pConnectedProfile->SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302565 hdd_send_roamed_ind(dev, roam_bss,
Abhishek Singh5a597e62016-12-05 15:16:30 +05302566 pFTAssocReq, assocReqlen,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302567 pFTAssocRsp, assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302568 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302569 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2570 {
2571 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
2572 pRoamInfo->fAuthRequired = FALSE;
2573
2574 vos_mem_copy(pHddStaCtx->roam_info.bssid,
2575 pRoamInfo->bssid,
2576 HDD_MAC_ADDR_LEN);
2577 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
2578 pRoamInfo->peerMac,
2579 HDD_MAC_ADDR_LEN);
2580 pHddStaCtx->roam_info.roamId = roamId;
2581 pHddStaCtx->roam_info.roamStatus = roamStatus;
2582 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
2583 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002584 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302585 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002586 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002587 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002588 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302589 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
2590 pFTAssocReq, assocReqlen,
2591 pFTAssocRsp, assocRsplen,
2592 WLAN_STATUS_SUCCESS,
2593 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002594 }
2595 }
2596 else
2597#endif
2598 {
2599 /* wpa supplicant expecting WPA/RSN IE in connect result */
2600 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2601 pAdapter->sessionId,
2602 &reqRsnLength,
2603 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002604
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002605 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2606 pAdapter->sessionId,
2607 &rspRsnLength,
2608 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302609 if ( !hddDisconInProgress )
2610 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002611#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302612 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05302613 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302614 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302615 if (pHddCtx->cfg_ini &&
2616 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302617 {
2618 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2619 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302620 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302621 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002622#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002623
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302624 {
2625 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302626 "%s: sending connect indication to nl80211:"
2627 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302628 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302629 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
2630 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302631 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302632 hdd_connect_result(dev, pRoamInfo->bssid,
2633 pRoamInfo,
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302634 pFTAssocReq, assocReqlen,
2635 pFTAssocRsp, assocRsplen,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302636 WLAN_STATUS_SUCCESS,
2637 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302638 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302641 if ( !hddDisconInProgress )
2642 {
2643 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07002644#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302645 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07002646#endif
2647 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302648 // Register the Station with TL after associated...
2649 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 pRoamInfo,
2651 pHddStaCtx->conn_info.staId[ 0 ],
2652 NULL,
2653 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 }
2656 else
2657 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002658 /* wpa supplicant expecting WPA/RSN IE in connect result */
2659 /* in case of reassociation also need to indicate it to supplicant */
2660 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2661 pAdapter->sessionId,
2662 &reqRsnLength,
2663 reqRsnIe);
2664
2665 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302667 if( pRoamInfo->fAuthRequired )
2668 {
2669 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2670 pHddStaCtx->conn_info.staId[ 0 ],
2671 WLANTL_STA_CONNECTED );
2672 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2673 }
2674 else
2675 {
2676 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2677 "%s: staId: %d Changing TL state to AUTHENTICATED",
2678 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
2679 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2680 pHddStaCtx->conn_info.staId[ 0 ],
2681 WLANTL_STA_AUTHENTICATED );
2682 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302683 hdd_postTLPacketPendingInd(pAdapter,
2684 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002686 }
2687
2688 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
2689 {
2690 // perform any WMM-related association processing
2691 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
2692 }
2693 else
2694 {
2695 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002696 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 vosStatus, vosStatus );
2698 }
Chet Lanctot186b5732013-03-18 10:26:30 -07002699#ifdef WLAN_FEATURE_11W
2700 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
2701 sizeof(pAdapter->hdd_stats.hddPmfStats) );
2702#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302703
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05302705 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302706 {
2707 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05302708 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302709 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302710 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302711 {
2712 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
2713 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05302714#ifdef FEATURE_WLAN_TDLS
2715 wlan_hdd_tdls_connection_callback(pAdapter);
2716#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002717 }
2718 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2721
2722 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002723 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302724 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2725 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
2726 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002727 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2729 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08002730 MAC_ADDR_ARRAY(pWextState->req_bssId),
2731 roamResult, roamStatus);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302732 if (!pHddStaCtx->get_mgmt_log_sent) {
2733 pHddStaCtx->get_mgmt_log_sent = TRUE;
Abhishek Singh611295e2015-07-09 11:11:54 +05302734 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302735 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302736 }
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302737
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302738 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2739 (pRoamInfo &&
2740 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2741 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2742 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05302743 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302744 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2745 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2746 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2747 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05302748 /* Set connection state to eConnectionState_NotConnected only when CSR
2749 * has completed operation - with a ASSOCIATION_FAILURE status
2750 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302751 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05302752 {
2753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2754 "%s: Set HDD connState to eConnectionState_NotConnected",
2755 __func__);
2756 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2757 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302758 if((pHddCtx->concurrency_mode <= 1) &&
2759 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 {
2761 pHddCtx->isAmpAllowed = VOS_TRUE;
2762 }
2763
2764 //If the Device Mode is Station
2765 // and the P2P Client is Connected
2766 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002767
2768 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002769 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002770 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2771 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302772 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 {
2774 //Enable BMPS only of other Session is P2P Client
2775 hdd_context_t *pHddCtx = NULL;
2776 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2777
2778 if (NULL != pVosContext)
2779 {
2780 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2781
2782 if(NULL != pHddCtx)
2783 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302784 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302785 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2786 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302787 {
2788 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002789 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302790 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002791 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302792 hdd_enable_bmps_imps(pHddCtx);
2793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 }
2795 }
2796 }
2797
James Zmudafbf5ffc2013-03-25 12:45:35 -07002798 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002799 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302800 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002801 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302802
2803 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2804 {
2805 hddLog(LOG1,
2806 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2807 wlan_hdd_tdls_reenable(pHddCtx);
2808 }
2809
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302810 if (pRoamInfo) {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302811 hddLog(VOS_TRACE_LEVEL_ERROR,
2812 "%s: send connect failure to nl80211:"
2813 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302814 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302815 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302816 roamResult, roamStatus, pRoamInfo->reasonCode);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302817 pHddStaCtx->conn_info.assoc_status_code =
2818 pRoamInfo->statusCode;
2819 } else {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302820 hddLog(VOS_TRACE_LEVEL_ERROR,
2821 "%s: connect failed:"
2822 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302823 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302824 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2825 roamResult, roamStatus);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302826 }
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302827
James Zmudafbf5ffc2013-03-25 12:45:35 -07002828 /* inform association failure event to nl80211 */
2829 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2830 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002831 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302832 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002833 NULL, 0, NULL, 0,
2834 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302835 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002836 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302837 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002838 NULL, 0, NULL, 0,
2839 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302840 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002841 }
2842 else
2843 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002844 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302845 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002846 NULL, 0, NULL, 0,
2847 pRoamInfo->reasonCode ?
2848 pRoamInfo->reasonCode :
2849 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302850 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002851 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302852 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002853 NULL, 0, NULL, 0,
2854 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302855 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002856 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302857 /*Clear the roam profile*/
2858 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002860
Kumar Anand82c009f2014-05-29 00:29:42 -07002861 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002862
c_hpothu24f40982014-04-18 18:00:36 +05302863 if (pRoamInfo)
2864 {
2865 WLANTL_AssocFailed(pRoamInfo->staId);
2866 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302867
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302868 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 netif_tx_disable(dev);
2870 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002871
Jeff Johnson295189b2012-06-20 16:38:30 -07002872 }
2873
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302874 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302875 {
2876 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2877 if (pHostapdAdapter != NULL)
2878 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302879 /* Restart SAP if its operating channel is different
2880 * from AP channel.
2881 */
2882 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2883 (int)pRoamInfo->pBssDesc->channelId)
2884 {
2885 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2886 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2887 (int)pRoamInfo->pBssDesc->channelId);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302888 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->force_scc_with_ecsa)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302889 {
Abhishek Singh78c691f2017-11-30 13:48:44 +05302890 hdd_schedule_ecsa_chan_change_work(pHddCtx,
2891 pAdapter->sessionId);
2892 }
2893 else
2894 {
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302895 hdd_hostapd_stop(pHostapdAdapter->dev);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302896 if (pHddCtx->cfg_ini &&
2897 pHddCtx->cfg_ini->enable_sap_auth_offload)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302898 hdd_force_scc_restart_sap(pHostapdAdapter,
2899 pHddCtx, (int)pRoamInfo->pBssDesc->channelId);
2900 }
Agrawal Ashish574b3e62017-02-09 18:58:34 +05302901
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302902 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302903 }
2904 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302905 else if (roamStatus == eCSR_ROAM_ASSOCIATION_FAILURE)
2906 {
2907 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
2908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 return eHAL_STATUS_SUCCESS;
2910}
2911
2912/**============================================================================
2913 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002914 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002916
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002918static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2919 tCsrRoamInfo *pRoamInfo,
2920 tANI_U32 roamId,
2921 eRoamCmdStatus roamStatus,
2922 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002923{
Katya Nigam47528772015-02-11 12:24:49 +05302924 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2925 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2926 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302927 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302928
Jeff Johnson81c17882013-05-03 09:53:35 -07002929 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2930 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2931
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 switch( roamResult )
2933 {
2934 // both IBSS Started and IBSS Join should come in here.
2935 case eCSR_ROAM_RESULT_IBSS_STARTED:
2936 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002937 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002939 if (NULL == pRoamInfo)
2940 {
2941 VOS_ASSERT(0);
2942 return;
2943 }
2944
2945 /* When IBSS Started comes from CSR, we need to move
2946 * connection state to IBSS Disconnected (meaning no peers
2947 * are in the IBSS).
2948 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302949 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2950 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2951 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002952 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2953 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302954 /*notify wmm */
2955 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002956 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002957
Jeff Johnson81c17882013-05-03 09:53:35 -07002958 if (pRoamInfo->pBssDesc)
2959 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302960#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2961 struct ieee80211_channel *chan;
2962 int chan_no;
2963 unsigned int freq;
2964#endif
Katya Nigam47528772015-02-11 12:24:49 +05302965 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2966 IBSS_BROADCAST_STAID,
2967 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002968
2969 /* we created the IBSS, notify supplicant */
2970 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2971 MAC_ADDRESS_STR,
2972 __func__, pAdapter->dev->name,
2973 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2974
2975 /* we must first give cfg80211 the BSS information */
2976 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2977 if (NULL == bss)
2978 {
2979 hddLog(VOS_TRACE_LEVEL_ERROR,
2980 "%s: %s: unable to create IBSS entry",
2981 __func__, pAdapter->dev->name);
2982 return;
2983 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302984#ifdef WLAN_FEATURE_RMC
2985 netif_carrier_on(pAdapter->dev);
2986 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2987 netif_tx_start_all_queues(pAdapter->dev);
2988#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302989#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2990 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002991
Anand N Sunkadfec40682015-07-29 09:51:17 +05302992 if (chan_no <= 14)
2993 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302994 HDD_NL80211_BAND_2GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302995 else
2996 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302997 HDD_NL80211_BAND_5GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302998
2999 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3000
3001 if (chan)
3002 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3003 chan, GFP_KERNEL);
3004 else
3005 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
3006 pAdapter->dev->name,
3007 (int)pRoamInfo->pBssDesc->channelId);
3008#else
Jeff Johnson81c17882013-05-03 09:53:35 -07003009 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05303010#endif
Yue Maf49ba872013-08-19 12:04:25 -07003011 cfg80211_put_bss(
3012#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3013 pHddCtx->wiphy,
3014#endif
3015 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07003016 }
Katya Nigam47528772015-02-11 12:24:49 +05303017 else
3018 {
3019 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3020 "%s: NULL Bss Desc",__func__);
3021 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303022
3023 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
3024 * in IBSS_COALESCED will remove the BC key.
3025 */
3026 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
3027 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
3028 == pHddStaCtx->ibss_enc_key.encType
3029 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
3030 == pHddStaCtx->ibss_enc_key.encType
3031 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3032 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
3033 {
3034 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3035 VOS_STATUS vosStatus;
3036
3037 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
3038
3039 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3040 grpmacaddr, WNI_CFG_BSSID_LEN);
3041 hddLog(VOS_TRACE_LEVEL_INFO,
3042 FL(" SET GTK in case of COALESCED"));
3043 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3044 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3045 if ( VOS_STATUS_SUCCESS != vosStatus )
3046 {
3047 hddLog(VOS_TRACE_LEVEL_ERROR,
3048 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
3049 }
3050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 break;
3052 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003053
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3055 {
Jeff Johnson81c17882013-05-03 09:53:35 -07003056 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
3057 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 break;
3059 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003060
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07003062 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
3063 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003065 }
3066
Jeff Johnson81c17882013-05-03 09:53:35 -07003067 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003068}
3069
3070/**============================================================================
3071 *
3072 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
3073 This information is passed to iwconfig later. The peer that joined
3074 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003075 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003077
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05303079static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07003080{
3081 int fSuccess = FALSE;
3082 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303083 VOS_STATUS status;
3084 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003085
Jeff Johnson295189b2012-06-20 16:38:30 -07003086 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3087 {
3088 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
3089 {
3090 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003091
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003093
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 fSuccess = TRUE;
3095 break;
3096 }
3097 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003098
Nirav Shah7e3c8132015-06-22 23:51:42 +05303099 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
3100 if (status != VOS_STATUS_SUCCESS) {
3101 hddLog(VOS_TRACE_LEVEL_ERROR,
3102 FL("Not able to add staid hash %d"), staId);
3103 return FALSE;
3104 }
3105
3106 hddLog(VOS_TRACE_LEVEL_INFO,
3107 FL("New station added sta_id %d mac:"
3108 MAC_ADDRESS_STR), staId,
3109 MAC_ADDR_ARRAY(peerMacAddress->bytes));
3110
Shailender Karmuchia734f332013-04-19 14:02:48 -07003111 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07003112}
3113/**============================================================================
3114 *
3115 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003116 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003118
Jeff Johnson295189b2012-06-20 16:38:30 -07003119 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07003120static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003121{
3122 int fSuccess = FALSE;
3123 int idx = 0;
3124 v_U8_t valid_idx = 0;
3125 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07003126 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003127 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05303128 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003129
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3131 {
3132 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
3133 {
3134 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303135 status = hdd_sta_id_hash_remove_entry(pAdapter,
3136 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
3137 if (status != VOS_STATUS_SUCCESS) {
3138 hddLog(VOS_TRACE_LEVEL_ERROR,
3139 FL("Not able to remove staid hash %d"), staId );
3140 fSuccess = FALSE;
3141 } else {
3142 hddLog(VOS_TRACE_LEVEL_INFO,
3143 FL("station removed sta_id %d mac:"
3144 MAC_ADDRESS_STR), staId,
3145 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07003146
Nirav Shah7e3c8132015-06-22 23:51:42 +05303147 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07003148
Nirav Shah7e3c8132015-06-22 23:51:42 +05303149 fSuccess = TRUE;
3150 // Note the deleted Index, if its 0 we need special handling
3151 del_idx = idx;
3152 empty_slots++;
3153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 }
3155 else
3156 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003157 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 {
3159 valid_idx = idx;
3160 }
Ravi Joshi8a934352013-09-25 16:46:58 -07003161 else
3162 {
3163 // Found an empty slot
3164 empty_slots++;
3165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003166 }
3167 }
3168
Ravi Joshi8a934352013-09-25 16:46:58 -07003169 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
3170 {
3171 // Last peer departed, set the IBSS state appropriately
3172 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003173 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07003174 "Last IBSS Peer Departed!!!" );
3175 }
3176
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 // Find next active staId, to have a valid sta trigger for TL.
3178 if (fSuccess == TRUE)
3179 {
3180 if (del_idx == 0)
3181 {
3182 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
3183 {
3184 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
3185 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
3186 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
3187
3188 pHddStaCtx->conn_info.staId[valid_idx] = 0;
3189 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
3190 }
3191 }
3192 }
3193 return( fSuccess );
3194}
3195
3196/**============================================================================
3197 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003198 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07003199 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 ===========================================================================*/
3202static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
3203{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003204 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05303205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3206 "%s: IBSS Connect Indication from SME!!! "
3207 "Set HDD connState to eConnectionState_IbssConnected",
3208 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
3210 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
3211
3212 // Save the connection info from CSR...
3213 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
3214
3215 // Send the bssid address to the wext.
3216 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003218 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3219 if (NULL == bss)
3220 {
3221 hddLog(VOS_TRACE_LEVEL_ERROR,
3222 "%s: %s: unable to create IBSS entry",
3223 __func__, pAdapter->dev->name);
3224 return eHAL_STATUS_FAILURE;
3225 }
Yue Maf49ba872013-08-19 12:04:25 -07003226 cfg80211_put_bss(
3227#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3228 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
3229#endif
3230 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07003231
3232 return( eHAL_STATUS_SUCCESS );
3233}
Mukul Sharmad2589a52014-04-23 21:06:25 +05303234
3235/**============================================================================
3236 *
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003238
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003240static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3241 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 eCsrRoamResult roamResult )
3243{
3244 eCsrEncryptionType connectedCipherAlgo;
3245 v_BOOL_t fConnected = FALSE;
3246 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3247 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303248 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303250 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07003252
3253 if (NULL == pRoamInfo)
3254 {
3255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
3256 return eHAL_STATUS_FAILURE;
3257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003259 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 // not require upper layer authentication) we can put TL directly into 'authenticated'
3261 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003262 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3263 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
3264 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003265
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3267 if( fConnected )
3268 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003269 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
3270 {
3271 v_U8_t staId;
3272
3273 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
3274
3275 if ( 0 == memcmp( pRoamInfo->peerMac,
3276 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
3277 {
3278 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3279 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05303280 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3281 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003282 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3283 }
3284 else
3285 {
3286 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
3287 (v_MACADDR_t*)pRoamInfo->peerMac,
3288 &staId);
3289 if ( VOS_STATUS_SUCCESS == vosStatus )
3290 {
3291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3292 "WLAN TL STA Ptk Installed for STAID=%d", staId);
3293 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3294 staId);
3295 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3296 }
3297 }
3298 }
3299 else
3300 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05303301 WLANTL_GetSTAState(pHddCtx->pvosContext,
3302 pHddStaCtx->conn_info.staId[0],
3303 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303304 // TODO: Considering getting a state machine in HDD later.
3305 // This routine is invoked twice. 1)set PTK 2)set GTK.
3306 // The folloing if statement will be TRUE when setting GTK.
3307 // At this time we don't handle the state in detail.
3308 // Related CR: 174048 - TL not in authenticated state
3309 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
3310 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
3311 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303312
3313 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
3314 "for StaId=%d. Changing TL state to AUTHENTICATED from"
3315 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303316
3317 // Connections that do not need Upper layer authentication,
3318 // transition TL to 'Authenticated' state after the keys are set.
3319 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3320 pHddStaCtx->conn_info.staId[ 0 ],
3321 WLANTL_STA_AUTHENTICATED );
3322
3323 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303324
3325 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3326 hdd_postTLPacketPendingInd(pAdapter,
3327 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05303328 //Need to call offload because when roaming happen at that time fwr
3329 //clean offload info as part of the DelBss
3330 // No need to configure offload if host was not suspended
3331 spin_lock(&pHddCtx->filter_lock);
3332 if(pHddCtx->hdd_wlan_suspended)
3333 {
3334 spin_unlock(&pHddCtx->filter_lock);
3335 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
3336 }
3337 else
3338 {
3339 spin_unlock(&pHddCtx->filter_lock);
3340 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303341 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3342 {
3343 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
3344 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303345 }
3346 else
3347 {
3348 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3349 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303350
3351 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
3352 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
3353 {
3354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
3355 " for StaId=%d. Due to OSEN, Changing TL state to"
3356 "AUTHENTICATED from state:%d",
3357 pHddStaCtx->conn_info.staId[0], prevTLState);
3358
3359 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3360 pHddStaCtx->conn_info.staId[ 0 ],
3361 WLANTL_STA_AUTHENTICATED );
3362
3363 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3364
3365 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3366 hdd_postTLPacketPendingInd(pAdapter,
3367 pHddStaCtx->conn_info.staId[0]);
3368 }
3369
3370
3371
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303372 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3373 {
3374 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
3375 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303376 }
3377
3378 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003379 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303381 else
3382 {
3383 // possible disassoc after issuing set key and waiting set key complete
3384 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3385 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003386
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 EXIT();
3388 return( eHAL_STATUS_SUCCESS );
3389}
3390/**============================================================================
3391 *
3392 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
3393 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003394static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07003396{
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3398
3399 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3400 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
3401 {
3402 struct iw_michaelmicfailure msg;
3403 union iwreq_data wreq;
3404 memset(&msg, '\0', sizeof(msg));
3405 msg.src_addr.sa_family = ARPHRD_ETHER;
3406 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08003407 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
3408 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07003409
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3411 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003412 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 msg.flags = IW_MICFAILURE_PAIRWISE;
3414 memset(&wreq, 0, sizeof(wreq));
3415 wreq.data.length = sizeof(msg);
3416 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003417 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003418 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3420 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
3421 NL80211_KEYTYPE_GROUP :
3422 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07003423 pRoamInfo->u.pMICFailureInfo->keyId,
3424 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003426
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003428
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 return( eHAL_STATUS_SUCCESS );
3430}
3431
3432/**============================================================================
3433 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003434 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003436
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003438static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3439 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 eCsrRoamResult roamResult )
3441{
3442 VOS_STATUS vosStatus;
3443
3444 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3445 switch( roamResult )
3446 {
3447 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3448 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003449 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303450 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303452 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3453 "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 -07003454 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3455 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003457
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3459
Shailender Karmuchia734f332013-04-19 14:02:48 -07003460 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
3461 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
3462 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
3463
3464 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05303465 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 pRoamInfo,
3467 pRoamInfo->staId,
3468 (v_MACADDR_t *)pRoamInfo->peerMac,
3469 pRoamInfo->pBssDesc );
3470 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3471 {
3472 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003473 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 vosStatus, vosStatus );
3475 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05303476 if (!roamSaveIbssStation(pAdapter,
3477 pRoamInfo->staId,
3478 (v_MACADDR_t *)pRoamInfo->peerMac))
3479 {
3480 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
3481 break;
3482 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003483 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303484
3485 staInfo = vos_mem_malloc(sizeof(*staInfo));
3486 if (staInfo == NULL) {
3487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3488 "memory allocation for station_info failed");
3489 return eHAL_STATUS_FAILED_ALLOC;
3490 }
3491
3492 memset(staInfo, 0, sizeof(*staInfo));
3493 staInfo->filled = 0;
3494 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003495
3496 cfg80211_new_sta(pAdapter->dev,
3497 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303498 staInfo, GFP_KERNEL);
3499 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003500
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003501 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3502 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3503 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3504 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
3505 {
3506 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05303507
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003508 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3509 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
3510
3511 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003512 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003513 pHddStaCtx->ibss_enc_key.encType);
3514
3515 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3516 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3517
3518 if ( VOS_STATUS_SUCCESS != vosStatus )
3519 {
3520 hddLog(VOS_TRACE_LEVEL_ERROR,
3521 "%s: sme_RoamSetKey failed, returned %d",
3522 __func__, vosStatus);
3523 return VOS_STATUS_E_FAILURE;
3524 }
3525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303527 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 netif_tx_start_all_queues(pAdapter->dev);
3529 break;
3530 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003531
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3533 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003534
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003536
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003539 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3540 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003541 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003542
Ravi Joshicc57ed42013-10-12 16:31:25 -07003543 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 {
3545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3546 "IBSS peer departed by cannot find peer in our registration table with TL" );
3547 }
3548
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3550 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003551 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3552 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
3553 pRoamInfo->staId );
3554
Katya Nigam47528772015-02-11 12:24:49 +05303555 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003556
3557 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003558 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003559
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003560 cfg80211_del_sta(pAdapter->dev,
3561 (const u8 *)&pRoamInfo->peerMac,
3562 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 break;
3564 }
3565 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3566 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003567 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
3568 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303570 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 netif_tx_disable(pAdapter->dev);
3572 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05303573 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3574 "%s: Set HDD connState to eConnectionState_NotConnected",
3575 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003577
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 // Send the bssid address to the wext.
3579 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
3580 // clean up data path
3581 hdd_disconnect_tx_rx(pAdapter);
3582 break;
3583 }
3584 default:
3585 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003586
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003588
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 return( eHAL_STATUS_SUCCESS );
3590}
3591
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003592#ifdef FEATURE_WLAN_TDLS
3593/**============================================================================
3594 *
3595 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
3596 TL the new STA. This is called as part of ADD_STA in the TDLS setup
3597 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07003598
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003599 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303600VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
3601#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3602 const tANI_U8 *peerMac,
3603#else
3604 tANI_U8 *peerMac,
3605#endif
3606 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003607{
3608 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003609 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003610 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3611 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003612 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
3613 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003614 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3615 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003616
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003617 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3618 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003619 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003620 "%s not connected. ignored", __func__);
3621 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003622 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003623
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003624 /*
3625 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3626 * be peer MAC, here we are wokrking on direct Link
3627 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003628 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003629
3630 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003631
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003632 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003633 sizeof(tSirMacAddr) );
3634
3635 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
3636 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
3637
3638 /* set the QoS field appropriately ..*/
3639 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
3640 : (staDesc.ucQosEnabled = 0) ;
3641
3642 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08003643 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003644
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003645 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003646
3647 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003648 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003649
Shailender Karmuchia734f332013-04-19 14:02:48 -07003650 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003651 * UMA is ready we inform TL to do frame translation.
3652 */
3653 staDesc.ucSwFrameTXXlation = 1;
3654 staDesc.ucSwFrameRXXlation = 1;
3655 staDesc.ucAddRmvLLC = 1;
3656
3657 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003658 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003659
3660 /* tdls Direct Link do not need bcastSig */
3661 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003662
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003663 if(staDesc.ucProtectedFrame)
3664 staDesc.ucIsReplayCheckValid = VOS_TRUE;
3665 else
3666 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003667
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303668 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003669
Shailender Karmuchia734f332013-04-19 14:02:48 -07003670 /* Register the Station with TL... */
3671 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
3672 hdd_rx_packet_cbk,
3673 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003674 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003675
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003676 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3677 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003678 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003679 "%s: WLANTL_RegisterSTAClient() failed to register. "
3680 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003681 return vosStatus;
3682 }
3683
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003684 if ( cfg_param->dynSplitscan &&
3685 ( VOS_TIMER_STATE_RUNNING !=
3686 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
3687 {
3688 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
3689 cfg_param->trafficMntrTmrForSplitScan);
3690 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003691 return( vosStatus );
3692}
3693
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303694VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003695{
3696 VOS_STATUS vosStatus;
3697 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
3698 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3699 {
3700 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3701 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003702 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003703 __func__, staId, vosStatus, vosStatus );
3704 }
3705 return( vosStatus );
3706}
3707
3708
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003709/*
3710 * HDD interface between SME and TL to ensure TDLS client registration with
3711 * TL in case of new TDLS client is added and deregistration at the time
3712 * TDLS client is deleted.
3713 */
3714
Shailender Karmuchia734f332013-04-19 14:02:48 -07003715eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
3716 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003717 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07003718 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003719 eCsrRoamResult roamResult)
3720{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003721 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003722 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003723 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003724
Kaushik, Sushant8489f472014-01-27 11:41:22 +05303725 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08003726 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3727 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
3728 "ADD_TDLS_PEER" :
3729 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
3730 "DEL_TDLS_PEER" :
3731 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
3732 "DEL_TDLS_PEER_IND" :
3733 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3734 "DEL_ALL_TDLS_PEER_IND" :
3735 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
3736 "UPDATE_TDLS_PEER" :
3737 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303738 "LINK_ESTABLISH_REQ_RSP" :
3739 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
3740 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08003741 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003742 switch( roamResult )
3743 {
3744 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3745 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003746 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3747 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303748 hddTdlsPeer_t *curr_peer;
3749
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003751 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05303752 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303753
3754 mutex_lock(&pHddCtx->tdls_lock);
3755 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3756 pRoamInfo->peerMac, FALSE);
3757 if (NULL != curr_peer)
3758 curr_peer->link_status = eTDLS_LINK_TEARING;
3759 else
3760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3761 "%s %d curr_peer is Null", __func__,__LINE__);
3762 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003763 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003764 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003765 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003766
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003767 /* check if there is available index for this new TDLS STA */
3768 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3769 {
3770 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3771 {
3772 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3773 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3774
3775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003776 ("TDLS: STA IDX at %d is %d "
3777 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003778 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003779 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003780
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003781 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003782 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3783 status = eHAL_STATUS_SUCCESS ;
3784 break ;
3785 }
3786 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003787 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003788 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003789 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3791 "wlan_hdd_tdls_set_sta_id() failed");
3792 return VOS_FALSE;
3793 }
3794
3795 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303796 /* store the ucast signature , if required for further reference. */
3797
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003798 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303799 /* start TDLS client registration with TL */
3800 status = hdd_roamRegisterTDLSSTA( pAdapter,
3801 pRoamInfo->peerMac,
3802 pRoamInfo->staId,
3803 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303804 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003805 }
3806 else
3807 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003808 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003809 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003810 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003811 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003812 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003813 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003814 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003815 break ;
3816 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003817 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3818 {
3819 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3820 {
3821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3822 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3823 }
3824 /* store the ucast signature which will be used later when
3825 * registering to TL
3826 */
3827 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3828 complete(&pAdapter->tdls_add_station_comp);
3829 break;
3830 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303831 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3832 {
3833 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3834 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303835 hddTdlsPeer_t *curr_peer;
3836
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303837 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3838 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303839
3840 mutex_lock(&pHddCtx->tdls_lock);
3841 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3842 pRoamInfo->peerMac, FALSE);
3843 if (curr_peer)
3844 curr_peer->link_status = eTDLS_LINK_TEARING;
3845 else
3846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3847 "%s %d curr_peer is Null",__func__,__LINE__);
3848 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303849 }
3850 complete(&pAdapter->tdls_link_establish_req_comp);
3851 break;
3852 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303853 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3854 {
3855 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3856 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3857 "%s: Channel switch request failed. %d", __func__,
3858 pRoamInfo->statusCode);
3859 else
3860 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3861 "%s: Channel switch request Success", __func__);
3862 break;
3863 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003864 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003865 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003866 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003867 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003868 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003869 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3870 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003871 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003873 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3874
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303875 mutex_lock(&pHddCtx->tdls_lock);
3876 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3877 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303878 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003879 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3881 " Current status for peer" MAC_ADDRESS_STR "is %d",
3882 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303883 if (TDLS_IS_CONNECTED(curr_peer) ||
3884 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303885 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303886 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303887 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3888 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303889 else
3890 mutex_unlock(&pHddCtx->tdls_lock);
3891
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303892 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003893 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303894 else
3895 mutex_unlock(&pHddCtx->tdls_lock);
3896
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303897 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003898 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303899 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003900
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003901 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3902 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3903 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003904 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003905 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003906 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003907 break ;
3908 }
3909 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003910 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003911 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003912 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003913 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3914 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003915 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003916 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3917 "%s: Sending teardown to supplicant with reason code %u",
3918 __func__, pRoamInfo->reasonCode);
3919
3920#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303921 mutex_lock(&pHddCtx->tdls_lock);
3922 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3923 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003924 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303925 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3926 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303927 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003928#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003929 status = eHAL_STATUS_SUCCESS ;
3930 break ;
3931 }
3932 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3933 {
3934 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003935 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003936 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003937 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3938 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003939 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003941 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003942 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003943 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303944
3945 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003946 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303947 mutex_unlock(&pHddCtx->tdls_lock);
3948
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003949 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3950 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003951
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003952 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003953 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003954 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3955 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003956
3957 status = eHAL_STATUS_SUCCESS ;
3958 }
3959 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303960 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003961 break ;
3962 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003963 default:
3964 {
3965 break ;
3966 }
3967 }
3968
3969 return status ;
3970}
3971#endif
3972
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303973void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003974{
3975 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3976 hdd_context_t *pHddCtx = NULL;
3977 int ret;
3978
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303979 ENTER();
3980
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003981 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3982 {
3983 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003984 "%s: Bad param, pAdapter [%pK]",
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003985 __func__, pAdapter);
3986 return;
3987 }
3988
3989 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3990 ret = wlan_hdd_validate_context(pHddCtx);
3991 if (0 != ret)
3992 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003993 return;
3994 }
3995
3996 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3997 {
3998 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3999 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304000
4001 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004002}
4003
Shailender Karmuchia734f332013-04-19 14:02:48 -07004004eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
4006{
4007 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
4008 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304009 hdd_wext_state_t *pWextState = NULL;
4010 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004011 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304012 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07004013 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004014
4015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004016 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004017 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004018
4019 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304020 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004021 {
4022 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304023 "invalid adapter or adapter has invalid magic");
4024 return eHAL_STATUS_FAILURE;
4025 }
4026
4027 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4028 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4029
4030 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4031 {
4032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4033 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004034 return eHAL_STATUS_FAILURE;
4035 }
4036
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05304037 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4038 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 switch( roamStatus )
4040 {
4041 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05304042 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4043 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004045
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004046#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
4047 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07004049 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 * interface down */
4051 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304052 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
4053 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05304054 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4056 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4057 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4059 }
4060 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05304061 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 break;
4063
4064 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004065 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07004067 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 // eCSR_ROAM_SHOULD_ROAM will be received.
4069 // Where in we will not mark the link down
4070 // Also we want to stop tx at this point when we will be
4071 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004072 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 {
4074 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304075 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004076 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05304077 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4078 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
4079 {
4080 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
4081 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004082 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304083 * Deregister this STA with TL, but do not flush the packets
4084 * for this STA from wmm_tx_queue. Since there is no valid STA
4085 * for these packets they will not be transmitted. Eventually
4086 * after the reassociation is successful, these packets will be
4087 * transmitted after registering STA with TL again. This ensures
4088 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004089 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304090 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
4091 pHddStaCtx->conn_info.staId[0]);
4092 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004093 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304094 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4095 FL("WLANTL_ClearSTAClient failed for staID %d."
4096 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
4097 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004098 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004099 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 }
4101 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004102 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 break;
4104#endif
4105
4106 case eCSR_ROAM_SHOULD_ROAM:
4107 // Dont need to do anything
4108 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 struct net_device *dev = pAdapter->dev;
4110 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4111 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304112 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004114#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 if (pHddStaCtx->ft_carrier_on == FALSE)
4116 {
4117#endif
4118 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004119#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 }
4121#endif
4122
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004123#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 //We should clear all sta register with TL, for now, only one.
4125 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
4126 if ( !VOS_IS_STATUS_SUCCESS(status ) )
4127 {
4128 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4129 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
4130 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004131 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004133#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 }
4135 break;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05304136 case eCSR_ROAM_LOSTLINK_DETECTED:
4137 {
4138 if (wlan_hdd_check_and_stop_mon(pAdapter, false))
4139 halStatus = eHAL_STATUS_FAILURE;
4140 }
4141 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 case eCSR_ROAM_LOSTLINK:
4143 case eCSR_ROAM_DISASSOCIATED:
4144 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4146 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05304147 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4149 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07004150 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4151 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304152 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07004153 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08004154
4155 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
4156 pHddCtx->configuredMcastBcastFilter =
4157 pHddCtx->sus_res_mcastbcast_filter;
4158 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
4159 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304160
Amar Singhald53568e2013-09-26 11:03:45 -07004161 hddLog(VOS_TRACE_LEVEL_INFO,
4162 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4163 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
4164 pHddCtx->configuredMcastBcastFilter);
4165 hddLog(VOS_TRACE_LEVEL_INFO,
4166 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4168 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004169#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304170 /* Call to clear any MC Addr List filter applied after
4171 * successful connection.
4172 */
4173 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004174#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 }
4176 break;
4177 case eCSR_ROAM_IBSS_LEAVE:
4178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4179 "****eCSR_ROAM_IBSS_LEAVE****");
4180 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4181 break;
4182 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4183 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4184 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304185 // To Do - address probable memory leak with WEP encryption upon successful association
4186 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004187 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304188 //Clear saved connection information in HDD
4189 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304191 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004192
4193 break;
4194 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004195 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 pRoamInfo, roamId, roamStatus, roamResult );
4197 break;
4198 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07004199 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
4200 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 break;
4202
4203 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
4204 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004205 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004206
4207 case eCSR_ROAM_MIC_ERROR_IND:
4208 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4209 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05304210 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
4211 {
4212 /*
4213 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
4214 * adding the 100 value.
4215 */
4216 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
4217 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4218 "%s : Rssi on Disconnect : %d",
4219 __func__, pAdapter->rssi_on_disconnect);
4220 break;
4221 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004223 {
4224 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4225
4226 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004227 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304228 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304229 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004230 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004231 /* Send DTIM period to the FW; only if the wlan is already
4232 in suspend. This is the case with roaming (reassoc),
4233 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
4234 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
4235 before the ENTER_BMPS_REQ ensures Listen Interval is
4236 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004237 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004238
4239 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004240 if due to unexpected scenario, if we are in BMPS,
4241 then trigger Exit and Enter BMPS to take DTIM period
4242 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004243 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
4244 {
4245 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
4246
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004247 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4248 iw_full_power_cbfn, pAdapter,
4249 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004250 }
4251 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304252
4253 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304254 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
4255 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304256 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304257 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304258 {
4259 hddLog( LOG1, FL("Device in full power."
4260 "Stop and start traffic timer for roaming"));
4261 pmcStopTrafficTimer(pHddCtx->hHal);
4262 if (pmcStartTrafficTimer(pHddCtx->hHal,
4263 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
4264 {
4265 hddLog(LOGP, FL("Cannot start traffic timer"));
4266 }
4267 }
4268
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004269 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304270 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304271 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304272 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 break;
4275#ifdef WLAN_FEATURE_VOWIFI_11R
4276 case eCSR_ROAM_FT_RESPONSE:
4277 hdd_SendFTEvent(pAdapter);
4278 break;
4279#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004280#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004281 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004282 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07004283 {
4284 /* Notify the supplicant of a new candidate */
4285 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
4286 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004287 break;
4288#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004289
Yue Maef608272013-04-08 23:09:17 -07004290#ifdef FEATURE_WLAN_LFR_METRICS
4291 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4292 /* This event is to notify pre-auth initiation */
4293 if (VOS_STATUS_SUCCESS !=
4294 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
4295 {
4296 halStatus = eHAL_STATUS_FAILURE;
4297 }
4298 break;
4299 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4300 /* This event will notify pre-auth completion in case of success */
4301 if (VOS_STATUS_SUCCESS !=
4302 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4303 pRoamInfo, 1))
4304 {
4305 halStatus = eHAL_STATUS_FAILURE;
4306 }
4307 break;
4308 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4309 /* This event will notify pre-auth completion in case of failure. */
4310 if (VOS_STATUS_SUCCESS !=
4311 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4312 pRoamInfo, 0))
4313 {
4314 halStatus = eHAL_STATUS_FAILURE;
4315 }
4316 break;
4317 case eCSR_ROAM_HANDOVER_SUCCESS:
4318 /* This event is to notify handover success.
4319 It will be only invoked on success */
4320 if (VOS_STATUS_SUCCESS !=
4321 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
4322 {
4323 halStatus = eHAL_STATUS_FAILURE;
4324 }
4325 break;
4326#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 case eCSR_ROAM_REMAIN_CHAN_READY:
4328 hdd_remainChanReadyHandler( pAdapter );
4329 break;
4330 case eCSR_ROAM_SEND_ACTION_CNF:
4331 hdd_sendActionCnf( pAdapter,
4332 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
4333 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004334#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08004335 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004336 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08004337 roamId, roamStatus, roamResult );
4338 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004339 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4340 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
4341 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004342#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004343#ifdef WLAN_FEATURE_11W
4344 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4345 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
4346 pRoamInfo->pbFrames,
4347 pRoamInfo->frameType);
4348 break;
4349#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004350#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004351 case eCSR_ROAM_TSM_IE_IND:
4352 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
4353 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
4354 break;
4355
4356 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4357 {
4358 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
4359 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
4360 {
4361 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
4362 }
4363 break;
4364 }
4365
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004366 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004367 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004368 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004369 break;
4370 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004371
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004372 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004373 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004374 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004375 break;
4376 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004377#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05304378 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
4379 {
4380 pAdapter->maxRateFlags = roamResult;
4381 break;
4382 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304383 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4384 if (pRoamInfo && pRoamInfo->pBssDesc) {
4385 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4386 pRoamInfo->pBssDesc);
4387 if (bss_status)
4388 cfg80211_put_bss(
4389#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4390 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4391#endif
4392 bss_status);
4393 else
4394 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
4395 }
Abhinav Kumar118efd02019-08-07 16:41:07 +05304396
4397 case eCSR_ROAM_SAE_COMPUTE:
4398 if (pRoamInfo)
4399 wlan_hdd_sae_callback(pAdapter, pRoamInfo);
4400 break;
4401
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304402 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4403 {
4404 hdd_adapter_t *pHostapdAdapter = NULL;
4405 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4406 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4407
4408 if (!pHddCtx || !pHddStaCtx) {
4409 hddLog(LOG1, FL("Invalid pHddCtx or pHddStaCtx"));
4410 break;
4411 }
4412
4413 hddLog(LOG1, FL("eCSR_ROAM_STA_CHANNEL_SWITCH: new channel %hu"),
4414 pRoamInfo->chan_info.chan_id);
4415
4416 pHddStaCtx->conn_info.operationChannel =
4417 pRoamInfo->chan_info.chan_id;
4418
4419 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
4420 if (pHostapdAdapter &&
4421 (test_bit(SOFTAP_BSS_STARTED,
4422 &pHostapdAdapter->event_flags)))
4423 {
4424 /* Restart SAP if its operating channel is different
4425 * from AP channel.
4426 */
4427 hddLog(VOS_TRACE_LEVEL_INFO,"SAP chan %d, STA chan %d, force_scc_with_ecsa %d",
4428 pHostapdAdapter->sessionCtx.ap.operatingChannel,
4429 pRoamInfo->chan_info.chan_id,
4430 pHddCtx->cfg_ini->force_scc_with_ecsa);
4431 if ((pHddCtx->cfg_ini->force_scc_with_ecsa ) &&
4432 (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
4433 pRoamInfo->chan_info.chan_id))
4434 {
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05304435 schedule_delayed_work(&pHddCtx->ecsa_chan_change_work, 0);
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304436 }
4437 else
4438 hddLog(LOG1, FL("SAP restart not required"));
4439 } else
4440 hddLog(LOG1, FL("SAP not active, nothing to do"));
4441 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304442 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05304443 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 break;
4445 }
4446 return( halStatus );
4447}
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304448
4449#ifdef WLAN_FEATURE_SAE
4450/**
4451 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
4452 * @auth_suite: auth suite
4453 * @auth_type: pointer to eCsrAuthType
4454 *
4455 * Return: None
4456 */
4457static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4458 eCsrAuthType *auth_type)
4459{
4460 if (!memcmp(auth_suite, ccp_rsn_oui_80, 4))
4461 *auth_type = eCSR_AUTH_TYPE_SAE;
4462}
4463#else
4464static inline
4465void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4466 eCsrAuthType *auth_type)
4467{
4468}
4469#endif
4470
Shailender Karmuchia734f332013-04-19 14:02:48 -07004471eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004472{
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304473 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004474 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004475 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 {
4477 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004478 } else
4479 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 {
4481 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004482 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004483#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004484 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 {
4486 // Check for 11r FT Authentication with PSK
4487 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004488 } else
4489 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 {
4491 // Check for 11R FT Authentication with 802.1X
4492 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004493 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004494#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004495#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004496 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 {
4498 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4499 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004500#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07004501#ifdef WLAN_FEATURE_11W
4502 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
4503 {
4504 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4505 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304506 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
4507 {
4508 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4509 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004510#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304511 if (!memcmp(auth_suite, ccp_rsn_oui_18, 4))
4512 {
4513 auth_type = eCSR_AUTH_TYPE_OWE;
4514 } else
4515
Shailender Karmuchia734f332013-04-19 14:02:48 -07004516 {
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304517 /* If auth suite is of SAE, auth_type will be
4518 * overwritten in hdd_translate_sae_rsn_to_csr_auth
4519 */
4520 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
4521 }
4522
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304523 hddLog(LOG1, FL("auth_type : %d"), auth_type);
4524
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004526}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004527
Shailender Karmuchia734f332013-04-19 14:02:48 -07004528eCsrAuthType
4529hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004530{
4531 eCsrAuthType auth_type;
4532 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004533 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 {
4535 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004536 } else
4537 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 {
4539 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004540 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004541#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004542 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 {
4544 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004545 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004546#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004547 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4549 }
4550 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4551 return auth_type;
4552}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004553
Shailender Karmuchia734f332013-04-19 14:02:48 -07004554eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004555hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004556{
4557 eCsrEncryptionType cipher_type;
4558 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004559 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 {
4561 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004562 }
4563 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 {
4565 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004566 }
4567 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 {
4569 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004570 }
4571 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 {
4573 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004574 }
4575 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
4576 {
4577 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4578 }
4579 else
4580 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4582 }
4583 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4584 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004585}
Jeff Johnson295189b2012-06-20 16:38:30 -07004586/* To find if the MAC address is NULL */
4587static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
4588{
4589 int i;
4590 for (i = 0; i < length; i++)
4591 {
4592 if (0x00 != (macAddr[i]))
4593 {
4594 return FALSE;
4595 }
4596 }
4597 return TRUE;
4598} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08004599
Shailender Karmuchia734f332013-04-19 14:02:48 -07004600eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004601hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004602{
4603 eCsrEncryptionType cipher_type;
4604 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004605 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 {
4607 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004608 } else
4609 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 {
4611 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004612 } else
4613 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004614 {
4615 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004616 } else
4617 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 {
4619 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004620 } else
4621 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004623 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4624 } else
4625 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4627 }
4628 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4629 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004630}
Jeff Johnson295189b2012-06-20 16:38:30 -07004631
Shailender Karmuchia734f332013-04-19 14:02:48 -07004632static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
4633 struct ether_addr *pBssid,
4634 eCsrEncryptionType *pEncryptType,
4635 eCsrEncryptionType *mcEncryptType,
4636 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004637#ifdef WLAN_FEATURE_11W
4638 u_int8_t *pMfpRequired,
4639 u_int8_t *pMfpCapable,
4640#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004641 u_int16_t gen_ie_len,
4642 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07004643{
4644 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004645 eHalStatus result;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304646 tDot11fIERSN dot11RSNIE = {0};
4647 tDot11fIEWPA dot11WPAIE = {0};
Shailender Karmuchia734f332013-04-19 14:02:48 -07004648 tANI_U32 i;
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304649 tANI_U32 status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004650 tANI_U8 *pRsnIe;
4651 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07004653 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004654
4655 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
4656 flag to 0 */
4657 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
4658 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
gaurank kathpaliab654f702020-01-03 15:07:17 +05304659 memset( PMKIDCache, 0 , sizeof(tPmkidCacheInfo) * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004660
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07004662 if ( gen_ie[0] == DOT11F_EID_RSN)
4663 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07004665 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07004666 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
4667 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304668 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
4669 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 return -EINVAL;
4671 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004672 // Skip past the EID byte and length byte
4673 pRsnIe = gen_ie + 2;
4674 RSNIeLen = gen_ie_len - 2;
4675 // Unpack the RSN IE
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304676 status = sme_unpack_rsn_ie(halHandle,
4677 pRsnIe,
4678 RSNIeLen,
4679 &dot11RSNIE);
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304680 if (DOT11F_FAILED(status))
4681 {
4682 hddLog(LOGE,
4683 FL("Parse failure in hdd_ProcessGENIE (0x%08x)"),
4684 status);
4685 return -EINVAL;
4686 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304687 hddLog(LOG1, FL("%s: gp_cipher_suite_present: %d"),
4688 __func__, dot11RSNIE.gp_cipher_suite_present);
4689
Shailender Karmuchia734f332013-04-19 14:02:48 -07004690 // Copy out the encryption and authentication types
4691 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004692 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004693 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304694 __func__, dot11RSNIE.akm_suite_cnt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004695 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 but probably I suspect we can do something different*/
4697 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07004698 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304699 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004700 //dot11RSNIE.pwise_cipher_suite_count
4701 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
4702 //dot11RSNIE.gp_cipher_suite_count
4703 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07004704#ifdef WLAN_FEATURE_11W
4705 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
4706 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
4707#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07004709 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004711 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304713 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 break;
4715 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004716 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304718 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 break;
4720 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004721 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 // For right now, I assume setASSOCIATE() has passed in the bssid.
4723 vos_mem_copy(PMKIDCache[i].BSSID,
4724 pBssid, ETHER_ADDR_LEN);
4725 vos_mem_copy(PMKIDCache[i].PMKID,
4726 dot11RSNIE.pmkid[i],
4727 CSR_RSN_PMKID_SIZE);
4728 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004729
4730 if (updatePMKCache)
4731 {
4732 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004733 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004734 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07004735 // Finally set the PMKSA ID Cache in CSR
4736 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
4737 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304738 dot11RSNIE.pmkid_count,
4739 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07004740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 }
4742 else if (gen_ie[0] == DOT11F_EID_WPA)
4743 {
4744 // Validity checks
4745 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
4746 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
4747 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304748 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
4749 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 return -EINVAL;
4751 }
4752 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07004753 pRsnIe = gen_ie + 2 + 4;
4754 RSNIeLen = gen_ie_len - (2 + 4);
4755 // Unpack the WPA IE
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304756 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304757 pRsnIe, RSNIeLen, &dot11WPAIE);
4758 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304759 {
4760 hddLog(LOGE,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304761 FL("Invalid RSN IE: parse status %d"), status);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304762 return -EINVAL;
4763 }
4764
Jeff Johnson295189b2012-06-20 16:38:30 -07004765 // Copy out the encryption and authentication types
4766 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004767 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004769 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07004770 //dot11WPAIE.auth_suite_count
4771 // Just translate the FIRST one
4772 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
4773 //dot11WPAIE.unicast_cipher_count
4774 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
4775 //dot11WPAIE.unicast_cipher_count
4776 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
4777 }
4778 else
4779 {
4780 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004781 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 }
4783 return 0;
4784}
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304785
4786/**
4787 * hdd_set_def_rsne_override() - set default encryption type and auth type
4788 * in profile.
4789 * @roam_profile: pointer to adapter
4790 * @auth_type: pointer to auth type
4791 *
4792 * Set default value of encryption type and auth type in profile to
4793 * search the AP using filter, as in force_rsne_override the RSNIE can be
4794 * currupt and we might not get the proper encryption type and auth type
4795 * while parsing the RSNIE.
4796 *
4797 * Return: void
4798 */
4799static void hdd_set_def_rsne_override(
4800 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
4801{
4802 hddLog( LOG1, FL("Set def values in roam profile"));
4803 roam_profile->MFPCapable = roam_profile->MFPEnabled;
4804 roam_profile->EncryptionType.numEntries = 2;
4805 roam_profile->mcEncryptionType.numEntries = 2;
4806 /* Use the cipher type in the RSN IE */
4807 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
4808 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
4809 roam_profile->mcEncryptionType.encryptionType[0] =
4810 eCSR_ENCRYPT_TYPE_AES;
4811 roam_profile->mcEncryptionType.encryptionType[1] =
4812 eCSR_ENCRYPT_TYPE_TKIP;
4813 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
4814}
4815
Jeff Johnson295189b2012-06-20 16:38:30 -07004816int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4817{
4818 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4819 v_U32_t status = 0;
4820 eCsrEncryptionType RSNEncryptType;
4821 eCsrEncryptionType mcRSNEncryptType;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304822 hdd_context_t *hdd_ctx;
Chet Lanctot186b5732013-03-18 10:26:30 -07004823#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304824 u_int8_t RSNMfpRequired = 0;
4825 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004826#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 struct ether_addr bSsid; // MAC address of assoc peer
4828 // MAC address of assoc peer
4829 // But, this routine is only called when we are NOT associated.
4830 vos_mem_copy(bSsid.ether_addr_octet,
4831 pWextState->roamProfile.BSSIDs.bssid,
4832 sizeof(bSsid.ether_addr_octet));
4833 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
4834 {
4835 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07004836 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 else
4838 {
4839 return 0;
4840 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 // The actual processing may eventually be more extensive than this.
4843 // Right now, just consume any PMKIDs that are sent in by the app.
4844 status = hdd_ProcessGENIE(pAdapter,
4845 &bSsid, // MAC address of assoc peer
4846 &RSNEncryptType,
4847 &mcRSNEncryptType,
4848 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004849#ifdef WLAN_FEATURE_11W
4850 &RSNMfpRequired,
4851 &RSNMfpCapable,
4852#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 pWextState->WPARSNIE[1]+2,
4854 pWextState->WPARSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304855
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 if (status == 0)
4857 {
4858 // Now copy over all the security attributes you have parsed out
4859 pWextState->roamProfile.EncryptionType.numEntries = 1;
4860 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004861
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
4863 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07004864
Shailender Karmuchi642e9812013-05-30 14:34:49 -07004865 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
4866 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4867 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
4868 {
4869 /*For wpa none supplicant sends the WPA IE with unicast cipher as
4870 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
4871 either AES/TKIP based on group cipher configuration
4872 mentioned in the wpa_supplicant.conf.*/
4873
4874 /*Set the unicast cipher same as multicast cipher*/
4875 pWextState->roamProfile.EncryptionType.encryptionType[0]
4876 = mcRSNEncryptType;
4877 }
4878
Chet Lanctot186b5732013-03-18 10:26:30 -07004879#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304880 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4881 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07004882 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4883 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4884#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304885 hddLog( LOG1,
4886 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4887 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304888 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304890
4891 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4892 if (hdd_ctx->force_rsne_override &&
4893 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
4894 hddLog(LOG1,
4895 FL("Test mode enabled set def Auth and enc type. RSN IE passed in connect req:"));
4896 vos_trace_hex_dump(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4897 pWextState->roamProfile.pRSNReqIE,
4898 pWextState->roamProfile.nRSNReqIELength);
4899
4900 pWextState->roamProfile.force_rsne_override = true;
4901 hddLog(LOG1,
4902 FL("MFPEnabled %d"), pWextState->roamProfile.MFPEnabled);
4903 /*
4904 * Reset MFPEnabled if testmode RSNE passed doesnt have MFPR
4905 * or MFPC bit set
4906 */
4907 if (pWextState->roamProfile.MFPEnabled &&
4908 !(pWextState->roamProfile.MFPRequired ||
4909 pWextState->roamProfile.MFPCapable)) {
4910 hddLog( LOG1,FL("Reset MFPEnabled"));
4911 pWextState->roamProfile.MFPEnabled = 0;
4912 }
4913
4914 /* If parsing failed set the def value for the roam profile */
4915 if (status)
4916 hdd_set_def_rsne_override(&pWextState->roamProfile,
4917 RSNAuthType);
4918 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304919 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004920}
4921int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4922{
4923 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4924 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
4925 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4926 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004927
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 pRoamProfile->AuthType.numEntries = 1;
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304929 hddLog( LOG1,
Abhinav Kumar2184e162019-09-16 15:02:24 +05304930 "%s: authType = %d RSNAuthType %d wpa_versions %d key_mgmt : 0x%x",
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304931 __func__, pHddStaCtx->conn_info.authType, RSNAuthType,
Abhinav Kumar2184e162019-09-16 15:02:24 +05304932 pWextState->wpaVersion, pWextState->authKeyMgmt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004933
Jeff Johnson295189b2012-06-20 16:38:30 -07004934 switch( pHddStaCtx->conn_info.authType)
4935 {
4936 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumar62801ba2018-09-19 12:14:14 +05304937 case eCSR_AUTH_TYPE_AUTOSWITCH:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004938#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 case eCSR_AUTH_TYPE_CCKM_WPA:
4940 case eCSR_AUTH_TYPE_CCKM_RSN:
4941#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004942 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4943
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004945 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004947
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004948#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004949 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4950 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4951 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004952 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004953 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4954 } else
4955 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004956 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004957 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 } else
4959#endif
4960 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4961 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004962 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4963 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4965 == IW_AUTH_KEY_MGMT_PSK) {
4966 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004967 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004970 }
4971 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004972#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004973 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4974 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4975 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004976 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004977 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004979 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004980 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004981 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004982 } else
4983#endif
4984
4985#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004986 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4987 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004989 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004990 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004991 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4993 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004994 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 } else
4996#endif
4997
Chet Lanctot186b5732013-03-18 10:26:30 -07004998#ifdef WLAN_FEATURE_11W
4999 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5000 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5001 } else
Abhishek Singhae408032014-09-25 17:22:04 +05305002 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5003 pRoamProfile->AuthType.authType[0] =
5004 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5005 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07005006#endif
Abhinav Kumara4282182019-09-13 11:25:59 +05305007 if ((RSNAuthType == eCSR_AUTH_TYPE_SAE) &&
5008 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5009 == IW_AUTH_KEY_MGMT_802_1X)) {
5010 /* SAE case */
5011 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5012 } else
Abhinav Kumar487e49e2019-07-22 14:46:18 +05305013 if ((RSNAuthType == eCSR_AUTH_TYPE_OWE) &&
5014 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5015 == IW_AUTH_KEY_MGMT_802_1X)) {
5016 /* OWE case */
5017 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OWE;
5018 } else
Abhinav Kumar2184e162019-09-16 15:02:24 +05305019 if (RSNAuthType == eCSR_AUTH_TYPE_SAE) {
5020 /* SAE with open authentication case */
5021 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5022 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07005023 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07005024 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005025 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
5026 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5028 == IW_AUTH_KEY_MGMT_PSK) {
5029 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Abhinav Kumar487e49e2019-07-22 14:46:18 +05305030 } else
5031 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005035 break;
5036
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005038
5039 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005040 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05305041 case eCSR_AUTH_TYPE_SAE:
5042 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5043 break;
5044
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005046
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005047#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08005048 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005049#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5051 break;
5052 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005053
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005055 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005056
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 EXIT();
5058 return 0;
5059}
5060
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05305061/**
5062 * hdd_rx_fwd_eapol() - forward cached eapol frames
5063 * @vosContext : pointer to vos global context
5064 * @pVosPacket: pointer to vos packet
5065 *
5066 * Return: None
5067 *
5068 */
5069void hdd_assoc_registerFwdEapolCB(void *pContext)
5070{
5071 WLANTL_RegisterFwdEapol(pContext, hdd_rx_fwd_eapol);
5072}
5073
Jeff Johnson295189b2012-06-20 16:38:30 -07005074/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005075
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305076 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07005078 to the CSR roam profile.
5079
Jeff Johnson295189b2012-06-20 16:38:30 -07005080 \param - dev - Pointer to the net device.
5081 - info - Pointer to the iw_request_info.
5082 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005083 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005085
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 --------------------------------------------------------------------------*/
5087
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305088int __iw_set_essid(struct net_device *dev,
5089 struct iw_request_info *info,
5090 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005091{
5092 v_U32_t status = 0;
5093 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305094 hdd_adapter_t *pAdapter;
5095 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 v_U32_t roamId;
5097 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305099 tHalHandle hHal;
5100 hdd_station_ctx_t *pHddStaCtx;
5101 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005102
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305104 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5105 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005106 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05305107 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305108 "%s: Adapter is NULL",__func__);
5109 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 }
5111
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305112 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5113 ret = wlan_hdd_validate_context(pHddCtx);
5114 if (0 != ret)
5115 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305116 return ret;
5117 }
5118
5119 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5120 if (NULL == hHal)
5121 {
5122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5123 "%s: Hal Context is NULL",__func__);
5124 return -EINVAL;
5125 }
5126 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5127 if (NULL == pHddStaCtx)
5128 {
5129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5130 "%s: STA Context is NULL",__func__);
5131 return -EINVAL;
5132 }
5133 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5134 if (NULL == pWextState)
5135 {
5136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5137 "%s: pWextState is NULL",__func__);
5138 return -EINVAL;
5139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
5141 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
5142 return -EBUSY;
5143 }
5144 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
5145 return -EINVAL;
5146 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005147
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305148 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
5149 return -EINVAL;
5150
Agrawal Ashishc407f192017-01-23 17:18:35 +05305151 /*Try disconnecting if already in connected state*/
5152 status = wlan_hdd_try_disconnect(pAdapter);
5153 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 {
Agrawal Ashishc407f192017-01-23 17:18:35 +05305155 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
5156 " connection"));
5157 return -EALREADY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 }
5159 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07005160 /** when cfg80211 defined, wpa_supplicant wext driver uses
5161 zero-length, null-string ssid for force disconnection.
5162 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07005163 driver MUST return success */
5164 if ( 0 == wrqu->essid.length ) {
5165 return 0;
5166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005167
5168 status = hdd_wmm_get_uapsd_mask(pAdapter,
5169 &pWextState->roamProfile.uapsd_mask);
5170 if (VOS_STATUS_SUCCESS != status)
5171 {
5172 pWextState->roamProfile.uapsd_mask = 0;
5173 }
5174 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005175
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005177
5178 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005179 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
5180 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
5181 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005182
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 //set gen ie
5184 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5185
5186 //set auth
5187 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5188 }
5189#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005190 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 if (pAdapter->wapi_info.nWapiMode)
5192 {
5193 switch (pAdapter->wapi_info.wapiAuthMode)
5194 {
5195 case WAPI_AUTH_MODE_PSK:
5196 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005197 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005198 pRoamProfile->AuthType.numEntries = 1;
5199 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5200 break;
5201 }
5202 case WAPI_AUTH_MODE_CERT:
5203 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005204 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 pRoamProfile->AuthType.numEntries = 1;
5206 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5207 break;
5208 }
5209 } // End of switch
5210 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5211 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5212 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005213 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005214 pRoamProfile->EncryptionType.numEntries = 1;
5215 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5216 pRoamProfile->mcEncryptionType.numEntries = 1;
5217 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5218 }
5219 }
5220#endif /* FEATURE_WLAN_WAPI */
5221 /* if previous genIE is not NULL, update AssocIE */
5222 if (0 != pWextState->genIE.length)
5223 {
5224 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
5225 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
5226 pWextState->genIE.length);
5227 pWextState->assocAddIE.length = pWextState->genIE.length;
5228 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5229 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5230
5231 /* clear previous genIE after use it */
5232 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
5233 }
5234
5235 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
5236 pWextState->roamProfile.bWPSAssociation = FALSE;
5237
5238 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5239 pWextState->roamProfile.nAddIEAssocLength))
5240 pWextState->roamProfile.bWPSAssociation = TRUE;
5241
5242
5243 // Disable auto BMPS entry by PMC until DHCP is done
5244 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
5245
Shailender Karmuchia734f332013-04-19 14:02:48 -07005246 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005247 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005248
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005249 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
5250 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005251 hdd_select_cbmode(pAdapter,
5252 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
5253 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305254 /*
5255 * Change conn_state to connecting before sme_RoamConnect(),
5256 * because sme_RoamConnect() has a direct path to call
5257 * hdd_smeRoamCallback(), which will change the conn_state
5258 * If direct path, conn_state will be accordingly changed
5259 * to NotConnected or Associated by either
5260 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
5261 * in sme_RoamCallback()
5262 * if sme_RomConnect is to be queued,
5263 * Connecting state will remain until it is completed.
5264 *
5265 * If connection state is not changed,
5266 * connection state will remain in eConnectionState_NotConnected state.
5267 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
5268 * if conn state is eConnectionState_NotConnected.
5269 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5270 * informed of connect result indication which is an issue.
5271 */
5272 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5273 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
5274 {
5275 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5276 FL("Set HDD connState to eConnectionState_Connecting"));
5277 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5278 eConnectionState_Connecting);
5279 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005280 status = sme_RoamConnect( hHal,pAdapter->sessionId,
5281 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305282
5283 if ((eHAL_STATUS_SUCCESS != status) &&
5284 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5285 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5286 {
5287 hddLog(VOS_TRACE_LEVEL_ERROR,
5288 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
5289 pAdapter->sessionId, status);
5290 /* change back to NotAssociated */
5291 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5292 eConnectionState_NotConnected);
5293 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005294 pRoamProfile->ChannelInfo.ChannelList = NULL;
5295 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005296
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005297 EXIT();
5298 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005299}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005300
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305301int iw_set_essid(struct net_device *dev,
5302 struct iw_request_info *info,
5303 union iwreq_data *wrqu, char *extra)
5304{
5305 int ret;
5306
5307 vos_ssr_protect(__func__);
5308 ret = __iw_set_essid(dev, info, wrqu, extra);
5309 vos_ssr_unprotect(__func__);
5310
5311 return ret;
5312}
5313
Jeff Johnson295189b2012-06-20 16:38:30 -07005314/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005315
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305316 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005318
Jeff Johnson295189b2012-06-20 16:38:30 -07005319 \param - dev - Pointer to the net device.
5320 - info - Pointer to the iw_request_info.
5321 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005322 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005323 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005324
Jeff Johnson295189b2012-06-20 16:38:30 -07005325 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305326int __iw_get_essid(struct net_device *dev,
5327 struct iw_request_info *info,
5328 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005329{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305330 hdd_adapter_t *pAdapter;
5331 hdd_context_t *pHddCtx;
5332 hdd_wext_state_t *wextBuf;
5333 hdd_station_ctx_t *pHddStaCtx;
5334 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305335
Jeff Johnson295189b2012-06-20 16:38:30 -07005336 ENTER();
5337
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305338 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5339 if (NULL == pAdapter)
5340 {
5341 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5342 "%s: Adapter is NULL",__func__);
5343 return -EINVAL;
5344 }
5345
5346 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5347 ret = wlan_hdd_validate_context(pHddCtx);
5348 if (0 != ret)
5349 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305350 return ret;
5351 }
5352
5353 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5354 if (NULL == pHddStaCtx)
5355 {
5356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5357 "%s: STA Context is NULL",__func__);
5358 return -EINVAL;
5359 }
5360
5361 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5362 if (NULL == wextBuf)
5363 {
5364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5365 "%s: wextBuf is NULL",__func__);
5366 return -EINVAL;
5367 }
5368
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5370 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5371 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
5372 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
5373 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
5374 {
5375 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5376 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
5377 dwrq->flags = 1;
5378 } else {
5379 memset(extra, 0, dwrq->length);
5380 dwrq->length = 0;
5381 dwrq->flags = 0;
5382 }
5383 EXIT();
5384 return 0;
5385}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305386
5387int iw_get_essid(struct net_device *dev,
5388 struct iw_request_info *info,
5389 struct iw_point *dwrq, char *extra)
5390{
5391 int ret;
5392
5393 vos_ssr_protect(__func__);
5394 ret = __iw_get_essid(dev, info, dwrq, extra);
5395 vos_ssr_unprotect(__func__);
5396
5397 return ret;
5398}
Jeff Johnson295189b2012-06-20 16:38:30 -07005399/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005400
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305401 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005402 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005403
Jeff Johnson295189b2012-06-20 16:38:30 -07005404 \param - dev - Pointer to the net device.
5405 - info - Pointer to the iw_request_info.
5406 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005407 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005409
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305411int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
5412 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005413{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305414 hdd_adapter_t *pAdapter;
5415 hdd_context_t *pHddCtx;
5416 hdd_wext_state_t *pWextState;
5417 hdd_station_ctx_t *pHddStaCtx;
5418 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005419 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305421 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005422
Jeff Johnson295189b2012-06-20 16:38:30 -07005423 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005424
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305425 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5426 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005427 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5429 "%s: Adapter is NULL",__func__);
5430 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005431 }
5432
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305433 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5434 ret = wlan_hdd_validate_context(pHddCtx);
5435 if (0 != ret)
5436 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305437 return ret;
5438 }
5439
5440 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5441 if (NULL == pHddStaCtx)
5442 {
5443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5444 "%s: STA Context is NULL",__func__);
5445 return -EINVAL;
5446 }
5447
5448 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5449 if (NULL == pWextState)
5450 {
5451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5452 "%s: pWextState is NULL",__func__);
5453 return -EINVAL;
5454 }
5455
5456 pRoamProfile = &pWextState->roamProfile;
5457
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 switch(wrqu->param.flags & IW_AUTH_INDEX)
5459 {
5460 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005461
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005463
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005465
Jeff Johnson295189b2012-06-20 16:38:30 -07005466 case IW_AUTH_CIPHER_PAIRWISE:
5467 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005468 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5472 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005474 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5475 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005476 }
5477
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005479
5480 if( (IW_AUTH_KEY_MGMT_802_1X
5481 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
5483 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005484 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 else
5486 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005487 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005490
5491 if( ( IW_AUTH_KEY_MGMT_802_1X
5492 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5494 /*Dynamic WEP key*/
5495 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5496 else
5497 /*Static WEP key*/
5498 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005499
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 }
5501 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005502
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005504 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005505 return -EINVAL;
5506 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005507
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 pRoamProfile->EncryptionType.numEntries = 1;
5509 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 break;
5512 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005513 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5515 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5516 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005517
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5519 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5520 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005521
5522 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5524 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005525
Jeff Johnson295189b2012-06-20 16:38:30 -07005526 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005527
5528 if( ( IW_AUTH_KEY_MGMT_802_1X
5529 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5530 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5531
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005533
5534 else
5535 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005537
5538 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
5539 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005541 if( ( IW_AUTH_KEY_MGMT_802_1X
5542 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5544 {
5545 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5546 }
5547 else
5548 {
5549 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5550 }
5551 }
5552 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005553
Jeff Johnson295189b2012-06-20 16:38:30 -07005554 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005555 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 return -EINVAL;
5557 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005558
Jeff Johnson295189b2012-06-20 16:38:30 -07005559 pRoamProfile->mcEncryptionType.numEntries = 1;
5560 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
5561 }
5562 break;
5563
5564 case IW_AUTH_80211_AUTH_ALG:
5565 {
5566 /*Save the auth algo here and set auth type to SME Roam profile
5567 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005568 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005570
Jeff Johnson295189b2012-06-20 16:38:30 -07005571 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5572 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5573
5574 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
5575 /*Not supported*/
5576 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5577 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5578 }
5579 break;
5580
5581 case IW_AUTH_KEY_MGMT:
5582 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005583#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005584#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5585 /*Check for CCKM AKM type */
5586 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005587 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
5588 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005589 /* Set the CCKM bit in authKeyMgmt */
5590 /* Right now, this breaks all ref to authKeyMgmt because our
5591 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 */
5593 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5594 /*Set the key management to 802.1X*/
5595 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005596 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5598 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
5599 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5600 /*Save the key management*/
5601 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5602 //pWextState->authKeyMgmt = wrqu->param.value;
5603 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5604 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5605 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5606 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
5607 /*Save the key management anyway*/
5608 pWextState->authKeyMgmt = wrqu->param.value;
5609 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
5610 /*Save the key management*/
5611 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5612 //pWextState->authKeyMgmt = wrqu->param.value;
5613 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5614 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5615 }
5616#else
5617 /*Save the key management*/
5618 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005619#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005620 }
5621 break;
5622
5623 case IW_AUTH_TKIP_COUNTERMEASURES:
5624 {
5625 if(wrqu->param.value) {
5626 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5627 "Counter Measure started %d", wrqu->param.value);
5628 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
5629 }
5630 else {
5631 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5632 "Counter Measure stopped=%d", wrqu->param.value);
5633 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
5634 }
5635 }
5636 break;
5637 case IW_AUTH_DROP_UNENCRYPTED:
5638 case IW_AUTH_WPA_ENABLED:
5639 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5640 case IW_AUTH_ROAMING_CONTROL:
5641 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005642
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005644
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005645 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 wrqu->param.flags & IW_AUTH_INDEX);
5647 break;
5648 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005649
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 EXIT();
5651 return 0;
5652}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305653
5654int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5655 union iwreq_data *wrqu, char *extra)
5656{
5657 int ret;
5658
5659 vos_ssr_protect(__func__);
5660 ret = __iw_set_auth(dev, info, wrqu, extra);
5661 vos_ssr_unprotect(__func__);
5662
5663 return ret;
5664}
5665
Jeff Johnson295189b2012-06-20 16:38:30 -07005666/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005667
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305668 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005669 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005670
Jeff Johnson295189b2012-06-20 16:38:30 -07005671 \param - dev - Pointer to the net device.
5672 - info - Pointer to the iw_request_info.
5673 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005674 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005675 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005676
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305678int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5679 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005680{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305681 hdd_adapter_t* pAdapter;
5682 hdd_wext_state_t *pWextState;
5683 tCsrRoamProfile *pRoamProfile;
5684 hdd_context_t *pHddCtx;
5685 int ret = 0;
5686
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005688
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305689 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5690 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005691 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5693 "%s: Adapter is NULL",__func__);
5694 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005695 }
5696
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305697 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5698 ret = wlan_hdd_validate_context(pHddCtx);
5699 if (0 != ret)
5700 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305701 return ret;
5702 }
5703
5704 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5705 if (NULL == pWextState)
5706 {
5707 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5708 "%s: pWextState is NULL",__func__);
5709 return -EINVAL;
5710 }
5711 pRoamProfile = &pWextState->roamProfile;
5712
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 switch(pRoamProfile->negotiatedAuthType)
5714 {
5715 case eCSR_AUTH_TYPE_WPA_NONE:
5716 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5717 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5718 break;
5719 case eCSR_AUTH_TYPE_WPA:
5720 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5721 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5722 break;
5723#ifdef WLAN_FEATURE_VOWIFI_11R
5724 case eCSR_AUTH_TYPE_FT_RSN:
5725#endif
5726 case eCSR_AUTH_TYPE_RSN:
5727 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5728 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5729 break;
5730 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5731 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5732 break;
5733 case eCSR_AUTH_TYPE_SHARED_KEY:
5734 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5735 break;
5736 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005737 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5739 break;
5740 case eCSR_AUTH_TYPE_AUTOSWITCH:
5741 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5742 break;
5743 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305744 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005745 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5746 return -EIO;
5747#ifdef WLAN_FEATURE_VOWIFI_11R
5748 case eCSR_AUTH_TYPE_FT_RSN_PSK:
5749#endif
5750 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07005751#ifdef WLAN_FEATURE_11W
5752 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05305753 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07005754#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05305755 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5757 return -EIO;
5758 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305759 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5761 return -EIO;
5762 }
5763 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
5764 {
5765 switch(pRoamProfile->negotiatedUCEncryptionType)
5766 {
5767 case eCSR_ENCRYPT_TYPE_NONE:
5768 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5769 break;
5770 case eCSR_ENCRYPT_TYPE_WEP40:
5771 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5772 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5773 break;
5774 case eCSR_ENCRYPT_TYPE_TKIP:
5775 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5776 break;
5777 case eCSR_ENCRYPT_TYPE_WEP104:
5778 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5779 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5780 break;
5781 case eCSR_ENCRYPT_TYPE_AES:
5782 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5783 break;
5784 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305785 hddLog(LOG1, "%s called with unknown auth type %d ",
5786 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 return -EIO;
5788 }
5789 }
5790
Shailender Karmuchia734f332013-04-19 14:02:48 -07005791 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 {
5793 switch(pRoamProfile->negotiatedMCEncryptionType)
5794 {
5795 case eCSR_ENCRYPT_TYPE_NONE:
5796 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5797 break;
5798 case eCSR_ENCRYPT_TYPE_WEP40:
5799 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5800 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5801 break;
5802 case eCSR_ENCRYPT_TYPE_TKIP:
5803 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5804 break;
5805 case eCSR_ENCRYPT_TYPE_WEP104:
5806 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5807 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5808 break;
5809 case eCSR_ENCRYPT_TYPE_AES:
5810 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5811 break;
5812 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305813 hddLog(LOG1, "%s called with unknown auth type %d ",
5814 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005815 return -EIO;
5816 }
5817 }
5818
5819 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005820 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 EXIT();
5822 return 0;
5823}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305824
5825int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5826 union iwreq_data *wrqu,char *extra)
5827{
5828 int ret;
5829
5830 vos_ssr_protect(__func__);
5831 ret = __iw_get_auth(dev, info, wrqu, extra);
5832 vos_ssr_unprotect(__func__);
5833
5834 return ret;
5835}
5836
Jeff Johnson295189b2012-06-20 16:38:30 -07005837/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005838
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305839 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07005840 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005842
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 \param - dev - Pointer to the net device.
5844 - info - Pointer to the iw_request_info.
5845 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005846 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005848
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305850int __iw_set_ap_address(struct net_device *dev,
5851 struct iw_request_info *info,
5852 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005853{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305854 hdd_station_ctx_t *pHddStaCtx;
5855 hdd_adapter_t *pAdapter;
5856 hdd_context_t *pHddCtx;
5857 v_U8_t *pMacAddress = NULL;
5858 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305859
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305861
5862 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5863 if (NULL == pAdapter)
5864 {
5865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5866 "%s: Adapter is NULL", __func__);
5867 return -EINVAL;
5868 }
5869 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5870 ret = wlan_hdd_validate_context(pHddCtx);
5871 if (0 != ret)
5872 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305873 return ret;
5874 }
5875 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5876 if (NULL == pHddStaCtx)
5877 {
5878 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5879 "%s: pHddStaCtx is NULL", __func__);
5880 return -EINVAL;
5881 }
5882
Jeff Johnson295189b2012-06-20 16:38:30 -07005883 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08005884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
5885 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07005887
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305888 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 return 0;
5890}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305891
5892int iw_set_ap_address(struct net_device *dev,
5893 struct iw_request_info *info,
5894 union iwreq_data *wrqu, char *extra)
5895{
5896 int ret;
5897
5898 vos_ssr_protect(__func__);
5899 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5900 vos_ssr_unprotect(__func__);
5901
5902 return ret;
5903}
5904
Jeff Johnson295189b2012-06-20 16:38:30 -07005905/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005906
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305907 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 This function returns the BSSID to the wpa_supplicant
5909 \param - dev - Pointer to the net device.
5910 - info - Pointer to the iw_request_info.
5911 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005912 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005914
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305916int __iw_get_ap_address(struct net_device *dev,
5917 struct iw_request_info *info,
5918 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005919{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305920 hdd_station_ctx_t *pHddStaCtx;
5921 hdd_adapter_t *pAdapter;
5922 hdd_context_t *pHddCtx;
5923 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305924
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 ENTER();
5926
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305927 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5928 if (NULL == pAdapter)
5929 {
5930 hddLog(VOS_TRACE_LEVEL_ERROR,
5931 "%s: Adapter is NULL", __func__);
5932 return -EINVAL;
5933 }
5934 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5935 ret = wlan_hdd_validate_context(pHddCtx);
5936 if (0 != ret)
5937 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305938 return ret;
5939 }
5940 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5941 if (NULL == pHddStaCtx)
5942 {
5943 hddLog(VOS_TRACE_LEVEL_ERROR,
5944 "%s: pHddStaCtx is NULL", __func__);
5945 return -EINVAL;
5946 }
5947
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
5949 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
5950 {
Jeff Johnson4416a782013-03-25 14:17:50 -07005951 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 }
5953 else
5954 {
5955 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
5956 }
5957 EXIT();
5958 return 0;
5959}
Jeff Johnsond13512a2012-07-17 11:42:19 -07005960
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305961int iw_get_ap_address(struct net_device *dev,
5962 struct iw_request_info *info,
5963 union iwreq_data *wrqu, char *extra)
5964{
5965 int ret;
5966
5967 vos_ssr_protect(__func__);
5968 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5969 vos_ssr_unprotect(__func__);
5970
5971 return ret;
5972}
5973
Chet Lanctot186b5732013-03-18 10:26:30 -07005974#ifdef WLAN_FEATURE_11W
5975/**---------------------------------------------------------------------------
5976
5977 \brief hdd_indicateUnprotMgmtFrame -
5978 This function forwards the unprotected management frame to the supplicant
5979 \param - pAdapter - Pointer to HDD adapter
5980 - nFrameLength - Length of the unprotected frame being passed
5981 - pbFrames - Pointer to the frame buffer
5982 - frameType - 802.11 frame type
5983 \return - nothing
5984
5985 --------------------------------------------------------------------------*/
5986void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5987 tANI_U32 nFrameLength,
5988 tANI_U8* pbFrames,
5989 tANI_U8 frameType )
5990{
5991 tANI_U8 type = 0;
5992 tANI_U8 subType = 0;
5993
5994 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5995 __func__, frameType, nFrameLength);
5996
5997 /* Sanity Checks */
5998 if (NULL == pAdapter)
5999 {
6000 hddLog( LOGE, FL("pAdapter is NULL"));
6001 return;
6002 }
6003
6004 if (NULL == pAdapter->dev)
6005 {
6006 hddLog( LOGE, FL("pAdapter->dev is NULL"));
6007 return;
6008 }
6009
6010 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6011 {
6012 hddLog( LOGE, FL("pAdapter has invalid magic"));
6013 return;
6014 }
6015
6016 if( !nFrameLength )
6017 {
6018 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
6019 return;
6020 }
6021
6022 if (NULL == pbFrames) {
6023 hddLog( LOGE, FL("pbFrames is NULL"));
6024 return;
6025 }
6026
6027 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
6028 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
6029
6030 /* Get pAdapter from Destination mac address of the frame */
6031 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
6032 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306033#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
6034 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
6035#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006036 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306037#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006038 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
6039 }
6040 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
6041 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306042#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
6043 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
6044#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006045 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306046#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006047 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
6048 }
6049 else
6050 {
6051 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
6052 return;
6053 }
6054}
6055#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006056
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006057#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006058void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
6059 tANI_U8 state,
6060 tANI_U16 measInterval )
6061{
6062 union iwreq_data wrqu;
6063 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006064 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006065
6066 if (NULL == pAdapter)
6067 return;
6068
6069 // create the event
6070 memset(&wrqu, '\0', sizeof(wrqu));
6071 memset(buf, '\0', sizeof(buf));
6072
6073 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
6074 tid, state, measInterval);
6075
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006076 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006077
6078 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006079 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006080 // send the event
6081 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6082}
6083
6084void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
6085{
6086 union iwreq_data wrqu;
6087 char buf[IW_CUSTOM_MAX + 1];
6088 char *pos = buf;
6089 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6090
6091 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6092 return;
6093
6094 // create the event
6095 memset(&wrqu, '\0', sizeof(wrqu));
6096 memset(buf, '\0', sizeof(buf));
6097
6098 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306099 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
6100 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
6101 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
6102 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006103
6104 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
6105 pos += nBytes;
6106 freeBytes -= nBytes;
6107
6108 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
6109 pos += WNI_CFG_BSSID_LEN;
6110 freeBytes -= WNI_CFG_BSSID_LEN;
6111
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006112 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
6113 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006114
6115 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006116 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006117
6118 // send the event
6119 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6120}
6121
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006122void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006123{
6124 union iwreq_data wrqu;
6125 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006126 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006127
6128 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6129 return;
6130
6131 // create the event
6132 memset(&wrqu, '\0', sizeof(wrqu));
6133 memset(buf, '\0', sizeof(buf));
6134
6135 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
6136
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006137 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006138
6139 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006140 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006141
6142 // send the event
6143 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6144}
6145
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006146void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
6147 const tANI_U16 measurementToken,
6148 const tANI_BOOLEAN flag,
6149 const tANI_U8 numBss)
6150{
6151 union iwreq_data wrqu;
6152 char buf[IW_CUSTOM_MAX];
6153 char *pos = buf;
6154 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6155
6156 memset(&wrqu, '\0', sizeof(wrqu));
6157 memset(buf, '\0', sizeof(buf));
6158
6159 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
6160 numBss);
6161
6162 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
6163 flag, numBss);
6164
6165 wrqu.data.pointer = buf;
6166 wrqu.data.length = nBytes;
6167 // send the event
6168 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6169}
6170
6171
6172static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006173 const tCsrRoamInfo *pRoamInfo)
6174{
6175 union iwreq_data wrqu;
6176 char buf[IW_CUSTOM_MAX + 1];
6177 char *pos = buf;
6178 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6179 tANI_U8 i = 0, len = 0;
6180 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
6181 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006182 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
6183 tANI_U8 ieLenByte = 1;
6184 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
6185#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006186
6187 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6188 return;
6189
6190 /* Custom event can pass maximum of 256 bytes of data,
6191 based on the IE len we need to identify how many BSS info can
6192 be filled in to custom event data */
6193 /*
6194 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
6195 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
6196 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
6197 */
6198
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006199 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006200 {
6201 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
6202 /* If the measurement is none and no scan results found,
6203 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006204 hdd_indicateEseBcnReportNoResults(pAdapter,
6205 pRoamInfo->pEseBcnReportRsp->measurementToken,
6206 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006207 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006208 }
6209 else
6210 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006211 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006212 {
6213 memset(&wrqu, '\0', sizeof(wrqu));
6214 memset(buf, '\0', sizeof(buf));
6215 tot_bcn_ieLen = 0;
6216 sendBss = 0;
6217 pos = buf;
6218 freeBytes = IW_CUSTOM_MAX;
6219
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006220 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006221 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006222 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
6223 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006224 {
6225 break;
6226 }
6227 tot_bcn_ieLen += len;
6228 sendBss++;
6229 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
6230 "IeLength(%d) Length of Ie(%d) totLen(%d)",
6231 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006232 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006233 tot_bcn_ieLen);
6234 }
6235
6236 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
6237 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006238 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6239 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006240
6241 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006242 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6243 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006244 pos += nBytes;
6245 freeBytes -= nBytes;
6246
6247 /* Copy total Beacon report data length */
6248 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
6249 pos += sizeof(tot_bcn_ieLen);
6250 freeBytes -= sizeof(tot_bcn_ieLen);
6251
6252 for (i = 0; i < sendBss; i++)
6253 {
6254 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306255 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
6256 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006257 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006258 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
6259 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
6260 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
6261 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
6262 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
6263 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
6264 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
6265 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
6266 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
6267 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
6268 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
6269 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
6270 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
6271 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
6272 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
6273 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006274
6275 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006276 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
6277 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006278 pos += len;
6279 freeBytes -= len;
6280
6281 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006282 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006283 vos_mem_copy(pos, (char*)&len, sizeof(len));
6284 pos += sizeof(len);
6285 freeBytes -= sizeof(len);
6286
6287 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006288 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006289 pos += len;
6290 freeBytes -= len;
6291 }
6292
6293 wrqu.data.pointer = buf;
6294 wrqu.data.length = strlen(buf);
6295
6296 // send the event
6297 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6298 lastSent += sendBss;
6299 }
6300 }
6301}
6302
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006303#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006304
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306305hdd_adapter_t *hdd_get_sta_connection_in_progress(hdd_context_t *hdd_ctx)
6306{
6307 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
6308 hdd_adapter_t *adapter = NULL;
6309 VOS_STATUS status;
6310 hdd_station_ctx_t *hdd_sta_ctx;
6311
6312 if (!hdd_ctx) {
6313 hddLog(LOGE, FL("HDD context is NULL"));
6314 return NULL;
6315 }
6316
6317 status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
6318 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
6319 adapter = adapter_node->pAdapter;
6320 if (!adapter)
6321 goto end;
6322
6323 if ((WLAN_HDD_INFRA_STATION == adapter->device_mode) ||
6324 (WLAN_HDD_P2P_CLIENT == adapter->device_mode) ||
6325 (WLAN_HDD_P2P_DEVICE == adapter->device_mode)) {
6326 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6327 if (eConnectionState_Connecting ==
6328 hdd_sta_ctx->conn_info.connState) {
6329 hddLog(LOG1, FL("session_id %d: Connection is in progress"),
6330 adapter->sessionId);
6331 return adapter;
6332 } else if ((eConnectionState_Associated ==
6333 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +05306334 sme_is_sta_key_exchange_in_progress(
6335 hdd_ctx->hHal, adapter->sessionId)) {
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306336 hddLog(LOG1, FL("session_id %d: Key exchange is in progress"),
6337 adapter->sessionId);
6338 return adapter;
6339 }
6340 }
6341end:
6342 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
6343 adapter_node = next;
6344 }
6345 return NULL;
6346}
6347