blob: 5258b344bb02eb771348a8f8c88fe22e3e0353cb [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
Agarwal Ashish51325b52014-06-16 16:50:49 +05302233 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002234 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
2235 goto done;
2236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002237
2238 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2239 pCsrRoamInfo->nAssocReqLength);
2240 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002241 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002242
2243 //pFTAssocRsp needs to point to the IEs
2244 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002245 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 (unsigned int)pFTAssocRsp[0],
2247 (unsigned int)pFTAssocRsp[1]);
2248
2249 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08002250 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002253 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002254
Abhishek Singh5a597e62016-12-05 15:16:30 +05302255 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
2256 (int) pCsrRoamInfo->pBssDesc->channelId);
2257 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
2258 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
2259 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2260 chan, pCsrRoamInfo->bssid,
2261 &roam_profile.SSID.ssId[0],
2262 roam_profile.SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302263 hdd_send_roamed_ind(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07002264 reqRsnIe, reqRsnLength,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302265 rspRsnIe, rspRsnLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002266
2267done:
2268 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07002269}
Jeff Johnson295189b2012-06-20 16:38:30 -07002270
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302271void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
2272{
2273 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2274 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2275 tCsrRoamInfo roamInfo;
2276 roamInfo.fAuthRequired = FALSE;
2277 vos_mem_copy(roamInfo.bssid,
2278 pHddStaCtx->roam_info.bssid,
2279 WNI_CFG_BSSID_LEN);
2280 vos_mem_copy(roamInfo.peerMac,
2281 pHddStaCtx->roam_info.peerMac,
2282 WNI_CFG_BSSID_LEN);
2283
2284 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
2285 &roamInfo,
2286 pHddStaCtx->roam_info.roamId,
2287 pHddStaCtx->roam_info.roamStatus,
2288 eCSR_ROAM_RESULT_AUTHENTICATED);
2289 if (halStatus != eHAL_STATUS_SUCCESS)
2290 {
2291 hddLog(LOGE, "%s: Set Key complete failure", __func__);
2292 }
2293 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
2294}
2295
Abhishek Singh78c691f2017-11-30 13:48:44 +05302296/**
2297 * hdd_schedule_ecsa_chan_change_work() - schedule ecsa chan change work
2298 * @hal: hal context
2299 * @sta_session_id: sta session id
2300 *
2301 * Return: void.
2302 */
2303static void
2304hdd_schedule_ecsa_chan_change_work(hdd_context_t *hdd_ctx,
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302305 uint8_t sta_session_id)
Abhishek Singh78c691f2017-11-30 13:48:44 +05302306{
2307 v_TIME_t conn_start_time;
2308 int32_t time_diff;
2309
2310 conn_start_time = sme_get_connect_strt_time(hdd_ctx->hHal, sta_session_id);
2311 time_diff = vos_timer_get_system_time() - conn_start_time;
2312
2313 if (time_diff < 0)
2314 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL;
2315 else if (time_diff > ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL)
2316 time_diff = 0;
2317 else
2318 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL - time_diff;
2319
2320 hddLog(LOG1, FL("schedule ecsa_chan_change_work after %d ms"), time_diff);
2321 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
2322 msecs_to_jiffies(time_diff));
2323}
2324
Shailender Karmuchia734f332013-04-19 14:02:48 -07002325static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2326 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 eCsrRoamResult roamResult )
2328{
2329 struct net_device *dev = pAdapter->dev;
2330 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2331 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302332 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05302333 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002334 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2335 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002336#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07002337 int ft_carrier_on = FALSE;
2338#endif
2339 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302340 v_BOOL_t hddDisconInProgress = FALSE;
2341
2342 /* HDD has initiated disconnect, do not send connect result indication
2343 * to kernel as it will be handled by __cfg80211_disconnect.
2344 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05302345 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
2346 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
2347 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2348 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302349 {
2350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2351 FL(" Disconnect from HDD in progress "));
2352 hddDisconInProgress = TRUE;
2353 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002354
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
2356 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302357 if ( !hddDisconInProgress )
2358 {
2359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05302360 "%s: Set HDD connState to eConnectionState_Associated",
2361 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302362 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
2363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002364
c_hpothu44ff4e02014-05-08 00:13:57 +05302365 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07002366 // Save the connection info from CSR...
2367 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05302368
2369#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2370 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
2371 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
2372 !hddDisconInProgress &&
2373 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
2374 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
2375 sme_set_per_roam_rxconfig(pHddCtx->hHal,
2376 pHddStaCtx->conn_info.staId[0],
2377 pHddCtx->cfg_ini->rateDownThreshold,
2378 pHddCtx->cfg_ini->rateUpThreshold,
2379 pHddCtx->cfg_ini->PERroamTriggerPercent,
2380 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
2381 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
2382#endif
2383
Jeff Johnson295189b2012-06-20 16:38:30 -07002384#ifdef FEATURE_WLAN_WAPI
2385 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
2386 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
2387 {
2388 pAdapter->wapi_info.fIsWapiSta = 1;
2389 }
2390 else
2391 {
2392 pAdapter->wapi_info.fIsWapiSta = 0;
2393 }
2394#endif /* FEATURE_WLAN_WAPI */
2395
2396 // indicate 'connect' status to userspace
2397 hdd_SendAssociationEvent(dev,pRoamInfo);
2398
2399
Shailender Karmuchia734f332013-04-19 14:02:48 -07002400 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 INIT_COMPLETION(pAdapter->linkup_event_var);
2402
2403 /*
2404 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
2405 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 -07002406 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 know that the device is getting activated properly.
2408 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002409#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05302410 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 {
2412#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002413 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 pAdapter->isLinkUpSvcNeeded = TRUE;
2415
Shailender Karmuchia734f332013-04-19 14:02:48 -07002416 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 pAdapter->isLinkUpSvcNeeded = TRUE;
2418
2419 // Switch on the Carrier to activate the device
2420 netif_carrier_on(dev);
2421
2422 // Wait for the Link to up to ensure all the queues are set properly by the kernel
2423 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
2424 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002425 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 {
2427 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
2428 }
2429
2430 // Disable Linkup Event Servicing - no more service required from the net device notifier call
2431 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002432#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002434 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002436 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 }
2438#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05302439 /* Check for STAID */
2440 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
2441 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2442 else
2443 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002444
2445 //For reassoc, the station is already registered, all we need is to change the state
2446 //of the STA in TL.
2447 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05302448 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 if( !pRoamInfo->fReassocReq )
2450 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002451 struct cfg80211_bss *bss;
2452#ifdef WLAN_FEATURE_VOWIFI_11R
2453 u8 *pFTAssocRsp = NULL;
2454 unsigned int assocRsplen = 0;
2455 u8 *pFTAssocReq = NULL;
2456 unsigned int assocReqlen = 0;
2457 struct ieee80211_channel *chan;
2458#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002460 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002461
2462 /* add bss_id to cfg80211 data base */
2463 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2464 if (NULL == bss)
2465 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302466 hddLog(LOGE,
2467 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05302468 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302469 if (!hddDisconInProgress) {
2470 /*
2471 * Here driver was not able to update cfg80211 database
2472 * this can happen if connected channel is not valid,
2473 * i.e reg domain was changed during connection.
2474 * Queue disconnect for the session if disconnect is
2475 * not in progress.
2476 */
2477 hddLog(LOGE, FL("Disconnecting..."));
2478 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2479 pAdapter->sessionId,
2480 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 return eHAL_STATUS_FAILURE;
2483 }
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302484
2485 //Association Response
2486 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames +
2487 pRoamInfo->nBeaconLength +
2488 pRoamInfo->nAssocReqLength);
2489 if (pFTAssocRsp != NULL)
2490 {
2491 // pFTAssocRsp needs to point to the IEs
2492 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2493 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
2494 (unsigned int)pFTAssocRsp[0],
2495 (unsigned int)pFTAssocRsp[1]);
2496 assocRsplen =
2497 pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2498 }
2499 else
2500 {
2501 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
2502 assocRsplen = 0;
2503 }
2504
2505 //Association Request
2506 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
2507 pRoamInfo->nBeaconLength);
2508 if (pFTAssocReq != NULL)
2509 {
2510 if(!ft_carrier_on)
2511 {
2512 // pFTAssocReq needs to point to the IEs
2513 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
2514 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
2515 (unsigned int)pFTAssocReq[0],
2516 (unsigned int)pFTAssocReq[1]);
2517 assocReqlen =
2518 pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
2519 }
2520 else
2521 {
2522 /* This should contain only the FTIEs */
2523 assocReqlen = pRoamInfo->nAssocReqLength;
2524 }
2525 }
2526 else
2527 {
2528 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
2529 assocReqlen = 0;
2530 }
2531
2532 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
2533 assocRsplen);
2534
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002535#ifdef WLAN_FEATURE_VOWIFI_11R
2536 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002537 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002539 if(ft_carrier_on)
2540 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302541 if ( !hddDisconInProgress )
2542 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05302543 struct cfg80211_bss *roam_bss;
2544
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302545 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002546 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302547 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002548 (int)pRoamInfo->pBssDesc->channelId);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302549 if (pHddCtx->cfg_ini &&
2550 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302551 {
2552 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2553 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05302554 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2555 chan, pRoamInfo->bssid,
2556 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2557 pRoamInfo->u.pConnectedProfile->SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302558 hdd_send_roamed_ind(dev, roam_bss,
Abhishek Singh5a597e62016-12-05 15:16:30 +05302559 pFTAssocReq, assocReqlen,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302560 pFTAssocRsp, assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302561 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302562 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2563 {
2564 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
2565 pRoamInfo->fAuthRequired = FALSE;
2566
2567 vos_mem_copy(pHddStaCtx->roam_info.bssid,
2568 pRoamInfo->bssid,
2569 HDD_MAC_ADDR_LEN);
2570 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
2571 pRoamInfo->peerMac,
2572 HDD_MAC_ADDR_LEN);
2573 pHddStaCtx->roam_info.roamId = roamId;
2574 pHddStaCtx->roam_info.roamStatus = roamStatus;
2575 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
2576 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002577 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302578 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002579 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002580 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002581 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302582 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
2583 pFTAssocReq, assocReqlen,
2584 pFTAssocRsp, assocRsplen,
2585 WLAN_STATUS_SUCCESS,
2586 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002587 }
2588 }
2589 else
2590#endif
2591 {
2592 /* wpa supplicant expecting WPA/RSN IE in connect result */
2593 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2594 pAdapter->sessionId,
2595 &reqRsnLength,
2596 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002597
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002598 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2599 pAdapter->sessionId,
2600 &rspRsnLength,
2601 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302602 if ( !hddDisconInProgress )
2603 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002604#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302605 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05302606 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302607 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302608 if (pHddCtx->cfg_ini &&
2609 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302610 {
2611 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2612 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302613 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302614 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002615#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002616
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302617 {
2618 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302619 "%s: sending connect indication to nl80211:"
2620 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302621 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302622 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
2623 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302624 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302625 hdd_connect_result(dev, pRoamInfo->bssid,
2626 pRoamInfo,
Abhinav Kumar4cde8292019-07-18 14:17:25 +05302627 pFTAssocReq, assocReqlen,
2628 pFTAssocRsp, assocRsplen,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302629 WLAN_STATUS_SUCCESS,
2630 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302631 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302634 if ( !hddDisconInProgress )
2635 {
2636 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07002637#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302638 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07002639#endif
2640 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302641 // Register the Station with TL after associated...
2642 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002643 pRoamInfo,
2644 pHddStaCtx->conn_info.staId[ 0 ],
2645 NULL,
2646 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 }
2649 else
2650 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002651 /* wpa supplicant expecting WPA/RSN IE in connect result */
2652 /* in case of reassociation also need to indicate it to supplicant */
2653 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2654 pAdapter->sessionId,
2655 &reqRsnLength,
2656 reqRsnIe);
2657
2658 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302660 if( pRoamInfo->fAuthRequired )
2661 {
2662 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2663 pHddStaCtx->conn_info.staId[ 0 ],
2664 WLANTL_STA_CONNECTED );
2665 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2666 }
2667 else
2668 {
2669 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2670 "%s: staId: %d Changing TL state to AUTHENTICATED",
2671 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
2672 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2673 pHddStaCtx->conn_info.staId[ 0 ],
2674 WLANTL_STA_AUTHENTICATED );
2675 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302676 hdd_postTLPacketPendingInd(pAdapter,
2677 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 }
2680
2681 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
2682 {
2683 // perform any WMM-related association processing
2684 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
2685 }
2686 else
2687 {
2688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002689 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 vosStatus, vosStatus );
2691 }
Chet Lanctot186b5732013-03-18 10:26:30 -07002692#ifdef WLAN_FEATURE_11W
2693 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
2694 sizeof(pAdapter->hdd_stats.hddPmfStats) );
2695#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302696
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05302698 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302699 {
2700 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05302701 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302702 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302703 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302704 {
2705 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
2706 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05302707#ifdef FEATURE_WLAN_TDLS
2708 wlan_hdd_tdls_connection_callback(pAdapter);
2709#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002710 }
2711 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002712 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2714
2715 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002716 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302717 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2718 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
2719 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002720 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2722 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08002723 MAC_ADDR_ARRAY(pWextState->req_bssId),
2724 roamResult, roamStatus);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302725 if (!pHddStaCtx->get_mgmt_log_sent) {
2726 pHddStaCtx->get_mgmt_log_sent = TRUE;
Abhishek Singh611295e2015-07-09 11:11:54 +05302727 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302728 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302729 }
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302730
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302731 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2732 (pRoamInfo &&
2733 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2734 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2735 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05302736 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302737 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2738 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2739 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2740 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05302741 /* Set connection state to eConnectionState_NotConnected only when CSR
2742 * has completed operation - with a ASSOCIATION_FAILURE status
2743 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302744 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05302745 {
2746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2747 "%s: Set HDD connState to eConnectionState_NotConnected",
2748 __func__);
2749 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2750 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302751 if((pHddCtx->concurrency_mode <= 1) &&
2752 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 {
2754 pHddCtx->isAmpAllowed = VOS_TRUE;
2755 }
2756
2757 //If the Device Mode is Station
2758 // and the P2P Client is Connected
2759 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002760
2761 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002762 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002763 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2764 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302765 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 {
2767 //Enable BMPS only of other Session is P2P Client
2768 hdd_context_t *pHddCtx = NULL;
2769 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2770
2771 if (NULL != pVosContext)
2772 {
2773 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2774
2775 if(NULL != pHddCtx)
2776 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302777 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302778 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2779 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302780 {
2781 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002782 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302783 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002784 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302785 hdd_enable_bmps_imps(pHddCtx);
2786 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 }
2788 }
2789 }
2790
James Zmudafbf5ffc2013-03-25 12:45:35 -07002791 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002792 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302793 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002794 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302795
2796 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2797 {
2798 hddLog(LOG1,
2799 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2800 wlan_hdd_tdls_reenable(pHddCtx);
2801 }
2802
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302803 if (pRoamInfo) {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302804 hddLog(VOS_TRACE_LEVEL_ERROR,
2805 "%s: send connect failure to nl80211:"
2806 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302807 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302808 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302809 roamResult, roamStatus, pRoamInfo->reasonCode);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302810 pHddStaCtx->conn_info.assoc_status_code =
2811 pRoamInfo->statusCode;
2812 } else {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302813 hddLog(VOS_TRACE_LEVEL_ERROR,
2814 "%s: connect failed:"
2815 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302816 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302817 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2818 roamResult, roamStatus);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302819 }
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302820
James Zmudafbf5ffc2013-03-25 12:45:35 -07002821 /* inform association failure event to nl80211 */
2822 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2823 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002824 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302825 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002826 NULL, 0, NULL, 0,
2827 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302828 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002829 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302830 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002831 NULL, 0, NULL, 0,
2832 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302833 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002834 }
2835 else
2836 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002837 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302838 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002839 NULL, 0, NULL, 0,
2840 pRoamInfo->reasonCode ?
2841 pRoamInfo->reasonCode :
2842 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302843 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002844 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302845 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002846 NULL, 0, NULL, 0,
2847 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302848 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002849 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302850 /*Clear the roam profile*/
2851 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002853
Kumar Anand82c009f2014-05-29 00:29:42 -07002854 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002855
c_hpothu24f40982014-04-18 18:00:36 +05302856 if (pRoamInfo)
2857 {
2858 WLANTL_AssocFailed(pRoamInfo->staId);
2859 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302860
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302861 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 netif_tx_disable(dev);
2863 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002864
Jeff Johnson295189b2012-06-20 16:38:30 -07002865 }
2866
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302867 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302868 {
2869 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2870 if (pHostapdAdapter != NULL)
2871 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302872 /* Restart SAP if its operating channel is different
2873 * from AP channel.
2874 */
2875 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2876 (int)pRoamInfo->pBssDesc->channelId)
2877 {
2878 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2879 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2880 (int)pRoamInfo->pBssDesc->channelId);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302881 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->force_scc_with_ecsa)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302882 {
Abhishek Singh78c691f2017-11-30 13:48:44 +05302883 hdd_schedule_ecsa_chan_change_work(pHddCtx,
2884 pAdapter->sessionId);
2885 }
2886 else
2887 {
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302888 hdd_hostapd_stop(pHostapdAdapter->dev);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302889 if (pHddCtx->cfg_ini &&
2890 pHddCtx->cfg_ini->enable_sap_auth_offload)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302891 hdd_force_scc_restart_sap(pHostapdAdapter,
2892 pHddCtx, (int)pRoamInfo->pBssDesc->channelId);
2893 }
Agrawal Ashish574b3e62017-02-09 18:58:34 +05302894
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302895 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302896 }
2897 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302898 else if (roamStatus == eCSR_ROAM_ASSOCIATION_FAILURE)
2899 {
2900 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
2901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 return eHAL_STATUS_SUCCESS;
2903}
2904
2905/**============================================================================
2906 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002907 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002909
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002911static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2912 tCsrRoamInfo *pRoamInfo,
2913 tANI_U32 roamId,
2914 eRoamCmdStatus roamStatus,
2915 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002916{
Katya Nigam47528772015-02-11 12:24:49 +05302917 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2918 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2919 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302920 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302921
Jeff Johnson81c17882013-05-03 09:53:35 -07002922 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2923 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2924
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 switch( roamResult )
2926 {
2927 // both IBSS Started and IBSS Join should come in here.
2928 case eCSR_ROAM_RESULT_IBSS_STARTED:
2929 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002930 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002931 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002932 if (NULL == pRoamInfo)
2933 {
2934 VOS_ASSERT(0);
2935 return;
2936 }
2937
2938 /* When IBSS Started comes from CSR, we need to move
2939 * connection state to IBSS Disconnected (meaning no peers
2940 * are in the IBSS).
2941 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2943 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2944 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002945 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2946 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302947 /*notify wmm */
2948 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002949 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002950
Jeff Johnson81c17882013-05-03 09:53:35 -07002951 if (pRoamInfo->pBssDesc)
2952 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302953#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2954 struct ieee80211_channel *chan;
2955 int chan_no;
2956 unsigned int freq;
2957#endif
Katya Nigam47528772015-02-11 12:24:49 +05302958 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2959 IBSS_BROADCAST_STAID,
2960 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002961
2962 /* we created the IBSS, notify supplicant */
2963 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2964 MAC_ADDRESS_STR,
2965 __func__, pAdapter->dev->name,
2966 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2967
2968 /* we must first give cfg80211 the BSS information */
2969 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2970 if (NULL == bss)
2971 {
2972 hddLog(VOS_TRACE_LEVEL_ERROR,
2973 "%s: %s: unable to create IBSS entry",
2974 __func__, pAdapter->dev->name);
2975 return;
2976 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302977#ifdef WLAN_FEATURE_RMC
2978 netif_carrier_on(pAdapter->dev);
2979 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2980 netif_tx_start_all_queues(pAdapter->dev);
2981#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302982#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2983 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002984
Anand N Sunkadfec40682015-07-29 09:51:17 +05302985 if (chan_no <= 14)
2986 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302987 HDD_NL80211_BAND_2GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302988 else
2989 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302990 HDD_NL80211_BAND_5GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302991
2992 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2993
2994 if (chan)
2995 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2996 chan, GFP_KERNEL);
2997 else
2998 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2999 pAdapter->dev->name,
3000 (int)pRoamInfo->pBssDesc->channelId);
3001#else
Jeff Johnson81c17882013-05-03 09:53:35 -07003002 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05303003#endif
Yue Maf49ba872013-08-19 12:04:25 -07003004 cfg80211_put_bss(
3005#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3006 pHddCtx->wiphy,
3007#endif
3008 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07003009 }
Katya Nigam47528772015-02-11 12:24:49 +05303010 else
3011 {
3012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3013 "%s: NULL Bss Desc",__func__);
3014 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05303015
3016 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
3017 * in IBSS_COALESCED will remove the BC key.
3018 */
3019 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
3020 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
3021 == pHddStaCtx->ibss_enc_key.encType
3022 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
3023 == pHddStaCtx->ibss_enc_key.encType
3024 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3025 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
3026 {
3027 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3028 VOS_STATUS vosStatus;
3029
3030 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
3031
3032 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3033 grpmacaddr, WNI_CFG_BSSID_LEN);
3034 hddLog(VOS_TRACE_LEVEL_INFO,
3035 FL(" SET GTK in case of COALESCED"));
3036 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3037 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3038 if ( VOS_STATUS_SUCCESS != vosStatus )
3039 {
3040 hddLog(VOS_TRACE_LEVEL_ERROR,
3041 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
3042 }
3043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 break;
3045 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003046
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3048 {
Jeff Johnson81c17882013-05-03 09:53:35 -07003049 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
3050 __func__, pAdapter->dev->name);
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 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07003055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
3056 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003058 }
3059
Jeff Johnson81c17882013-05-03 09:53:35 -07003060 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003061}
3062
3063/**============================================================================
3064 *
3065 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
3066 This information is passed to iwconfig later. The peer that joined
3067 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003068 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003070
Jeff Johnson295189b2012-06-20 16:38:30 -07003071 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05303072static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07003073{
3074 int fSuccess = FALSE;
3075 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303076 VOS_STATUS status;
3077 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003078
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3080 {
3081 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
3082 {
3083 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003084
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003086
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 fSuccess = TRUE;
3088 break;
3089 }
3090 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003091
Nirav Shah7e3c8132015-06-22 23:51:42 +05303092 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
3093 if (status != VOS_STATUS_SUCCESS) {
3094 hddLog(VOS_TRACE_LEVEL_ERROR,
3095 FL("Not able to add staid hash %d"), staId);
3096 return FALSE;
3097 }
3098
3099 hddLog(VOS_TRACE_LEVEL_INFO,
3100 FL("New station added sta_id %d mac:"
3101 MAC_ADDRESS_STR), staId,
3102 MAC_ADDR_ARRAY(peerMacAddress->bytes));
3103
Shailender Karmuchia734f332013-04-19 14:02:48 -07003104 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07003105}
3106/**============================================================================
3107 *
3108 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003109 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07003113static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003114{
3115 int fSuccess = FALSE;
3116 int idx = 0;
3117 v_U8_t valid_idx = 0;
3118 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07003119 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003120 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05303121 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003122
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3124 {
3125 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
3126 {
3127 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303128 status = hdd_sta_id_hash_remove_entry(pAdapter,
3129 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
3130 if (status != VOS_STATUS_SUCCESS) {
3131 hddLog(VOS_TRACE_LEVEL_ERROR,
3132 FL("Not able to remove staid hash %d"), staId );
3133 fSuccess = FALSE;
3134 } else {
3135 hddLog(VOS_TRACE_LEVEL_INFO,
3136 FL("station removed sta_id %d mac:"
3137 MAC_ADDRESS_STR), staId,
3138 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07003139
Nirav Shah7e3c8132015-06-22 23:51:42 +05303140 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07003141
Nirav Shah7e3c8132015-06-22 23:51:42 +05303142 fSuccess = TRUE;
3143 // Note the deleted Index, if its 0 we need special handling
3144 del_idx = idx;
3145 empty_slots++;
3146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 }
3148 else
3149 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003150 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 {
3152 valid_idx = idx;
3153 }
Ravi Joshi8a934352013-09-25 16:46:58 -07003154 else
3155 {
3156 // Found an empty slot
3157 empty_slots++;
3158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 }
3160 }
3161
Ravi Joshi8a934352013-09-25 16:46:58 -07003162 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
3163 {
3164 // Last peer departed, set the IBSS state appropriately
3165 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003166 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07003167 "Last IBSS Peer Departed!!!" );
3168 }
3169
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 // Find next active staId, to have a valid sta trigger for TL.
3171 if (fSuccess == TRUE)
3172 {
3173 if (del_idx == 0)
3174 {
3175 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
3176 {
3177 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
3178 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
3179 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
3180
3181 pHddStaCtx->conn_info.staId[valid_idx] = 0;
3182 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
3183 }
3184 }
3185 }
3186 return( fSuccess );
3187}
3188
3189/**============================================================================
3190 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003193
Jeff Johnson295189b2012-06-20 16:38:30 -07003194 ===========================================================================*/
3195static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
3196{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003197 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05303198 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3199 "%s: IBSS Connect Indication from SME!!! "
3200 "Set HDD connState to eConnectionState_IbssConnected",
3201 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
3203 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
3204
3205 // Save the connection info from CSR...
3206 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
3207
3208 // Send the bssid address to the wext.
3209 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003211 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3212 if (NULL == bss)
3213 {
3214 hddLog(VOS_TRACE_LEVEL_ERROR,
3215 "%s: %s: unable to create IBSS entry",
3216 __func__, pAdapter->dev->name);
3217 return eHAL_STATUS_FAILURE;
3218 }
Yue Maf49ba872013-08-19 12:04:25 -07003219 cfg80211_put_bss(
3220#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3221 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
3222#endif
3223 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07003224
3225 return( eHAL_STATUS_SUCCESS );
3226}
Mukul Sharmad2589a52014-04-23 21:06:25 +05303227
3228/**============================================================================
3229 *
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003231
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003233static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3234 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 eCsrRoamResult roamResult )
3236{
3237 eCsrEncryptionType connectedCipherAlgo;
3238 v_BOOL_t fConnected = FALSE;
3239 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3240 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303241 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303243 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07003245
3246 if (NULL == pRoamInfo)
3247 {
3248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
3249 return eHAL_STATUS_FAILURE;
3250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003252 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07003253 // not require upper layer authentication) we can put TL directly into 'authenticated'
3254 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003255 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3256 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
3257 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003258
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3260 if( fConnected )
3261 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003262 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
3263 {
3264 v_U8_t staId;
3265
3266 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
3267
3268 if ( 0 == memcmp( pRoamInfo->peerMac,
3269 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
3270 {
3271 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3272 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05303273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3274 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003275 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3276 }
3277 else
3278 {
3279 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
3280 (v_MACADDR_t*)pRoamInfo->peerMac,
3281 &staId);
3282 if ( VOS_STATUS_SUCCESS == vosStatus )
3283 {
3284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3285 "WLAN TL STA Ptk Installed for STAID=%d", staId);
3286 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3287 staId);
3288 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3289 }
3290 }
3291 }
3292 else
3293 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05303294 WLANTL_GetSTAState(pHddCtx->pvosContext,
3295 pHddStaCtx->conn_info.staId[0],
3296 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303297 // TODO: Considering getting a state machine in HDD later.
3298 // This routine is invoked twice. 1)set PTK 2)set GTK.
3299 // The folloing if statement will be TRUE when setting GTK.
3300 // At this time we don't handle the state in detail.
3301 // Related CR: 174048 - TL not in authenticated state
3302 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
3303 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
3304 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303305
3306 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
3307 "for StaId=%d. Changing TL state to AUTHENTICATED from"
3308 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303309
3310 // Connections that do not need Upper layer authentication,
3311 // transition TL to 'Authenticated' state after the keys are set.
3312 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3313 pHddStaCtx->conn_info.staId[ 0 ],
3314 WLANTL_STA_AUTHENTICATED );
3315
3316 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303317
3318 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3319 hdd_postTLPacketPendingInd(pAdapter,
3320 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05303321 //Need to call offload because when roaming happen at that time fwr
3322 //clean offload info as part of the DelBss
3323 // No need to configure offload if host was not suspended
3324 spin_lock(&pHddCtx->filter_lock);
3325 if(pHddCtx->hdd_wlan_suspended)
3326 {
3327 spin_unlock(&pHddCtx->filter_lock);
3328 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
3329 }
3330 else
3331 {
3332 spin_unlock(&pHddCtx->filter_lock);
3333 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303334 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3335 {
3336 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
3337 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303338 }
3339 else
3340 {
3341 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3342 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303343
3344 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
3345 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
3346 {
3347 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
3348 " for StaId=%d. Due to OSEN, Changing TL state to"
3349 "AUTHENTICATED from state:%d",
3350 pHddStaCtx->conn_info.staId[0], prevTLState);
3351
3352 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3353 pHddStaCtx->conn_info.staId[ 0 ],
3354 WLANTL_STA_AUTHENTICATED );
3355
3356 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3357
3358 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3359 hdd_postTLPacketPendingInd(pAdapter,
3360 pHddStaCtx->conn_info.staId[0]);
3361 }
3362
3363
3364
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303365 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3366 {
3367 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
3368 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303369 }
3370
3371 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303374 else
3375 {
3376 // possible disassoc after issuing set key and waiting set key complete
3377 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3378 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003379
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 EXIT();
3381 return( eHAL_STATUS_SUCCESS );
3382}
3383/**============================================================================
3384 *
3385 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
3386 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003387static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07003389{
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3391
3392 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3393 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
3394 {
3395 struct iw_michaelmicfailure msg;
3396 union iwreq_data wreq;
3397 memset(&msg, '\0', sizeof(msg));
3398 msg.src_addr.sa_family = ARPHRD_ETHER;
3399 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08003400 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
3401 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07003402
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3404 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003405 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 msg.flags = IW_MICFAILURE_PAIRWISE;
3407 memset(&wreq, 0, sizeof(wreq));
3408 wreq.data.length = sizeof(msg);
3409 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003411 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3413 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
3414 NL80211_KEYTYPE_GROUP :
3415 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07003416 pRoamInfo->u.pMICFailureInfo->keyId,
3417 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003421
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 return( eHAL_STATUS_SUCCESS );
3423}
3424
3425/**============================================================================
3426 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003427 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07003428 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003429
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003431static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3432 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 eCsrRoamResult roamResult )
3434{
3435 VOS_STATUS vosStatus;
3436
3437 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3438 switch( roamResult )
3439 {
3440 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3441 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003442 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303443 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003444
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303445 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3446 "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 -07003447 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3448 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003450
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3452
Shailender Karmuchia734f332013-04-19 14:02:48 -07003453 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
3454 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
3455 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
3456
3457 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05303458 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 pRoamInfo,
3460 pRoamInfo->staId,
3461 (v_MACADDR_t *)pRoamInfo->peerMac,
3462 pRoamInfo->pBssDesc );
3463 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3464 {
3465 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003466 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 vosStatus, vosStatus );
3468 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05303469 if (!roamSaveIbssStation(pAdapter,
3470 pRoamInfo->staId,
3471 (v_MACADDR_t *)pRoamInfo->peerMac))
3472 {
3473 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
3474 break;
3475 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003476 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303477
3478 staInfo = vos_mem_malloc(sizeof(*staInfo));
3479 if (staInfo == NULL) {
3480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3481 "memory allocation for station_info failed");
3482 return eHAL_STATUS_FAILED_ALLOC;
3483 }
3484
3485 memset(staInfo, 0, sizeof(*staInfo));
3486 staInfo->filled = 0;
3487 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003488
3489 cfg80211_new_sta(pAdapter->dev,
3490 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303491 staInfo, GFP_KERNEL);
3492 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003493
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003494 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3495 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3496 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3497 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
3498 {
3499 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05303500
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003501 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3502 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
3503
3504 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003505 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003506 pHddStaCtx->ibss_enc_key.encType);
3507
3508 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3509 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3510
3511 if ( VOS_STATUS_SUCCESS != vosStatus )
3512 {
3513 hddLog(VOS_TRACE_LEVEL_ERROR,
3514 "%s: sme_RoamSetKey failed, returned %d",
3515 __func__, vosStatus);
3516 return VOS_STATUS_E_FAILURE;
3517 }
3518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303520 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 netif_tx_start_all_queues(pAdapter->dev);
3522 break;
3523 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003524
Jeff Johnson295189b2012-06-20 16:38:30 -07003525 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3526 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003527
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003529
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3533 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003534 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003535
Ravi Joshicc57ed42013-10-12 16:31:25 -07003536 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003537 {
3538 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3539 "IBSS peer departed by cannot find peer in our registration table with TL" );
3540 }
3541
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3543 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003544 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3545 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
3546 pRoamInfo->staId );
3547
Katya Nigam47528772015-02-11 12:24:49 +05303548 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003549
3550 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003551 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003552
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003553 cfg80211_del_sta(pAdapter->dev,
3554 (const u8 *)&pRoamInfo->peerMac,
3555 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 break;
3557 }
3558 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3559 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003560 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
3561 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303563 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 netif_tx_disable(pAdapter->dev);
3565 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05303566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3567 "%s: Set HDD connState to eConnectionState_NotConnected",
3568 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003570
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 // Send the bssid address to the wext.
3572 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
3573 // clean up data path
3574 hdd_disconnect_tx_rx(pAdapter);
3575 break;
3576 }
3577 default:
3578 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003579
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003581
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 return( eHAL_STATUS_SUCCESS );
3583}
3584
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003585#ifdef FEATURE_WLAN_TDLS
3586/**============================================================================
3587 *
3588 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
3589 TL the new STA. This is called as part of ADD_STA in the TDLS setup
3590 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07003591
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003592 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303593VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
3594#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3595 const tANI_U8 *peerMac,
3596#else
3597 tANI_U8 *peerMac,
3598#endif
3599 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003600{
3601 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003602 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003603 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3604 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003605 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
3606 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003607 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3608 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003609
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003610 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3611 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003612 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003613 "%s not connected. ignored", __func__);
3614 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003615 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003616
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003617 /*
3618 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3619 * be peer MAC, here we are wokrking on direct Link
3620 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003621 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003622
3623 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003624
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003625 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003626 sizeof(tSirMacAddr) );
3627
3628 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
3629 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
3630
3631 /* set the QoS field appropriately ..*/
3632 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
3633 : (staDesc.ucQosEnabled = 0) ;
3634
3635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08003636 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003637
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003638 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003639
3640 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003641 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003642
Shailender Karmuchia734f332013-04-19 14:02:48 -07003643 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003644 * UMA is ready we inform TL to do frame translation.
3645 */
3646 staDesc.ucSwFrameTXXlation = 1;
3647 staDesc.ucSwFrameRXXlation = 1;
3648 staDesc.ucAddRmvLLC = 1;
3649
3650 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003651 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003652
3653 /* tdls Direct Link do not need bcastSig */
3654 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003655
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003656 if(staDesc.ucProtectedFrame)
3657 staDesc.ucIsReplayCheckValid = VOS_TRUE;
3658 else
3659 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003660
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303661 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003662
Shailender Karmuchia734f332013-04-19 14:02:48 -07003663 /* Register the Station with TL... */
3664 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
3665 hdd_rx_packet_cbk,
3666 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003667 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003668
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003669 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3670 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003672 "%s: WLANTL_RegisterSTAClient() failed to register. "
3673 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003674 return vosStatus;
3675 }
3676
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003677 if ( cfg_param->dynSplitscan &&
3678 ( VOS_TIMER_STATE_RUNNING !=
3679 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
3680 {
3681 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
3682 cfg_param->trafficMntrTmrForSplitScan);
3683 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003684 return( vosStatus );
3685}
3686
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303687VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003688{
3689 VOS_STATUS vosStatus;
3690 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
3691 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3692 {
3693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3694 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003695 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003696 __func__, staId, vosStatus, vosStatus );
3697 }
3698 return( vosStatus );
3699}
3700
3701
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003702/*
3703 * HDD interface between SME and TL to ensure TDLS client registration with
3704 * TL in case of new TDLS client is added and deregistration at the time
3705 * TDLS client is deleted.
3706 */
3707
Shailender Karmuchia734f332013-04-19 14:02:48 -07003708eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
3709 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003710 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07003711 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003712 eCsrRoamResult roamResult)
3713{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003714 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003715 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003716 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003717
Kaushik, Sushant8489f472014-01-27 11:41:22 +05303718 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08003719 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3720 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
3721 "ADD_TDLS_PEER" :
3722 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
3723 "DEL_TDLS_PEER" :
3724 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
3725 "DEL_TDLS_PEER_IND" :
3726 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3727 "DEL_ALL_TDLS_PEER_IND" :
3728 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
3729 "UPDATE_TDLS_PEER" :
3730 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303731 "LINK_ESTABLISH_REQ_RSP" :
3732 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
3733 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08003734 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003735 switch( roamResult )
3736 {
3737 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3738 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003739 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3740 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303741 hddTdlsPeer_t *curr_peer;
3742
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003743 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003744 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05303745 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303746
3747 mutex_lock(&pHddCtx->tdls_lock);
3748 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3749 pRoamInfo->peerMac, FALSE);
3750 if (NULL != curr_peer)
3751 curr_peer->link_status = eTDLS_LINK_TEARING;
3752 else
3753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3754 "%s %d curr_peer is Null", __func__,__LINE__);
3755 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003756 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003757 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003758 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003759
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003760 /* check if there is available index for this new TDLS STA */
3761 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3762 {
3763 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3764 {
3765 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3766 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3767
3768 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003769 ("TDLS: STA IDX at %d is %d "
3770 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003771 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003772 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003773
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003774 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003775 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3776 status = eHAL_STATUS_SUCCESS ;
3777 break ;
3778 }
3779 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003780 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003781 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003782 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003783 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3784 "wlan_hdd_tdls_set_sta_id() failed");
3785 return VOS_FALSE;
3786 }
3787
3788 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303789 /* store the ucast signature , if required for further reference. */
3790
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003791 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303792 /* start TDLS client registration with TL */
3793 status = hdd_roamRegisterTDLSSTA( pAdapter,
3794 pRoamInfo->peerMac,
3795 pRoamInfo->staId,
3796 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303797 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003798 }
3799 else
3800 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003801 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003802 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003803 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003804 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003805 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003806 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003807 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003808 break ;
3809 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003810 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3811 {
3812 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3813 {
3814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3815 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3816 }
3817 /* store the ucast signature which will be used later when
3818 * registering to TL
3819 */
3820 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3821 complete(&pAdapter->tdls_add_station_comp);
3822 break;
3823 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303824 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3825 {
3826 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3827 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303828 hddTdlsPeer_t *curr_peer;
3829
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3831 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303832
3833 mutex_lock(&pHddCtx->tdls_lock);
3834 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3835 pRoamInfo->peerMac, FALSE);
3836 if (curr_peer)
3837 curr_peer->link_status = eTDLS_LINK_TEARING;
3838 else
3839 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3840 "%s %d curr_peer is Null",__func__,__LINE__);
3841 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303842 }
3843 complete(&pAdapter->tdls_link_establish_req_comp);
3844 break;
3845 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303846 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3847 {
3848 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3850 "%s: Channel switch request failed. %d", __func__,
3851 pRoamInfo->statusCode);
3852 else
3853 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3854 "%s: Channel switch request Success", __func__);
3855 break;
3856 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003857 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003858 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003859 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003860 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003861 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003862 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3863 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003864 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003865 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003866 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3867
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303868 mutex_lock(&pHddCtx->tdls_lock);
3869 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3870 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303871 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003872 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303873 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3874 " Current status for peer" MAC_ADDRESS_STR "is %d",
3875 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303876 if (TDLS_IS_CONNECTED(curr_peer) ||
3877 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303878 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303879 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303880 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3881 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303882 else
3883 mutex_unlock(&pHddCtx->tdls_lock);
3884
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303885 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003886 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303887 else
3888 mutex_unlock(&pHddCtx->tdls_lock);
3889
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303890 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003891 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303892 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003893
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003894 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3895 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3896 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003897 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003898 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003899 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003900 break ;
3901 }
3902 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003903 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003904 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003905 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003906 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3907 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003908 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003909 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3910 "%s: Sending teardown to supplicant with reason code %u",
3911 __func__, pRoamInfo->reasonCode);
3912
3913#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303914 mutex_lock(&pHddCtx->tdls_lock);
3915 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3916 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003917 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303918 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3919 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303920 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003921#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003922 status = eHAL_STATUS_SUCCESS ;
3923 break ;
3924 }
3925 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3926 {
3927 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003928 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003929 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003930 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3931 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003932 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003934 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003935 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003936 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303937
3938 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003939 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303940 mutex_unlock(&pHddCtx->tdls_lock);
3941
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003942 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3943 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003944
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003945 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003946 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003947 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3948 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003949
3950 status = eHAL_STATUS_SUCCESS ;
3951 }
3952 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303953 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003954 break ;
3955 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003956 default:
3957 {
3958 break ;
3959 }
3960 }
3961
3962 return status ;
3963}
3964#endif
3965
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303966void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003967{
3968 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3969 hdd_context_t *pHddCtx = NULL;
3970 int ret;
3971
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303972 ENTER();
3973
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003974 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3975 {
3976 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003977 "%s: Bad param, pAdapter [%pK]",
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003978 __func__, pAdapter);
3979 return;
3980 }
3981
3982 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3983 ret = wlan_hdd_validate_context(pHddCtx);
3984 if (0 != ret)
3985 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003986 return;
3987 }
3988
3989 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3990 {
3991 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3992 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303993
3994 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003995}
3996
Shailender Karmuchia734f332013-04-19 14:02:48 -07003997eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3999{
4000 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
4001 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304002 hdd_wext_state_t *pWextState = NULL;
4003 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004004 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304005 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07004006 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004007
4008 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004009 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004010 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004011
4012 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304013 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004014 {
4015 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05304016 "invalid adapter or adapter has invalid magic");
4017 return eHAL_STATUS_FAILURE;
4018 }
4019
4020 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4021 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4022
4023 if ((NULL == pWextState) || (NULL == pHddStaCtx))
4024 {
4025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4026 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004027 return eHAL_STATUS_FAILURE;
4028 }
4029
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05304030 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4031 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 switch( roamStatus )
4033 {
4034 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05304035 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4036 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004038
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004039#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
4040 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07004042 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 * interface down */
4044 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304045 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
4046 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05304047 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4049 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4050 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4052 }
4053 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05304054 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 break;
4056
4057 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004058 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07004060 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07004061 // eCSR_ROAM_SHOULD_ROAM will be received.
4062 // Where in we will not mark the link down
4063 // Also we want to stop tx at this point when we will be
4064 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004065 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 {
4067 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304068 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05304070 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4071 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
4072 {
4073 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
4074 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004075 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304076 * Deregister this STA with TL, but do not flush the packets
4077 * for this STA from wmm_tx_queue. Since there is no valid STA
4078 * for these packets they will not be transmitted. Eventually
4079 * after the reassociation is successful, these packets will be
4080 * transmitted after registering STA with TL again. This ensures
4081 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004082 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304083 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
4084 pHddStaCtx->conn_info.staId[0]);
4085 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004086 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304087 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4088 FL("WLANTL_ClearSTAClient failed for staID %d."
4089 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
4090 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004091 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004093 }
4094 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004095 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 break;
4097#endif
4098
4099 case eCSR_ROAM_SHOULD_ROAM:
4100 // Dont need to do anything
4101 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 struct net_device *dev = pAdapter->dev;
4103 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4104 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304105 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004107#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 if (pHddStaCtx->ft_carrier_on == FALSE)
4109 {
4110#endif
4111 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004112#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 }
4114#endif
4115
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004116#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 //We should clear all sta register with TL, for now, only one.
4118 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
4119 if ( !VOS_IS_STATUS_SUCCESS(status ) )
4120 {
4121 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4122 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
4123 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004124 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004126#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 }
4128 break;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05304129 case eCSR_ROAM_LOSTLINK_DETECTED:
4130 {
4131 if (wlan_hdd_check_and_stop_mon(pAdapter, false))
4132 halStatus = eHAL_STATUS_FAILURE;
4133 }
4134 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 case eCSR_ROAM_LOSTLINK:
4136 case eCSR_ROAM_DISASSOCIATED:
4137 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4139 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05304140 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4142 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07004143 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4144 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304145 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07004146 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08004147
4148 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
4149 pHddCtx->configuredMcastBcastFilter =
4150 pHddCtx->sus_res_mcastbcast_filter;
4151 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
4152 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304153
Amar Singhald53568e2013-09-26 11:03:45 -07004154 hddLog(VOS_TRACE_LEVEL_INFO,
4155 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4156 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
4157 pHddCtx->configuredMcastBcastFilter);
4158 hddLog(VOS_TRACE_LEVEL_INFO,
4159 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4161 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004162#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304163 /* Call to clear any MC Addr List filter applied after
4164 * successful connection.
4165 */
4166 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004167#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 }
4169 break;
4170 case eCSR_ROAM_IBSS_LEAVE:
4171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4172 "****eCSR_ROAM_IBSS_LEAVE****");
4173 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4174 break;
4175 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4176 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4177 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304178 // To Do - address probable memory leak with WEP encryption upon successful association
4179 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304181 //Clear saved connection information in HDD
4182 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304184 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004185
4186 break;
4187 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004188 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004189 pRoamInfo, roamId, roamStatus, roamResult );
4190 break;
4191 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07004192 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
4193 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 break;
4195
4196 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
4197 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004199
4200 case eCSR_ROAM_MIC_ERROR_IND:
4201 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4202 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05304203 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
4204 {
4205 /*
4206 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
4207 * adding the 100 value.
4208 */
4209 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
4210 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4211 "%s : Rssi on Disconnect : %d",
4212 __func__, pAdapter->rssi_on_disconnect);
4213 break;
4214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004215 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004216 {
4217 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4218
4219 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004220 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304221 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304222 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004223 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004224 /* Send DTIM period to the FW; only if the wlan is already
4225 in suspend. This is the case with roaming (reassoc),
4226 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
4227 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
4228 before the ENTER_BMPS_REQ ensures Listen Interval is
4229 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004230 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004231
4232 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004233 if due to unexpected scenario, if we are in BMPS,
4234 then trigger Exit and Enter BMPS to take DTIM period
4235 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004236 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
4237 {
4238 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
4239
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004240 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4241 iw_full_power_cbfn, pAdapter,
4242 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004243 }
4244 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304245
4246 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304247 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
4248 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304249 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304250 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304251 {
4252 hddLog( LOG1, FL("Device in full power."
4253 "Stop and start traffic timer for roaming"));
4254 pmcStopTrafficTimer(pHddCtx->hHal);
4255 if (pmcStartTrafficTimer(pHddCtx->hHal,
4256 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
4257 {
4258 hddLog(LOGP, FL("Cannot start traffic timer"));
4259 }
4260 }
4261
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004262 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304263 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304264 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304265 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 break;
4268#ifdef WLAN_FEATURE_VOWIFI_11R
4269 case eCSR_ROAM_FT_RESPONSE:
4270 hdd_SendFTEvent(pAdapter);
4271 break;
4272#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004273#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004274 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004275 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07004276 {
4277 /* Notify the supplicant of a new candidate */
4278 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
4279 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004280 break;
4281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004282
Yue Maef608272013-04-08 23:09:17 -07004283#ifdef FEATURE_WLAN_LFR_METRICS
4284 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4285 /* This event is to notify pre-auth initiation */
4286 if (VOS_STATUS_SUCCESS !=
4287 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
4288 {
4289 halStatus = eHAL_STATUS_FAILURE;
4290 }
4291 break;
4292 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4293 /* This event will notify pre-auth completion in case of success */
4294 if (VOS_STATUS_SUCCESS !=
4295 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4296 pRoamInfo, 1))
4297 {
4298 halStatus = eHAL_STATUS_FAILURE;
4299 }
4300 break;
4301 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4302 /* This event will notify pre-auth completion in case of failure. */
4303 if (VOS_STATUS_SUCCESS !=
4304 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4305 pRoamInfo, 0))
4306 {
4307 halStatus = eHAL_STATUS_FAILURE;
4308 }
4309 break;
4310 case eCSR_ROAM_HANDOVER_SUCCESS:
4311 /* This event is to notify handover success.
4312 It will be only invoked on success */
4313 if (VOS_STATUS_SUCCESS !=
4314 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
4315 {
4316 halStatus = eHAL_STATUS_FAILURE;
4317 }
4318 break;
4319#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004320 case eCSR_ROAM_REMAIN_CHAN_READY:
4321 hdd_remainChanReadyHandler( pAdapter );
4322 break;
4323 case eCSR_ROAM_SEND_ACTION_CNF:
4324 hdd_sendActionCnf( pAdapter,
4325 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
4326 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004327#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08004328 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004329 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08004330 roamId, roamStatus, roamResult );
4331 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004332 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4333 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
4334 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004335#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004336#ifdef WLAN_FEATURE_11W
4337 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4338 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
4339 pRoamInfo->pbFrames,
4340 pRoamInfo->frameType);
4341 break;
4342#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004343#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004344 case eCSR_ROAM_TSM_IE_IND:
4345 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
4346 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
4347 break;
4348
4349 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4350 {
4351 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
4352 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
4353 {
4354 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
4355 }
4356 break;
4357 }
4358
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004359 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004360 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004361 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004362 break;
4363 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004364
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004365 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004366 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004367 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004368 break;
4369 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004370#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05304371 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
4372 {
4373 pAdapter->maxRateFlags = roamResult;
4374 break;
4375 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304376 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4377 if (pRoamInfo && pRoamInfo->pBssDesc) {
4378 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4379 pRoamInfo->pBssDesc);
4380 if (bss_status)
4381 cfg80211_put_bss(
4382#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4383 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4384#endif
4385 bss_status);
4386 else
4387 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
4388 }
Abhinav Kumar118efd02019-08-07 16:41:07 +05304389
4390 case eCSR_ROAM_SAE_COMPUTE:
4391 if (pRoamInfo)
4392 wlan_hdd_sae_callback(pAdapter, pRoamInfo);
4393 break;
4394
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304395 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4396 {
4397 hdd_adapter_t *pHostapdAdapter = NULL;
4398 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4399 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4400
4401 if (!pHddCtx || !pHddStaCtx) {
4402 hddLog(LOG1, FL("Invalid pHddCtx or pHddStaCtx"));
4403 break;
4404 }
4405
4406 hddLog(LOG1, FL("eCSR_ROAM_STA_CHANNEL_SWITCH: new channel %hu"),
4407 pRoamInfo->chan_info.chan_id);
4408
4409 pHddStaCtx->conn_info.operationChannel =
4410 pRoamInfo->chan_info.chan_id;
4411
4412 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
4413 if (pHostapdAdapter &&
4414 (test_bit(SOFTAP_BSS_STARTED,
4415 &pHostapdAdapter->event_flags)))
4416 {
4417 /* Restart SAP if its operating channel is different
4418 * from AP channel.
4419 */
4420 hddLog(VOS_TRACE_LEVEL_INFO,"SAP chan %d, STA chan %d, force_scc_with_ecsa %d",
4421 pHostapdAdapter->sessionCtx.ap.operatingChannel,
4422 pRoamInfo->chan_info.chan_id,
4423 pHddCtx->cfg_ini->force_scc_with_ecsa);
4424 if ((pHddCtx->cfg_ini->force_scc_with_ecsa ) &&
4425 (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
4426 pRoamInfo->chan_info.chan_id))
4427 {
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05304428 schedule_delayed_work(&pHddCtx->ecsa_chan_change_work, 0);
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304429 }
4430 else
4431 hddLog(LOG1, FL("SAP restart not required"));
4432 } else
4433 hddLog(LOG1, FL("SAP not active, nothing to do"));
4434 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304435 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05304436 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 break;
4438 }
4439 return( halStatus );
4440}
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304441
4442#ifdef WLAN_FEATURE_SAE
4443/**
4444 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
4445 * @auth_suite: auth suite
4446 * @auth_type: pointer to eCsrAuthType
4447 *
4448 * Return: None
4449 */
4450static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4451 eCsrAuthType *auth_type)
4452{
4453 if (!memcmp(auth_suite, ccp_rsn_oui_80, 4))
4454 *auth_type = eCSR_AUTH_TYPE_SAE;
4455}
4456#else
4457static inline
4458void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
4459 eCsrAuthType *auth_type)
4460{
4461}
4462#endif
4463
Shailender Karmuchia734f332013-04-19 14:02:48 -07004464eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004465{
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304466 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004468 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 {
4470 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004471 } else
4472 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 {
4474 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004475 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004476#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004477 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 {
4479 // Check for 11r FT Authentication with PSK
4480 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004481 } else
4482 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 {
4484 // Check for 11R FT Authentication with 802.1X
4485 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004486 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004487#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004488#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004489 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 {
4491 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4492 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004493#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07004494#ifdef WLAN_FEATURE_11W
4495 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
4496 {
4497 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4498 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304499 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
4500 {
4501 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4502 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004503#endif
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304504 if (!memcmp(auth_suite, ccp_rsn_oui_18, 4))
4505 {
4506 auth_type = eCSR_AUTH_TYPE_OWE;
4507 } else
4508
Shailender Karmuchia734f332013-04-19 14:02:48 -07004509 {
Abhinav Kumar4d44f632019-08-02 13:55:54 +05304510 /* If auth suite is of SAE, auth_type will be
4511 * overwritten in hdd_translate_sae_rsn_to_csr_auth
4512 */
4513 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
4514 }
4515
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304516 hddLog(LOG1, FL("auth_type : %d"), auth_type);
4517
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004519}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004520
Shailender Karmuchia734f332013-04-19 14:02:48 -07004521eCsrAuthType
4522hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004523{
4524 eCsrAuthType auth_type;
4525 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004526 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 {
4528 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004529 } else
4530 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 {
4532 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004533 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004534#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004535 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 {
4537 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004538 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004539#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004540 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4542 }
4543 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4544 return auth_type;
4545}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004546
Shailender Karmuchia734f332013-04-19 14:02:48 -07004547eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004548hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004549{
4550 eCsrEncryptionType cipher_type;
4551 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004552 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 {
4554 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004555 }
4556 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 {
4558 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004559 }
4560 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 {
4562 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004563 }
4564 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 {
4566 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004567 }
4568 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
4569 {
4570 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4571 }
4572 else
4573 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004574 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4575 }
4576 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4577 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004578}
Jeff Johnson295189b2012-06-20 16:38:30 -07004579/* To find if the MAC address is NULL */
4580static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
4581{
4582 int i;
4583 for (i = 0; i < length; i++)
4584 {
4585 if (0x00 != (macAddr[i]))
4586 {
4587 return FALSE;
4588 }
4589 }
4590 return TRUE;
4591} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08004592
Shailender Karmuchia734f332013-04-19 14:02:48 -07004593eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004594hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004595{
4596 eCsrEncryptionType cipher_type;
4597 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004598 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 {
4600 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004601 } else
4602 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 {
4604 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004605 } else
4606 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 {
4608 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004609 } else
4610 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 {
4612 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004613 } else
4614 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004616 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4617 } else
4618 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004619 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4620 }
4621 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4622 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004623}
Jeff Johnson295189b2012-06-20 16:38:30 -07004624
Shailender Karmuchia734f332013-04-19 14:02:48 -07004625static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
4626 struct ether_addr *pBssid,
4627 eCsrEncryptionType *pEncryptType,
4628 eCsrEncryptionType *mcEncryptType,
4629 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004630#ifdef WLAN_FEATURE_11W
4631 u_int8_t *pMfpRequired,
4632 u_int8_t *pMfpCapable,
4633#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004634 u_int16_t gen_ie_len,
4635 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07004636{
4637 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004638 eHalStatus result;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304639 tDot11fIERSN dot11RSNIE = {0};
4640 tDot11fIEWPA dot11WPAIE = {0};
Shailender Karmuchia734f332013-04-19 14:02:48 -07004641 tANI_U32 i;
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304642 tANI_U32 status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004643 tANI_U8 *pRsnIe;
4644 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07004646 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004647
4648 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
4649 flag to 0 */
4650 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
4651 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
gaurank kathpaliab654f702020-01-03 15:07:17 +05304652 memset( PMKIDCache, 0 , sizeof(tPmkidCacheInfo) * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07004655 if ( gen_ie[0] == DOT11F_EID_RSN)
4656 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07004658 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
4660 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304661 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
4662 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004663 return -EINVAL;
4664 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004665 // Skip past the EID byte and length byte
4666 pRsnIe = gen_ie + 2;
4667 RSNIeLen = gen_ie_len - 2;
4668 // Unpack the RSN IE
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304669 status = sme_unpack_rsn_ie(halHandle,
4670 pRsnIe,
4671 RSNIeLen,
4672 &dot11RSNIE);
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304673 if (DOT11F_FAILED(status))
4674 {
4675 hddLog(LOGE,
4676 FL("Parse failure in hdd_ProcessGENIE (0x%08x)"),
4677 status);
4678 return -EINVAL;
4679 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304680 hddLog(LOG1, FL("%s: gp_cipher_suite_present: %d"),
4681 __func__, dot11RSNIE.gp_cipher_suite_present);
4682
Shailender Karmuchia734f332013-04-19 14:02:48 -07004683 // Copy out the encryption and authentication types
4684 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004685 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004686 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304687 __func__, dot11RSNIE.akm_suite_cnt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004688 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 but probably I suspect we can do something different*/
4690 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07004691 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304692 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004693 //dot11RSNIE.pwise_cipher_suite_count
4694 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
4695 //dot11RSNIE.gp_cipher_suite_count
4696 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07004697#ifdef WLAN_FEATURE_11W
4698 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
4699 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
4700#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07004702 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004704 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304706 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 break;
4708 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004709 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304711 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 break;
4713 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004714 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 // For right now, I assume setASSOCIATE() has passed in the bssid.
4716 vos_mem_copy(PMKIDCache[i].BSSID,
4717 pBssid, ETHER_ADDR_LEN);
4718 vos_mem_copy(PMKIDCache[i].PMKID,
4719 dot11RSNIE.pmkid[i],
4720 CSR_RSN_PMKID_SIZE);
4721 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004722
4723 if (updatePMKCache)
4724 {
4725 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004726 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004727 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07004728 // Finally set the PMKSA ID Cache in CSR
4729 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
4730 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304731 dot11RSNIE.pmkid_count,
4732 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07004733 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 }
4735 else if (gen_ie[0] == DOT11F_EID_WPA)
4736 {
4737 // Validity checks
4738 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
4739 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
4740 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304741 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
4742 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 return -EINVAL;
4744 }
4745 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07004746 pRsnIe = gen_ie + 2 + 4;
4747 RSNIeLen = gen_ie_len - (2 + 4);
4748 // Unpack the WPA IE
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304749 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304750 pRsnIe, RSNIeLen, &dot11WPAIE);
4751 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304752 {
4753 hddLog(LOGE,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304754 FL("Invalid RSN IE: parse status %d"), status);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304755 return -EINVAL;
4756 }
4757
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 // Copy out the encryption and authentication types
4759 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004760 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004762 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 //dot11WPAIE.auth_suite_count
4764 // Just translate the FIRST one
4765 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
4766 //dot11WPAIE.unicast_cipher_count
4767 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
4768 //dot11WPAIE.unicast_cipher_count
4769 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
4770 }
4771 else
4772 {
4773 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004774 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 }
4776 return 0;
4777}
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304778
4779/**
4780 * hdd_set_def_rsne_override() - set default encryption type and auth type
4781 * in profile.
4782 * @roam_profile: pointer to adapter
4783 * @auth_type: pointer to auth type
4784 *
4785 * Set default value of encryption type and auth type in profile to
4786 * search the AP using filter, as in force_rsne_override the RSNIE can be
4787 * currupt and we might not get the proper encryption type and auth type
4788 * while parsing the RSNIE.
4789 *
4790 * Return: void
4791 */
4792static void hdd_set_def_rsne_override(
4793 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
4794{
4795 hddLog( LOG1, FL("Set def values in roam profile"));
4796 roam_profile->MFPCapable = roam_profile->MFPEnabled;
4797 roam_profile->EncryptionType.numEntries = 2;
4798 roam_profile->mcEncryptionType.numEntries = 2;
4799 /* Use the cipher type in the RSN IE */
4800 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
4801 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
4802 roam_profile->mcEncryptionType.encryptionType[0] =
4803 eCSR_ENCRYPT_TYPE_AES;
4804 roam_profile->mcEncryptionType.encryptionType[1] =
4805 eCSR_ENCRYPT_TYPE_TKIP;
4806 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
4807}
4808
Jeff Johnson295189b2012-06-20 16:38:30 -07004809int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4810{
4811 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4812 v_U32_t status = 0;
4813 eCsrEncryptionType RSNEncryptType;
4814 eCsrEncryptionType mcRSNEncryptType;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304815 hdd_context_t *hdd_ctx;
Chet Lanctot186b5732013-03-18 10:26:30 -07004816#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304817 u_int8_t RSNMfpRequired = 0;
4818 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004819#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 struct ether_addr bSsid; // MAC address of assoc peer
4821 // MAC address of assoc peer
4822 // But, this routine is only called when we are NOT associated.
4823 vos_mem_copy(bSsid.ether_addr_octet,
4824 pWextState->roamProfile.BSSIDs.bssid,
4825 sizeof(bSsid.ether_addr_octet));
4826 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
4827 {
4828 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07004829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 else
4831 {
4832 return 0;
4833 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304834
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 // The actual processing may eventually be more extensive than this.
4836 // Right now, just consume any PMKIDs that are sent in by the app.
4837 status = hdd_ProcessGENIE(pAdapter,
4838 &bSsid, // MAC address of assoc peer
4839 &RSNEncryptType,
4840 &mcRSNEncryptType,
4841 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004842#ifdef WLAN_FEATURE_11W
4843 &RSNMfpRequired,
4844 &RSNMfpCapable,
4845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004846 pWextState->WPARSNIE[1]+2,
4847 pWextState->WPARSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304848
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 if (status == 0)
4850 {
4851 // Now copy over all the security attributes you have parsed out
4852 pWextState->roamProfile.EncryptionType.numEntries = 1;
4853 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004854
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
4856 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07004857
Shailender Karmuchi642e9812013-05-30 14:34:49 -07004858 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
4859 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4860 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
4861 {
4862 /*For wpa none supplicant sends the WPA IE with unicast cipher as
4863 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
4864 either AES/TKIP based on group cipher configuration
4865 mentioned in the wpa_supplicant.conf.*/
4866
4867 /*Set the unicast cipher same as multicast cipher*/
4868 pWextState->roamProfile.EncryptionType.encryptionType[0]
4869 = mcRSNEncryptType;
4870 }
4871
Chet Lanctot186b5732013-03-18 10:26:30 -07004872#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304873 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4874 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07004875 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4876 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4877#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304878 hddLog( LOG1,
4879 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4880 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304881 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304883
4884 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4885 if (hdd_ctx->force_rsne_override &&
4886 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
4887 hddLog(LOG1,
4888 FL("Test mode enabled set def Auth and enc type. RSN IE passed in connect req:"));
4889 vos_trace_hex_dump(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4890 pWextState->roamProfile.pRSNReqIE,
4891 pWextState->roamProfile.nRSNReqIELength);
4892
4893 pWextState->roamProfile.force_rsne_override = true;
4894 hddLog(LOG1,
4895 FL("MFPEnabled %d"), pWextState->roamProfile.MFPEnabled);
4896 /*
4897 * Reset MFPEnabled if testmode RSNE passed doesnt have MFPR
4898 * or MFPC bit set
4899 */
4900 if (pWextState->roamProfile.MFPEnabled &&
4901 !(pWextState->roamProfile.MFPRequired ||
4902 pWextState->roamProfile.MFPCapable)) {
4903 hddLog( LOG1,FL("Reset MFPEnabled"));
4904 pWextState->roamProfile.MFPEnabled = 0;
4905 }
4906
4907 /* If parsing failed set the def value for the roam profile */
4908 if (status)
4909 hdd_set_def_rsne_override(&pWextState->roamProfile,
4910 RSNAuthType);
4911 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304912 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004913}
4914int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4915{
4916 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4917 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
4918 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4919 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004920
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 pRoamProfile->AuthType.numEntries = 1;
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304922 hddLog( LOG1,
Abhinav Kumar2184e162019-09-16 15:02:24 +05304923 "%s: authType = %d RSNAuthType %d wpa_versions %d key_mgmt : 0x%x",
Abhinav Kumar487e49e2019-07-22 14:46:18 +05304924 __func__, pHddStaCtx->conn_info.authType, RSNAuthType,
Abhinav Kumar2184e162019-09-16 15:02:24 +05304925 pWextState->wpaVersion, pWextState->authKeyMgmt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004926
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 switch( pHddStaCtx->conn_info.authType)
4928 {
4929 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumar62801ba2018-09-19 12:14:14 +05304930 case eCSR_AUTH_TYPE_AUTOSWITCH:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004931#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 case eCSR_AUTH_TYPE_CCKM_WPA:
4933 case eCSR_AUTH_TYPE_CCKM_RSN:
4934#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004935 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4936
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004938 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004940
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004941#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004942 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4943 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4944 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004945 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004946 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4947 } else
4948 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004949 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004950 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 } else
4952#endif
4953 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4954 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004955 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4956 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4958 == IW_AUTH_KEY_MGMT_PSK) {
4959 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004960 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 }
4964 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004965#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004966 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4967 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4968 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004969 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004970 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004971 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004972 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004973 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004974 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 } else
4976#endif
4977
4978#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004979 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4980 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004982 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004983 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004984 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4986 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004987 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004988 } else
4989#endif
4990
Chet Lanctot186b5732013-03-18 10:26:30 -07004991#ifdef WLAN_FEATURE_11W
4992 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4993 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4994 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304995 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4996 pRoamProfile->AuthType.authType[0] =
4997 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4998 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004999#endif
Abhinav Kumara4282182019-09-13 11:25:59 +05305000 if ((RSNAuthType == eCSR_AUTH_TYPE_SAE) &&
5001 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5002 == IW_AUTH_KEY_MGMT_802_1X)) {
5003 /* SAE case */
5004 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5005 } else
Abhinav Kumar487e49e2019-07-22 14:46:18 +05305006 if ((RSNAuthType == eCSR_AUTH_TYPE_OWE) &&
5007 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5008 == IW_AUTH_KEY_MGMT_802_1X)) {
5009 /* OWE case */
5010 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OWE;
5011 } else
Abhinav Kumar2184e162019-09-16 15:02:24 +05305012 if (RSNAuthType == eCSR_AUTH_TYPE_SAE) {
5013 /* SAE with open authentication case */
5014 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5015 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07005016 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005018 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
5019 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5021 == IW_AUTH_KEY_MGMT_PSK) {
5022 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Abhinav Kumar487e49e2019-07-22 14:46:18 +05305023 } else
5024 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005027 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005028 break;
5029
Jeff Johnson295189b2012-06-20 16:38:30 -07005030 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005031
5032 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 break;
Abhinav Kumar4d44f632019-08-02 13:55:54 +05305034 case eCSR_AUTH_TYPE_SAE:
5035 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
5036 break;
5037
Jeff Johnson295189b2012-06-20 16:38:30 -07005038 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005039
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005040#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08005041 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005042#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005043 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5044 break;
5045 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005046
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005048 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005049
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 EXIT();
5051 return 0;
5052}
5053
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05305054/**
5055 * hdd_rx_fwd_eapol() - forward cached eapol frames
5056 * @vosContext : pointer to vos global context
5057 * @pVosPacket: pointer to vos packet
5058 *
5059 * Return: None
5060 *
5061 */
5062void hdd_assoc_registerFwdEapolCB(void *pContext)
5063{
5064 WLANTL_RegisterFwdEapol(pContext, hdd_rx_fwd_eapol);
5065}
5066
Jeff Johnson295189b2012-06-20 16:38:30 -07005067/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005068
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305069 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07005071 to the CSR roam profile.
5072
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 \param - dev - Pointer to the net device.
5074 - info - Pointer to the iw_request_info.
5075 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005076 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005077 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005078
Jeff Johnson295189b2012-06-20 16:38:30 -07005079 --------------------------------------------------------------------------*/
5080
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305081int __iw_set_essid(struct net_device *dev,
5082 struct iw_request_info *info,
5083 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005084{
5085 v_U32_t status = 0;
5086 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305087 hdd_adapter_t *pAdapter;
5088 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 v_U32_t roamId;
5090 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005091 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305092 tHalHandle hHal;
5093 hdd_station_ctx_t *pHddStaCtx;
5094 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005095
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305097 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5098 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05305100 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305101 "%s: Adapter is NULL",__func__);
5102 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 }
5104
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305105 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5106 ret = wlan_hdd_validate_context(pHddCtx);
5107 if (0 != ret)
5108 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305109 return ret;
5110 }
5111
5112 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5113 if (NULL == hHal)
5114 {
5115 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5116 "%s: Hal Context is NULL",__func__);
5117 return -EINVAL;
5118 }
5119 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5120 if (NULL == pHddStaCtx)
5121 {
5122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5123 "%s: STA Context is NULL",__func__);
5124 return -EINVAL;
5125 }
5126 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5127 if (NULL == pWextState)
5128 {
5129 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5130 "%s: pWextState is NULL",__func__);
5131 return -EINVAL;
5132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
5134 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
5135 return -EBUSY;
5136 }
5137 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
5138 return -EINVAL;
5139 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005140
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305141 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
5142 return -EINVAL;
5143
Agrawal Ashishc407f192017-01-23 17:18:35 +05305144 /*Try disconnecting if already in connected state*/
5145 status = wlan_hdd_try_disconnect(pAdapter);
5146 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 {
Agrawal Ashishc407f192017-01-23 17:18:35 +05305148 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
5149 " connection"));
5150 return -EALREADY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 }
5152 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07005153 /** when cfg80211 defined, wpa_supplicant wext driver uses
5154 zero-length, null-string ssid for force disconnection.
5155 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07005156 driver MUST return success */
5157 if ( 0 == wrqu->essid.length ) {
5158 return 0;
5159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005160
5161 status = hdd_wmm_get_uapsd_mask(pAdapter,
5162 &pWextState->roamProfile.uapsd_mask);
5163 if (VOS_STATUS_SUCCESS != status)
5164 {
5165 pWextState->roamProfile.uapsd_mask = 0;
5166 }
5167 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005168
Jeff Johnson295189b2012-06-20 16:38:30 -07005169 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005170
5171 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
5173 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
5174 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005175
Jeff Johnson295189b2012-06-20 16:38:30 -07005176 //set gen ie
5177 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5178
5179 //set auth
5180 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5181 }
5182#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005183 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 if (pAdapter->wapi_info.nWapiMode)
5185 {
5186 switch (pAdapter->wapi_info.wapiAuthMode)
5187 {
5188 case WAPI_AUTH_MODE_PSK:
5189 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005190 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005191 pRoamProfile->AuthType.numEntries = 1;
5192 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5193 break;
5194 }
5195 case WAPI_AUTH_MODE_CERT:
5196 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005197 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %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_CERTIFICATE;
5200 break;
5201 }
5202 } // End of switch
5203 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5204 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5205 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005206 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 pRoamProfile->EncryptionType.numEntries = 1;
5208 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5209 pRoamProfile->mcEncryptionType.numEntries = 1;
5210 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5211 }
5212 }
5213#endif /* FEATURE_WLAN_WAPI */
5214 /* if previous genIE is not NULL, update AssocIE */
5215 if (0 != pWextState->genIE.length)
5216 {
5217 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
5218 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
5219 pWextState->genIE.length);
5220 pWextState->assocAddIE.length = pWextState->genIE.length;
5221 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5222 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5223
5224 /* clear previous genIE after use it */
5225 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
5226 }
5227
5228 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
5229 pWextState->roamProfile.bWPSAssociation = FALSE;
5230
5231 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5232 pWextState->roamProfile.nAddIEAssocLength))
5233 pWextState->roamProfile.bWPSAssociation = TRUE;
5234
5235
5236 // Disable auto BMPS entry by PMC until DHCP is done
5237 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
5238
Shailender Karmuchia734f332013-04-19 14:02:48 -07005239 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005241
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005242 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
5243 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005244 hdd_select_cbmode(pAdapter,
5245 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
5246 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305247 /*
5248 * Change conn_state to connecting before sme_RoamConnect(),
5249 * because sme_RoamConnect() has a direct path to call
5250 * hdd_smeRoamCallback(), which will change the conn_state
5251 * If direct path, conn_state will be accordingly changed
5252 * to NotConnected or Associated by either
5253 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
5254 * in sme_RoamCallback()
5255 * if sme_RomConnect is to be queued,
5256 * Connecting state will remain until it is completed.
5257 *
5258 * If connection state is not changed,
5259 * connection state will remain in eConnectionState_NotConnected state.
5260 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
5261 * if conn state is eConnectionState_NotConnected.
5262 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5263 * informed of connect result indication which is an issue.
5264 */
5265 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5266 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
5267 {
5268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5269 FL("Set HDD connState to eConnectionState_Connecting"));
5270 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5271 eConnectionState_Connecting);
5272 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005273 status = sme_RoamConnect( hHal,pAdapter->sessionId,
5274 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305275
5276 if ((eHAL_STATUS_SUCCESS != status) &&
5277 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5278 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5279 {
5280 hddLog(VOS_TRACE_LEVEL_ERROR,
5281 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
5282 pAdapter->sessionId, status);
5283 /* change back to NotAssociated */
5284 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5285 eConnectionState_NotConnected);
5286 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005287 pRoamProfile->ChannelInfo.ChannelList = NULL;
5288 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005289
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005290 EXIT();
5291 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005292}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005293
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305294int iw_set_essid(struct net_device *dev,
5295 struct iw_request_info *info,
5296 union iwreq_data *wrqu, char *extra)
5297{
5298 int ret;
5299
5300 vos_ssr_protect(__func__);
5301 ret = __iw_set_essid(dev, info, wrqu, extra);
5302 vos_ssr_unprotect(__func__);
5303
5304 return ret;
5305}
5306
Jeff Johnson295189b2012-06-20 16:38:30 -07005307/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005308
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305309 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005311
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 \param - dev - Pointer to the net device.
5313 - info - Pointer to the iw_request_info.
5314 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005315 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005316 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005317
Jeff Johnson295189b2012-06-20 16:38:30 -07005318 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305319int __iw_get_essid(struct net_device *dev,
5320 struct iw_request_info *info,
5321 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005322{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305323 hdd_adapter_t *pAdapter;
5324 hdd_context_t *pHddCtx;
5325 hdd_wext_state_t *wextBuf;
5326 hdd_station_ctx_t *pHddStaCtx;
5327 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 ENTER();
5330
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305331 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5332 if (NULL == pAdapter)
5333 {
5334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5335 "%s: Adapter is NULL",__func__);
5336 return -EINVAL;
5337 }
5338
5339 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5340 ret = wlan_hdd_validate_context(pHddCtx);
5341 if (0 != ret)
5342 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305343 return ret;
5344 }
5345
5346 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5347 if (NULL == pHddStaCtx)
5348 {
5349 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5350 "%s: STA Context is NULL",__func__);
5351 return -EINVAL;
5352 }
5353
5354 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5355 if (NULL == wextBuf)
5356 {
5357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5358 "%s: wextBuf is NULL",__func__);
5359 return -EINVAL;
5360 }
5361
Jeff Johnson295189b2012-06-20 16:38:30 -07005362 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5363 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5364 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
5365 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
5366 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
5367 {
5368 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5369 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
5370 dwrq->flags = 1;
5371 } else {
5372 memset(extra, 0, dwrq->length);
5373 dwrq->length = 0;
5374 dwrq->flags = 0;
5375 }
5376 EXIT();
5377 return 0;
5378}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305379
5380int iw_get_essid(struct net_device *dev,
5381 struct iw_request_info *info,
5382 struct iw_point *dwrq, char *extra)
5383{
5384 int ret;
5385
5386 vos_ssr_protect(__func__);
5387 ret = __iw_get_essid(dev, info, dwrq, extra);
5388 vos_ssr_unprotect(__func__);
5389
5390 return ret;
5391}
Jeff Johnson295189b2012-06-20 16:38:30 -07005392/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005393
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305394 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005396
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 \param - dev - Pointer to the net device.
5398 - info - Pointer to the iw_request_info.
5399 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005400 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005402
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305404int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
5405 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005406{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305407 hdd_adapter_t *pAdapter;
5408 hdd_context_t *pHddCtx;
5409 hdd_wext_state_t *pWextState;
5410 hdd_station_ctx_t *pHddStaCtx;
5411 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005412 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005413 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305414 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005415
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005417
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305418 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5419 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005420 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5422 "%s: Adapter is NULL",__func__);
5423 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005424 }
5425
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305426 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5427 ret = wlan_hdd_validate_context(pHddCtx);
5428 if (0 != ret)
5429 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305430 return ret;
5431 }
5432
5433 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5434 if (NULL == pHddStaCtx)
5435 {
5436 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5437 "%s: STA Context is NULL",__func__);
5438 return -EINVAL;
5439 }
5440
5441 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5442 if (NULL == pWextState)
5443 {
5444 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5445 "%s: pWextState is NULL",__func__);
5446 return -EINVAL;
5447 }
5448
5449 pRoamProfile = &pWextState->roamProfile;
5450
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 switch(wrqu->param.flags & IW_AUTH_INDEX)
5452 {
5453 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005454
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005456
Jeff Johnson295189b2012-06-20 16:38:30 -07005457 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005458
Jeff Johnson295189b2012-06-20 16:38:30 -07005459 case IW_AUTH_CIPHER_PAIRWISE:
5460 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005461 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5465 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5468 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005469 }
5470
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005472
5473 if( (IW_AUTH_KEY_MGMT_802_1X
5474 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005475 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
5476 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005477 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005478 else
5479 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005480 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005483
5484 if( ( IW_AUTH_KEY_MGMT_802_1X
5485 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005486 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5487 /*Dynamic WEP key*/
5488 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5489 else
5490 /*Static WEP key*/
5491 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005492
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 }
5494 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005497 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 return -EINVAL;
5499 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005500
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 pRoamProfile->EncryptionType.numEntries = 1;
5502 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 break;
5505 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005506 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5508 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5509 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005510
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5512 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5513 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005514
5515 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005516 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5517 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005518
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005520
5521 if( ( IW_AUTH_KEY_MGMT_802_1X
5522 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5523 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5524
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005526
5527 else
5528 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005529 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005530
5531 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
5532 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005534 if( ( IW_AUTH_KEY_MGMT_802_1X
5535 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005536 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5537 {
5538 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5539 }
5540 else
5541 {
5542 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5543 }
5544 }
5545 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005546
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005548 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 return -EINVAL;
5550 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005551
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 pRoamProfile->mcEncryptionType.numEntries = 1;
5553 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
5554 }
5555 break;
5556
5557 case IW_AUTH_80211_AUTH_ALG:
5558 {
5559 /*Save the auth algo here and set auth type to SME Roam profile
5560 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005561 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005563
Jeff Johnson295189b2012-06-20 16:38:30 -07005564 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5565 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5566
5567 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
5568 /*Not supported*/
5569 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5570 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5571 }
5572 break;
5573
5574 case IW_AUTH_KEY_MGMT:
5575 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005576#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005577#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5578 /*Check for CCKM AKM type */
5579 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005580 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
5581 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005582 /* Set the CCKM bit in authKeyMgmt */
5583 /* Right now, this breaks all ref to authKeyMgmt because our
5584 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07005585 */
5586 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5587 /*Set the key management to 802.1X*/
5588 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005589 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5591 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
5592 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5593 /*Save the key management*/
5594 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5595 //pWextState->authKeyMgmt = wrqu->param.value;
5596 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5597 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5598 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5599 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
5600 /*Save the key management anyway*/
5601 pWextState->authKeyMgmt = wrqu->param.value;
5602 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
5603 /*Save the key management*/
5604 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5605 //pWextState->authKeyMgmt = wrqu->param.value;
5606 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5607 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5608 }
5609#else
5610 /*Save the key management*/
5611 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005612#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 }
5614 break;
5615
5616 case IW_AUTH_TKIP_COUNTERMEASURES:
5617 {
5618 if(wrqu->param.value) {
5619 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5620 "Counter Measure started %d", wrqu->param.value);
5621 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
5622 }
5623 else {
5624 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5625 "Counter Measure stopped=%d", wrqu->param.value);
5626 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
5627 }
5628 }
5629 break;
5630 case IW_AUTH_DROP_UNENCRYPTED:
5631 case IW_AUTH_WPA_ENABLED:
5632 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5633 case IW_AUTH_ROAMING_CONTROL:
5634 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005635
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005637
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005638 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 wrqu->param.flags & IW_AUTH_INDEX);
5640 break;
5641 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005642
Jeff Johnson295189b2012-06-20 16:38:30 -07005643 EXIT();
5644 return 0;
5645}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305646
5647int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5648 union iwreq_data *wrqu, char *extra)
5649{
5650 int ret;
5651
5652 vos_ssr_protect(__func__);
5653 ret = __iw_set_auth(dev, info, wrqu, extra);
5654 vos_ssr_unprotect(__func__);
5655
5656 return ret;
5657}
5658
Jeff Johnson295189b2012-06-20 16:38:30 -07005659/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005660
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305661 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005663
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 \param - dev - Pointer to the net device.
5665 - info - Pointer to the iw_request_info.
5666 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005667 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005669
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305671int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5672 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005673{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305674 hdd_adapter_t* pAdapter;
5675 hdd_wext_state_t *pWextState;
5676 tCsrRoamProfile *pRoamProfile;
5677 hdd_context_t *pHddCtx;
5678 int ret = 0;
5679
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005681
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305682 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5683 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005684 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5686 "%s: Adapter is NULL",__func__);
5687 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005688 }
5689
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305690 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5691 ret = wlan_hdd_validate_context(pHddCtx);
5692 if (0 != ret)
5693 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305694 return ret;
5695 }
5696
5697 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5698 if (NULL == pWextState)
5699 {
5700 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5701 "%s: pWextState is NULL",__func__);
5702 return -EINVAL;
5703 }
5704 pRoamProfile = &pWextState->roamProfile;
5705
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 switch(pRoamProfile->negotiatedAuthType)
5707 {
5708 case eCSR_AUTH_TYPE_WPA_NONE:
5709 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5710 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5711 break;
5712 case eCSR_AUTH_TYPE_WPA:
5713 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5714 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5715 break;
5716#ifdef WLAN_FEATURE_VOWIFI_11R
5717 case eCSR_AUTH_TYPE_FT_RSN:
5718#endif
5719 case eCSR_AUTH_TYPE_RSN:
5720 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5721 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5722 break;
5723 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5724 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5725 break;
5726 case eCSR_AUTH_TYPE_SHARED_KEY:
5727 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5728 break;
5729 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005730 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5732 break;
5733 case eCSR_AUTH_TYPE_AUTOSWITCH:
5734 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5735 break;
5736 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305737 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5739 return -EIO;
5740#ifdef WLAN_FEATURE_VOWIFI_11R
5741 case eCSR_AUTH_TYPE_FT_RSN_PSK:
5742#endif
5743 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07005744#ifdef WLAN_FEATURE_11W
5745 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05305746 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07005747#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05305748 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5750 return -EIO;
5751 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305752 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5754 return -EIO;
5755 }
5756 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
5757 {
5758 switch(pRoamProfile->negotiatedUCEncryptionType)
5759 {
5760 case eCSR_ENCRYPT_TYPE_NONE:
5761 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5762 break;
5763 case eCSR_ENCRYPT_TYPE_WEP40:
5764 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5765 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5766 break;
5767 case eCSR_ENCRYPT_TYPE_TKIP:
5768 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5769 break;
5770 case eCSR_ENCRYPT_TYPE_WEP104:
5771 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5772 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5773 break;
5774 case eCSR_ENCRYPT_TYPE_AES:
5775 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5776 break;
5777 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305778 hddLog(LOG1, "%s called with unknown auth type %d ",
5779 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 return -EIO;
5781 }
5782 }
5783
Shailender Karmuchia734f332013-04-19 14:02:48 -07005784 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07005785 {
5786 switch(pRoamProfile->negotiatedMCEncryptionType)
5787 {
5788 case eCSR_ENCRYPT_TYPE_NONE:
5789 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5790 break;
5791 case eCSR_ENCRYPT_TYPE_WEP40:
5792 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5793 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5794 break;
5795 case eCSR_ENCRYPT_TYPE_TKIP:
5796 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5797 break;
5798 case eCSR_ENCRYPT_TYPE_WEP104:
5799 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5800 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5801 break;
5802 case eCSR_ENCRYPT_TYPE_AES:
5803 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5804 break;
5805 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305806 hddLog(LOG1, "%s called with unknown auth type %d ",
5807 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 return -EIO;
5809 }
5810 }
5811
5812 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005813 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 EXIT();
5815 return 0;
5816}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305817
5818int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5819 union iwreq_data *wrqu,char *extra)
5820{
5821 int ret;
5822
5823 vos_ssr_protect(__func__);
5824 ret = __iw_get_auth(dev, info, wrqu, extra);
5825 vos_ssr_unprotect(__func__);
5826
5827 return ret;
5828}
5829
Jeff Johnson295189b2012-06-20 16:38:30 -07005830/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005831
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305832 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07005833 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005835
Jeff Johnson295189b2012-06-20 16:38:30 -07005836 \param - dev - Pointer to the net device.
5837 - info - Pointer to the iw_request_info.
5838 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005839 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005841
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305843int __iw_set_ap_address(struct net_device *dev,
5844 struct iw_request_info *info,
5845 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005846{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305847 hdd_station_ctx_t *pHddStaCtx;
5848 hdd_adapter_t *pAdapter;
5849 hdd_context_t *pHddCtx;
5850 v_U8_t *pMacAddress = NULL;
5851 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305852
Jeff Johnson295189b2012-06-20 16:38:30 -07005853 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305854
5855 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5856 if (NULL == pAdapter)
5857 {
5858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5859 "%s: Adapter is NULL", __func__);
5860 return -EINVAL;
5861 }
5862 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5863 ret = wlan_hdd_validate_context(pHddCtx);
5864 if (0 != ret)
5865 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305866 return ret;
5867 }
5868 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5869 if (NULL == pHddStaCtx)
5870 {
5871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5872 "%s: pHddStaCtx is NULL", __func__);
5873 return -EINVAL;
5874 }
5875
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08005877 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
5878 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07005880
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305881 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 return 0;
5883}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305884
5885int iw_set_ap_address(struct net_device *dev,
5886 struct iw_request_info *info,
5887 union iwreq_data *wrqu, char *extra)
5888{
5889 int ret;
5890
5891 vos_ssr_protect(__func__);
5892 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5893 vos_ssr_unprotect(__func__);
5894
5895 return ret;
5896}
5897
Jeff Johnson295189b2012-06-20 16:38:30 -07005898/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005899
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305900 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 This function returns the BSSID to the wpa_supplicant
5902 \param - dev - Pointer to the net device.
5903 - info - Pointer to the iw_request_info.
5904 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005905 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005906 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005907
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305909int __iw_get_ap_address(struct net_device *dev,
5910 struct iw_request_info *info,
5911 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005912{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305913 hdd_station_ctx_t *pHddStaCtx;
5914 hdd_adapter_t *pAdapter;
5915 hdd_context_t *pHddCtx;
5916 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305917
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 ENTER();
5919
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305920 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5921 if (NULL == pAdapter)
5922 {
5923 hddLog(VOS_TRACE_LEVEL_ERROR,
5924 "%s: Adapter is NULL", __func__);
5925 return -EINVAL;
5926 }
5927 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5928 ret = wlan_hdd_validate_context(pHddCtx);
5929 if (0 != ret)
5930 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305931 return ret;
5932 }
5933 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5934 if (NULL == pHddStaCtx)
5935 {
5936 hddLog(VOS_TRACE_LEVEL_ERROR,
5937 "%s: pHddStaCtx is NULL", __func__);
5938 return -EINVAL;
5939 }
5940
Jeff Johnson295189b2012-06-20 16:38:30 -07005941 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
5942 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
5943 {
Jeff Johnson4416a782013-03-25 14:17:50 -07005944 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 }
5946 else
5947 {
5948 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
5949 }
5950 EXIT();
5951 return 0;
5952}
Jeff Johnsond13512a2012-07-17 11:42:19 -07005953
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305954int iw_get_ap_address(struct net_device *dev,
5955 struct iw_request_info *info,
5956 union iwreq_data *wrqu, char *extra)
5957{
5958 int ret;
5959
5960 vos_ssr_protect(__func__);
5961 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5962 vos_ssr_unprotect(__func__);
5963
5964 return ret;
5965}
5966
Chet Lanctot186b5732013-03-18 10:26:30 -07005967#ifdef WLAN_FEATURE_11W
5968/**---------------------------------------------------------------------------
5969
5970 \brief hdd_indicateUnprotMgmtFrame -
5971 This function forwards the unprotected management frame to the supplicant
5972 \param - pAdapter - Pointer to HDD adapter
5973 - nFrameLength - Length of the unprotected frame being passed
5974 - pbFrames - Pointer to the frame buffer
5975 - frameType - 802.11 frame type
5976 \return - nothing
5977
5978 --------------------------------------------------------------------------*/
5979void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5980 tANI_U32 nFrameLength,
5981 tANI_U8* pbFrames,
5982 tANI_U8 frameType )
5983{
5984 tANI_U8 type = 0;
5985 tANI_U8 subType = 0;
5986
5987 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5988 __func__, frameType, nFrameLength);
5989
5990 /* Sanity Checks */
5991 if (NULL == pAdapter)
5992 {
5993 hddLog( LOGE, FL("pAdapter is NULL"));
5994 return;
5995 }
5996
5997 if (NULL == pAdapter->dev)
5998 {
5999 hddLog( LOGE, FL("pAdapter->dev is NULL"));
6000 return;
6001 }
6002
6003 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
6004 {
6005 hddLog( LOGE, FL("pAdapter has invalid magic"));
6006 return;
6007 }
6008
6009 if( !nFrameLength )
6010 {
6011 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
6012 return;
6013 }
6014
6015 if (NULL == pbFrames) {
6016 hddLog( LOGE, FL("pbFrames is NULL"));
6017 return;
6018 }
6019
6020 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
6021 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
6022
6023 /* Get pAdapter from Destination mac address of the frame */
6024 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
6025 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306026#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
6027 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
6028#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006029 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306030#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006031 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
6032 }
6033 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
6034 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306035#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
6036 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
6037#else
Chet Lanctot186b5732013-03-18 10:26:30 -07006038 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05306039#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07006040 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
6041 }
6042 else
6043 {
6044 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
6045 return;
6046 }
6047}
6048#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006049
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006050#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006051void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
6052 tANI_U8 state,
6053 tANI_U16 measInterval )
6054{
6055 union iwreq_data wrqu;
6056 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006057 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006058
6059 if (NULL == pAdapter)
6060 return;
6061
6062 // create the event
6063 memset(&wrqu, '\0', sizeof(wrqu));
6064 memset(buf, '\0', sizeof(buf));
6065
6066 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
6067 tid, state, measInterval);
6068
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006069 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006070
6071 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006072 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006073 // send the event
6074 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6075}
6076
6077void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
6078{
6079 union iwreq_data wrqu;
6080 char buf[IW_CUSTOM_MAX + 1];
6081 char *pos = buf;
6082 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6083
6084 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6085 return;
6086
6087 // create the event
6088 memset(&wrqu, '\0', sizeof(wrqu));
6089 memset(buf, '\0', sizeof(buf));
6090
6091 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306092 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
6093 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
6094 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
6095 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006096
6097 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
6098 pos += nBytes;
6099 freeBytes -= nBytes;
6100
6101 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
6102 pos += WNI_CFG_BSSID_LEN;
6103 freeBytes -= WNI_CFG_BSSID_LEN;
6104
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006105 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
6106 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006107
6108 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006109 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006110
6111 // send the event
6112 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6113}
6114
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006115void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006116{
6117 union iwreq_data wrqu;
6118 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006119 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006120
6121 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6122 return;
6123
6124 // create the event
6125 memset(&wrqu, '\0', sizeof(wrqu));
6126 memset(buf, '\0', sizeof(buf));
6127
6128 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
6129
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006130 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006131
6132 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006133 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006134
6135 // send the event
6136 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6137}
6138
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006139void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
6140 const tANI_U16 measurementToken,
6141 const tANI_BOOLEAN flag,
6142 const tANI_U8 numBss)
6143{
6144 union iwreq_data wrqu;
6145 char buf[IW_CUSTOM_MAX];
6146 char *pos = buf;
6147 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6148
6149 memset(&wrqu, '\0', sizeof(wrqu));
6150 memset(buf, '\0', sizeof(buf));
6151
6152 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
6153 numBss);
6154
6155 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
6156 flag, numBss);
6157
6158 wrqu.data.pointer = buf;
6159 wrqu.data.length = nBytes;
6160 // send the event
6161 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6162}
6163
6164
6165static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006166 const tCsrRoamInfo *pRoamInfo)
6167{
6168 union iwreq_data wrqu;
6169 char buf[IW_CUSTOM_MAX + 1];
6170 char *pos = buf;
6171 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6172 tANI_U8 i = 0, len = 0;
6173 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
6174 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006175 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
6176 tANI_U8 ieLenByte = 1;
6177 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
6178#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006179
6180 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6181 return;
6182
6183 /* Custom event can pass maximum of 256 bytes of data,
6184 based on the IE len we need to identify how many BSS info can
6185 be filled in to custom event data */
6186 /*
6187 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
6188 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
6189 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
6190 */
6191
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006192 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006193 {
6194 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
6195 /* If the measurement is none and no scan results found,
6196 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006197 hdd_indicateEseBcnReportNoResults(pAdapter,
6198 pRoamInfo->pEseBcnReportRsp->measurementToken,
6199 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006200 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006201 }
6202 else
6203 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006204 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006205 {
6206 memset(&wrqu, '\0', sizeof(wrqu));
6207 memset(buf, '\0', sizeof(buf));
6208 tot_bcn_ieLen = 0;
6209 sendBss = 0;
6210 pos = buf;
6211 freeBytes = IW_CUSTOM_MAX;
6212
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006213 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006214 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006215 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
6216 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006217 {
6218 break;
6219 }
6220 tot_bcn_ieLen += len;
6221 sendBss++;
6222 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
6223 "IeLength(%d) Length of Ie(%d) totLen(%d)",
6224 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006225 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006226 tot_bcn_ieLen);
6227 }
6228
6229 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
6230 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006231 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6232 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006233
6234 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006235 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6236 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006237 pos += nBytes;
6238 freeBytes -= nBytes;
6239
6240 /* Copy total Beacon report data length */
6241 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
6242 pos += sizeof(tot_bcn_ieLen);
6243 freeBytes -= sizeof(tot_bcn_ieLen);
6244
6245 for (i = 0; i < sendBss; i++)
6246 {
6247 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306248 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
6249 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006250 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006251 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
6252 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
6253 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
6254 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
6255 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
6256 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
6257 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
6258 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
6259 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
6260 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
6261 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
6262 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
6263 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
6264 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
6265 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
6266 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006267
6268 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006269 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
6270 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006271 pos += len;
6272 freeBytes -= len;
6273
6274 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006275 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006276 vos_mem_copy(pos, (char*)&len, sizeof(len));
6277 pos += sizeof(len);
6278 freeBytes -= sizeof(len);
6279
6280 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006281 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006282 pos += len;
6283 freeBytes -= len;
6284 }
6285
6286 wrqu.data.pointer = buf;
6287 wrqu.data.length = strlen(buf);
6288
6289 // send the event
6290 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6291 lastSent += sendBss;
6292 }
6293 }
6294}
6295
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006296#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006297
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306298hdd_adapter_t *hdd_get_sta_connection_in_progress(hdd_context_t *hdd_ctx)
6299{
6300 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
6301 hdd_adapter_t *adapter = NULL;
6302 VOS_STATUS status;
6303 hdd_station_ctx_t *hdd_sta_ctx;
6304
6305 if (!hdd_ctx) {
6306 hddLog(LOGE, FL("HDD context is NULL"));
6307 return NULL;
6308 }
6309
6310 status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
6311 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
6312 adapter = adapter_node->pAdapter;
6313 if (!adapter)
6314 goto end;
6315
6316 if ((WLAN_HDD_INFRA_STATION == adapter->device_mode) ||
6317 (WLAN_HDD_P2P_CLIENT == adapter->device_mode) ||
6318 (WLAN_HDD_P2P_DEVICE == adapter->device_mode)) {
6319 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6320 if (eConnectionState_Connecting ==
6321 hdd_sta_ctx->conn_info.connState) {
6322 hddLog(LOG1, FL("session_id %d: Connection is in progress"),
6323 adapter->sessionId);
6324 return adapter;
6325 } else if ((eConnectionState_Associated ==
6326 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +05306327 sme_is_sta_key_exchange_in_progress(
6328 hdd_ctx->hHal, adapter->sessionId)) {
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306329 hddLog(LOG1, FL("session_id %d: Key exchange is in progress"),
6330 adapter->sessionId);
6331 return adapter;
6332 }
6333 }
6334end:
6335 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
6336 adapter_node = next;
6337 }
6338 return NULL;
6339}
6340