blob: adf6ce73090d99c81c652d56263843906ab7844a [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07002 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all
7 * copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 * PERFORMANCE OF THIS SOFTWARE.
17 */
18
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080019/**
20 * DOC: wlan_hdd_assoc.c
21 *
22 * WLAN Host Device Driver implementation
23 *
24 */
25
26#include "wlan_hdd_includes.h"
27#include <ani_global.h>
28#include "dot11f.h"
29#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053030#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080031#include <linux/ieee80211.h>
32#include <linux/wireless.h>
33#include <linux/etherdevice.h>
34#include <net/cfg80211.h>
35#include "wlan_hdd_cfg80211.h"
36#include "csr_inside_api.h"
37#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080038#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080039#include "sme_api.h"
40#include "wlan_hdd_hostapd.h"
Jeff Johnson8bb61112018-03-31 13:33:54 -070041#include <wlan_hdd_green_ap.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080042#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070043#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070044#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080045#include <cds_sched.h>
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -080046#include "wlan_policy_mgr_api.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053047#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070049#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070050#include <cdp_txrx_cmn.h>
51#include <cdp_txrx_flow_ctrl_legacy.h>
52#include <cdp_txrx_peer_ops.h>
53#include <cdp_txrx_misc.h>
Kabilan Kannan256e3182017-05-02 16:02:37 -070054#include <cdp_txrx_ctrl.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053055#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080056#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080057#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053058#include "wlan_pmo_ucfg_api.h"
Yu Wang000dc2f2017-05-26 17:38:48 +080059#include "wlan_hdd_tsf.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070060#include "wlan_utility.h"
Wu Gaoc02785d2017-09-07 18:17:13 +080061#include "wlan_p2p_ucfg_api.h"
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +053062#include "wlan_ipa_ucfg_api.h"
Qiwei Cai3719efe2018-06-11 21:09:29 +080063#include "wlan_hdd_stats.h"
Paul Zhangcb573e02018-11-06 10:37:16 +080064#include "wlan_hdd_scan.h"
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -080065#include "wlan_crypto_global_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
Alok Kumarb64650c2018-03-23 17:05:11 +053067#include "wlan_hdd_nud_tracking.h"
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -070068#include <wlan_cfg80211_crypto.h>
69#include <wlan_crypto_global_api.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070/* These are needed to recognize WPA and RSN suite types */
71#define HDD_WPA_OUI_SIZE 4
72#define HDD_RSN_OUI_SIZE 4
73uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
74uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
75uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
76uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
77uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
78uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
79
80#ifdef FEATURE_WLAN_ESE
81/* CCKM */
82uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
83/* CCKM */
84uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
85#endif /* FEATURE_WLAN_ESE */
86
87/* group cipher */
88uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
89
90/* WEP-40 or RSN */
91uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
92
93/* TKIP or RSN-PSK */
94uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
95
96/* Reserved */
97uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
98
99/* AES-CCMP */
100uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
101
102/* WEP-104 */
103uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
104
105#ifdef WLAN_FEATURE_11W
106/* RSN-PSK-SHA256 */
107uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
108
109/* RSN-8021X-SHA256 */
110uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
111#endif
112
Mukul Sharma05504ac2017-06-08 12:35:53 +0530113/* AES-GCMP-128 */
114uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
115
116/* AES-GCMP-256 */
117uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +0530118#ifdef WLAN_FEATURE_FILS_SK
119uint8_t ccp_rsn_oui_0e[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0E};
120uint8_t ccp_rsn_oui_0f[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0F};
121uint8_t ccp_rsn_oui_10[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x10};
122uint8_t ccp_rsn_oui_11[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x11};
123#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +0530124uint8_t ccp_rsn_oui_12[HDD_RSN_OUI_SIZE] = {0x50, 0x6F, 0x9A, 0x02};
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +0530125uint8_t ccp_rsn_oui_0b[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0B};
126uint8_t ccp_rsn_oui_0c[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0C};
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +0530127/* FT-SUITE-B AKM */
128uint8_t ccp_rsn_oui_0d[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0D};
Mukul Sharma05504ac2017-06-08 12:35:53 +0530129
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +0530130/* OWE https://tools.ietf.org/html/rfc8110 */
131uint8_t ccp_rsn_oui_18[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x12};
132
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530133#ifdef WLAN_FEATURE_SAE
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +0530134/* SAE AKM */
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530135uint8_t ccp_rsn_oui_80[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x08};
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +0530136/* FT SAE AKM */
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530137uint8_t ccp_rsn_oui_90[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x09};
138#endif
Srinivas Dasarib328f1a2018-12-18 17:45:06 +0530139static const
140u8 ccp_rsn_oui_13[HDD_RSN_OUI_SIZE] = {0x50, 0x6F, 0x9A, 0x01};
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142/* Offset where the EID-Len-IE, start. */
143#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
144#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146#define HDD_PEER_AUTHORIZE_WAIT 10
147
148/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700149 * beacon_filter_table - table of IEs used for beacon filtering
150 */
151static const int beacon_filter_table[] = {
Srinivas Girigowda61771262019-04-01 11:55:19 -0700152 WLAN_ELEMID_DSPARMS,
153 WLAN_ELEMID_ERP,
154 WLAN_ELEMID_EDCAPARMS,
155 WLAN_ELEMID_QOS_CAPABILITY,
156 WLAN_ELEMID_HTINFO_ANA,
157 WLAN_ELEMID_OP_MODE_NOTIFY,
158 WLAN_ELEMID_VHTOP,
Krunal Sonib7f20432017-04-27 13:01:02 -0700159#ifdef WLAN_FEATURE_11AX_BSS_COLOR
160 /*
161 * EID: 221 vendor IE is being used temporarily by 11AX
162 * bss-color-change IE till it gets any fixed number. This
163 * vendor EID needs to be replaced with bss-color-change IE
164 * number.
165 */
Srinivas Girigowda61771262019-04-01 11:55:19 -0700166 WLAN_ELEMID_VENDOR,
Krunal Sonib7f20432017-04-27 13:01:02 -0700167#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700168};
169
Padma, Santhosh Kumareb90a552018-01-16 19:41:58 +0530170#if defined(WLAN_FEATURE_SAE) && \
171 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
172/**
173 * wlan_hdd_sae_callback() - Sends SAE info to supplicant
174 * @adapter: pointer adapter context
175 * @roam_info: pointer to roam info
176 *
177 * This API is used to send required SAE info to trigger SAE in supplicant.
178 *
179 * Return: None
180 */
181static void wlan_hdd_sae_callback(struct hdd_adapter *adapter,
182 struct csr_roam_info *roam_info)
183{
184 struct hdd_context *hdd_ctx = adapter->hdd_ctx;
185 int flags;
186 struct sir_sae_info *sae_info = roam_info->sae_info;
187 struct cfg80211_external_auth_params params = {0};
188
189 if (wlan_hdd_validate_context(hdd_ctx))
190 return;
191
192 if (!sae_info) {
193 hdd_err("SAE info in NULL");
194 return;
195 }
196
197 flags = cds_get_gfp_flags();
198
199 params.key_mgmt_suite = 0x00;
200 params.key_mgmt_suite |= 0x0F << 8;
201 params.key_mgmt_suite |= 0xAC << 16;
202 params.key_mgmt_suite |= 0x8 << 24;
203
204 params.action = NL80211_EXTERNAL_AUTH_START;
205 qdf_mem_copy(params.bssid, sae_info->peer_mac_addr.bytes,
206 QDF_MAC_ADDR_SIZE);
207 qdf_mem_copy(params.ssid.ssid, sae_info->ssid.ssId,
208 sae_info->ssid.length);
209 params.ssid.ssid_len = sae_info->ssid.length;
210
211 cfg80211_external_auth_request(adapter->dev, &params, flags);
212 hdd_debug("SAE: sent cmd");
213}
214#else
215static inline void wlan_hdd_sae_callback(struct hdd_adapter *adapter,
216 struct csr_roam_info *roam_info)
217{ }
218#endif
219
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700220/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800221 * hdd_conn_set_authenticated() - set authentication state
Jeff Johnsonba388342017-10-02 13:31:01 -0700222 * @adapter: pointer to the adapter
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530223 * @auth_state: authentication state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 *
225 * This function updates the global HDD station context
226 * authentication state.
227 *
228 * Return: none
229 */
230static void
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530231hdd_conn_set_authenticated(struct hdd_adapter *adapter, uint8_t auth_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800232{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700233 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530234 char *auth_time;
235 uint32_t time_buffer_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800236
237 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700238 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Jeff Johnson457c2422019-02-27 13:56:04 -0800239 sta_ctx->conn_info.is_authenticated, auth_state);
240 sta_ctx->conn_info.is_authenticated = auth_state;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530241
242 auth_time = sta_ctx->conn_info.auth_time;
243 time_buffer_size = sizeof(sta_ctx->conn_info.auth_time);
244
245 if (auth_state)
246 qdf_get_time_of_the_day_in_hr_min_sec_usec(auth_time,
247 time_buffer_size);
248 else
hangtian127c9532019-01-12 13:29:07 +0800249 qdf_mem_zero(auth_time, time_buffer_size);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530250
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800251}
252
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700253void hdd_conn_set_connection_state(struct hdd_adapter *adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700254 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800255{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700256 struct hdd_station_ctx *hdd_sta_ctx =
257 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530258 char *connect_time;
259 uint32_t time_buffer_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260
261 /* save the new connection state */
Jun Wang92cd8362018-07-27 16:52:47 +0800262 hdd_debug("Changed conn state from old:%d to new:%d for dev %s",
Jeff Johnsone7951512019-02-27 10:02:51 -0800263 hdd_sta_ctx->conn_info.conn_state, conn_state,
Jun Wang92cd8362018-07-27 16:52:47 +0800264 adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800265
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700266 hdd_tsf_notify_wlan_state_change(adapter,
Jeff Johnsone7951512019-02-27 10:02:51 -0800267 hdd_sta_ctx->conn_info.conn_state,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700268 conn_state);
Jeff Johnsone7951512019-02-27 10:02:51 -0800269 hdd_sta_ctx->conn_info.conn_state = conn_state;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530270
271 connect_time = hdd_sta_ctx->conn_info.connect_time;
272 time_buffer_size = sizeof(hdd_sta_ctx->conn_info.connect_time);
273 if (conn_state == eConnectionState_Associated)
274 qdf_get_time_of_the_day_in_hr_min_sec_usec(connect_time,
275 time_buffer_size);
276 else
hangtian127c9532019-01-12 13:29:07 +0800277 qdf_mem_zero(connect_time, time_buffer_size);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530278
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279}
280
281/**
282 * hdd_conn_get_connection_state() - get connection state
Jeff Johnsonba388342017-10-02 13:31:01 -0700283 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800284 * @pConnState: pointer to connection state
285 *
286 * This function updates the global HDD station context connection state.
287 *
288 * Return: true if (Infra Associated or IBSS Connected)
289 * and sets output parameter pConnState;
290 * false otherwise
291 */
Jeff Johnson435e1b82017-10-07 14:13:10 -0700292static inline bool
293hdd_conn_get_connection_state(struct hdd_station_ctx *sta_ctx,
Dustin Brown0127a732018-07-19 14:06:34 -0700294 eConnectionState *out_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800295{
Jeff Johnsone7951512019-02-27 10:02:51 -0800296 eConnectionState state = sta_ctx->conn_info.conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800297
Dustin Brown0127a732018-07-19 14:06:34 -0700298 if (out_state)
299 *out_state = state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300
Dustin Brown0127a732018-07-19 14:06:34 -0700301 switch (state) {
302 case eConnectionState_Associated:
303 case eConnectionState_IbssConnected:
304 case eConnectionState_IbssDisconnected:
305 case eConnectionState_NdiConnected:
306 return true;
307 default:
308 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800309 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800310}
311
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700312bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313{
Jeff Johnsone7951512019-02-27 10:02:51 -0800314 return hdd_sta_ctx->conn_info.conn_state ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800315 eConnectionState_Connecting;
316}
317
Jeff Johnsond377dce2017-10-04 10:32:42 -0700318bool hdd_conn_is_connected(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800319{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700320 return hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800321}
322
Dustin Brown0127a732018-07-19 14:06:34 -0700323bool hdd_adapter_is_connected_sta(struct hdd_adapter *adapter)
324{
325 switch (adapter->device_mode) {
326 case QDF_STA_MODE:
327 case QDF_P2P_CLIENT_MODE:
328 case QDF_NDI_MODE:
329 return hdd_conn_is_connected(&adapter->session.station);
330 default:
331 return false;
332 }
333}
334
Jeff Johnsond377dce2017-10-04 10:32:42 -0700335enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800336{
337 uint8_t staChannel = 0;
338
Jeff Johnsone7951512019-02-27 10:02:51 -0800339 if (eConnectionState_Associated == sta_ctx->conn_info.conn_state)
Jeff Johnson8626e932019-02-27 18:35:22 -0800340 staChannel = sta_ctx->conn_info.channel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341
342 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700343 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700345 return BAND_5G;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800346 else /* If station is not connected return as BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700347 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800348}
349
350/**
351 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
Jeff Johnsond377dce2017-10-04 10:32:42 -0700352 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800353 * @pConnectedCipherAlgo: pointer to connected cipher algo
354 *
355 * Return: false if any errors encountered, true otherwise
356 */
357static inline bool
Jeff Johnsond377dce2017-10-04 10:32:42 -0700358hdd_conn_get_connected_cipher_algo(struct hdd_station_ctx *sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800359 eCsrEncryptionType *pConnectedCipherAlgo)
360{
Jeff Johnson389e16b2018-05-05 23:32:55 -0700361 bool connected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362
Jeff Johnson389e16b2018-05-05 23:32:55 -0700363 connected = hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800364
365 if (pConnectedCipherAlgo)
Jeff Johnsonb1959842019-02-27 13:04:04 -0800366 *pConnectedCipherAlgo = sta_ctx->conn_info.uc_encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367
Jeff Johnson389e16b2018-05-05 23:32:55 -0700368 return connected;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800369}
370
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530371struct hdd_adapter *hdd_get_sta_connection_in_progress(
372 struct hdd_context *hdd_ctx)
373{
374 struct hdd_adapter *adapter = NULL;
375 struct hdd_station_ctx *hdd_sta_ctx;
376
377 if (!hdd_ctx) {
378 hdd_err("HDD context is NULL");
379 return NULL;
380 }
381
382 hdd_for_each_adapter(hdd_ctx, adapter) {
383 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
384 if ((QDF_STA_MODE == adapter->device_mode) ||
385 (QDF_P2P_CLIENT_MODE == adapter->device_mode) ||
386 (QDF_P2P_DEVICE_MODE == adapter->device_mode)) {
387 if (eConnectionState_Connecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -0800388 hdd_sta_ctx->conn_info.conn_state) {
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530389 hdd_debug("vdev_id %d: Connection is in progress",
Jeff Johnson1abc5662019-02-04 14:27:02 -0800390 adapter->vdev_id);
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530391 return adapter;
392 } else if ((eConnectionState_Associated ==
Jeff Johnsone7951512019-02-27 10:02:51 -0800393 hdd_sta_ctx->conn_info.conn_state) &&
Vignesh Viswanathan0a569292018-02-14 15:34:47 +0530394 sme_is_sta_key_exchange_in_progress(
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700395 hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -0800396 adapter->vdev_id)) {
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530397 hdd_debug("vdev_id %d: Key exchange is in progress",
Jeff Johnson1abc5662019-02-04 14:27:02 -0800398 adapter->vdev_id);
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530399 return adapter;
400 }
401 }
402 }
403 return NULL;
404}
405
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530406void hdd_abort_ongoing_sta_connection(struct hdd_context *hdd_ctx)
407{
408 struct hdd_adapter *sta_adapter;
409 QDF_STATUS status;
410
411 sta_adapter = hdd_get_sta_connection_in_progress(hdd_ctx);
412 if (sta_adapter) {
413 hdd_debug("Disconnecting STA on vdev: %d",
Jeff Johnson1abc5662019-02-04 14:27:02 -0800414 sta_adapter->vdev_id);
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530415 status = wlan_hdd_disconnect(sta_adapter,
416 eCSR_DISCONNECT_REASON_DEAUTH);
417 if (QDF_IS_STATUS_ERROR(status)) {
418 hdd_err("wlan_hdd_disconnect failed, status: %d",
419 status);
420 }
421 }
422}
423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800424/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700425 * hdd_remove_beacon_filter() - remove beacon filter
426 * @adapter: Pointer to the hdd adapter
427 *
428 * Return: 0 on success and errno on failure
429 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700430static int hdd_remove_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700431{
432 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700433 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700434
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700435 status = sme_remove_beacon_filter(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -0800436 adapter->vdev_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700437 if (!QDF_IS_STATUS_SUCCESS(status)) {
438 hdd_err("sme_remove_beacon_filter() failed");
439 return -EFAULT;
440 }
441
442 return 0;
443}
444
445/**
446 * hdd_add_beacon_filter() - add beacon filter
447 * @adapter: Pointer to the hdd adapter
448 *
449 * Return: 0 on success and errno on failure
450 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700451static int hdd_add_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700452{
453 int i;
454 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
455 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700456 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700457
458 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530459 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700460 (unsigned long int *)ie_map);
461
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700462 status = sme_add_beacon_filter(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -0800463 adapter->vdev_id, ie_map);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700464 if (!QDF_IS_STATUS_SUCCESS(status)) {
465 hdd_err("sme_add_beacon_filter() failed");
466 return -EFAULT;
467 }
468 return 0;
469}
470
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530471void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
472 tDot11fIEHTCaps *roam_ht_cap)
473
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530474{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530475 uint32_t i, temp_ht_cap;
476
477 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
478
479 if (roam_ht_cap->advCodingCap)
480 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
481 if (roam_ht_cap->supportedChannelWidthSet)
482 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
483 temp_ht_cap = roam_ht_cap->mimoPowerSave &
484 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
485 if (temp_ht_cap)
486 hdd_ht_cap->cap_info |=
487 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
488 if (roam_ht_cap->greenField)
489 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
490 if (roam_ht_cap->shortGI20MHz)
491 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
492 if (roam_ht_cap->shortGI40MHz)
493 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
494 if (roam_ht_cap->txSTBC)
495 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
496 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
497 IEEE80211_HT_CAP_RX_STBC_SHIFT);
498 if (temp_ht_cap)
499 hdd_ht_cap->cap_info |=
500 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
501 if (roam_ht_cap->delayedBA)
502 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
503 if (roam_ht_cap->maximalAMSDUsize)
504 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
505 if (roam_ht_cap->dsssCckMode40MHz)
506 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
507 if (roam_ht_cap->psmp)
508 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
509 if (roam_ht_cap->stbcControlFrame)
510 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
511 if (roam_ht_cap->lsigTXOPProtection)
512 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
513
514 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
515 if (roam_ht_cap->maxRxAMPDUFactor)
516 hdd_ht_cap->ampdu_params_info |=
517 IEEE80211_HT_AMPDU_PARM_FACTOR;
518 temp_ht_cap = roam_ht_cap->mpduDensity &
519 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
520 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
521 if (temp_ht_cap)
522 hdd_ht_cap->ampdu_params_info |=
523 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
524
525 /* 802.11n HT extended capabilities masks */
526 if (roam_ht_cap->pco)
527 hdd_ht_cap->extended_ht_cap_info |=
528 IEEE80211_HT_EXT_CAP_PCO;
529 temp_ht_cap = roam_ht_cap->transitionTime &
530 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
531 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
532 if (temp_ht_cap)
533 hdd_ht_cap->extended_ht_cap_info |=
534 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
535 temp_ht_cap = roam_ht_cap->mcsFeedback &
536 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
537 if (temp_ht_cap)
538 hdd_ht_cap->extended_ht_cap_info |=
539 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
540
541 /* tx_bf_cap_info capabilities */
542 if (roam_ht_cap->txBF)
543 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
544 if (roam_ht_cap->rxStaggeredSounding)
545 hdd_ht_cap->tx_BF_cap_info |=
546 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
547 if (roam_ht_cap->txStaggeredSounding)
548 hdd_ht_cap->tx_BF_cap_info |=
549 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
550 if (roam_ht_cap->rxZLF)
551 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
552 if (roam_ht_cap->txZLF)
553 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
554 if (roam_ht_cap->implicitTxBF)
555 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
556 temp_ht_cap = roam_ht_cap->calibration &
557 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
558 if (temp_ht_cap)
559 hdd_ht_cap->tx_BF_cap_info |=
560 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
561 if (roam_ht_cap->explicitCSITxBF)
562 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
563 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
564 hdd_ht_cap->tx_BF_cap_info |=
565 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
566 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
567 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
568 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
569 if (temp_ht_cap)
570 hdd_ht_cap->tx_BF_cap_info |=
571 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
572 temp_ht_cap =
573 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
574 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
575 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
576 if (temp_ht_cap)
577 hdd_ht_cap->tx_BF_cap_info |=
578 temp_ht_cap <<
579 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
580 temp_ht_cap =
581 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
582 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
583 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
584 if (temp_ht_cap)
585 hdd_ht_cap->tx_BF_cap_info |=
586 temp_ht_cap <<
587 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
588 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
589 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
590 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
591 if (temp_ht_cap)
592 hdd_ht_cap->tx_BF_cap_info |=
593 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
594 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
595 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
596 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
597 if (temp_ht_cap)
598 hdd_ht_cap->tx_BF_cap_info |=
599 temp_ht_cap <<
600 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
601 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
602 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
603 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
604 if (temp_ht_cap)
605 hdd_ht_cap->tx_BF_cap_info |=
606 temp_ht_cap <<
607 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
608
609 /* antenna selection */
610 if (roam_ht_cap->antennaSelection)
611 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
612 if (roam_ht_cap->explicitCSIFeedbackTx)
613 hdd_ht_cap->antenna_selection_info |=
614 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
615 if (roam_ht_cap->antennaIndicesFeedbackTx)
616 hdd_ht_cap->antenna_selection_info |=
617 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
618 if (roam_ht_cap->explicitCSIFeedback)
619 hdd_ht_cap->antenna_selection_info |=
620 ANTENNA_SEL_INFO_EXP_CSI_FB;
621 if (roam_ht_cap->antennaIndicesFeedback)
622 hdd_ht_cap->antenna_selection_info |=
623 ANTENNA_SEL_INFO_ANT_ID_FB;
624 if (roam_ht_cap->rxAS)
625 hdd_ht_cap->antenna_selection_info |=
626 ANTENNA_SEL_INFO_RX_AS;
627 if (roam_ht_cap->txSoundingPPDUs)
628 hdd_ht_cap->antenna_selection_info |=
629 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
630
631 /* mcs data rate */
632 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
633 hdd_ht_cap->mcs.rx_mask[i] =
634 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800635 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530636 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
637 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800638 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530639 roam_ht_cap->supportedMCSSet[12];
640}
641
642#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
643#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
644#define VHT_CAP_RXSTBC_MASK_SHIFT 8
645#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
646#define VHT_CAP_BEAMFORMEE_STS_MASK \
647 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
648#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
649#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
650 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
651#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
652#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
653 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
654#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
655
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530656void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
657 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530658{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530659 uint32_t temp_vht_cap;
660
661 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
662
663 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
664 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
665 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
666 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
667 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800668 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530669 if (roam_vht_cap->supportedChannelWidthSet &
670 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
671 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
672 hdd_vht_cap->vht_cap_info |=
673 temp_vht_cap <<
674 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
675 if (roam_vht_cap->supportedChannelWidthSet &
676 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
677 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
678 hdd_vht_cap->vht_cap_info |=
679 temp_vht_cap <<
680 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800681 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530682 if (roam_vht_cap->ldpcCodingCap)
683 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
684 if (roam_vht_cap->shortGI80MHz)
685 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
686 if (roam_vht_cap->shortGI160and80plus80MHz)
687 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
688 if (roam_vht_cap->txSTBC)
689 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
690 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
691 VHT_CAP_RXSTBC_MASK_SHIFT);
692 if (temp_vht_cap)
693 hdd_vht_cap->vht_cap_info |=
694 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
695 if (roam_vht_cap->suBeamFormerCap)
696 hdd_vht_cap->vht_cap_info |=
697 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
698 if (roam_vht_cap->suBeamformeeCap)
699 hdd_vht_cap->vht_cap_info |=
700 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
701 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
702 (VHT_CAP_BEAMFORMEE_STS_MASK);
703 if (temp_vht_cap)
704 hdd_vht_cap->vht_cap_info |=
705 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
706 temp_vht_cap = roam_vht_cap->numSoundingDim &
707 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
708 if (temp_vht_cap)
709 hdd_vht_cap->vht_cap_info |=
710 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
711 if (roam_vht_cap->muBeamformerCap)
712 hdd_vht_cap->vht_cap_info |=
713 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
714 if (roam_vht_cap->muBeamformeeCap)
715 hdd_vht_cap->vht_cap_info |=
716 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
717 if (roam_vht_cap->vhtTXOPPS)
718 hdd_vht_cap->vht_cap_info |=
719 IEEE80211_VHT_CAP_VHT_TXOP_PS;
720 if (roam_vht_cap->htcVHTCap)
721 hdd_vht_cap->vht_cap_info |=
722 IEEE80211_VHT_CAP_HTC_VHT;
723 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
724 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
725 if (temp_vht_cap)
726 hdd_vht_cap->vht_cap_info |=
727 temp_vht_cap <<
728 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
729 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
730 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
731 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
732 if (temp_vht_cap)
733 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
734 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
735 if (roam_vht_cap->rxAntPattern)
736 hdd_vht_cap->vht_cap_info |=
737 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
738 if (roam_vht_cap->txAntPattern)
739 hdd_vht_cap->vht_cap_info |=
740 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
741 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
742 hdd_vht_cap->supp_mcs.rx_highest =
743 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
744 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
745 hdd_vht_cap->supp_mcs.tx_highest =
746 ((uint16_t)roam_vht_cap->txSupDataRate);
747}
748
749/* ht param */
750#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
751#define HT_PARAM_SERVICE_INT_GRAN 0xe0
752#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
753
754/* operatinon mode */
755#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
756
757/* stbc_param */
758#define HT_STBC_PARAM_MCS 0x007f
759
760/**
761 * hdd_copy_ht_operation()- copy HT operation element from roam info to
762 * hdd station context.
763 * @hdd_sta_ctx: pointer to hdd station context
764 * @roam_info: pointer to roam info
765 *
766 * Return: None
767 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700768static void hdd_copy_ht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800769 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530770{
771 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
772 struct ieee80211_ht_operation *hdd_ht_ops =
773 &hdd_sta_ctx->conn_info.ht_operation;
774 uint32_t i, temp_ht_ops;
775
776 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
777
778 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
779
780 /* HT_PARAMS */
781 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
782 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
783 if (temp_ht_ops)
784 hdd_ht_ops->ht_param |= temp_ht_ops;
785 else
786 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
787 if (roam_ht_ops->recommendedTxWidthSet)
788 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
789 if (roam_ht_ops->rifsMode)
790 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
791 if (roam_ht_ops->controlledAccessOnly)
792 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
793 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
794 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
795 if (temp_ht_ops)
796 hdd_ht_ops->ht_param |= temp_ht_ops <<
797 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
798
799 /* operation mode */
800 temp_ht_ops = roam_ht_ops->opMode &
801 IEEE80211_HT_OP_MODE_PROTECTION;
802 switch (temp_ht_ops) {
803 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
804 hdd_ht_ops->operation_mode |=
805 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
806 break;
807 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
808 hdd_ht_ops->operation_mode |=
809 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
810 break;
811 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
812 hdd_ht_ops->operation_mode |=
813 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
814 break;
815 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
816 default:
817 hdd_ht_ops->operation_mode |=
818 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
819 }
820 if (roam_ht_ops->nonGFDevicesPresent)
821 hdd_ht_ops->operation_mode |=
822 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
823 if (roam_ht_ops->transmitBurstLimit)
824 hdd_ht_ops->operation_mode |=
825 HT_OP_MODE_TX_BURST_LIMIT;
826 if (roam_ht_ops->obssNonHTStaPresent)
827 hdd_ht_ops->operation_mode |=
828 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
829
830 /* stbc_param */
831 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
832 HT_STBC_PARAM_MCS;
833 if (temp_ht_ops)
834 hdd_ht_ops->stbc_param |= temp_ht_ops;
835 if (roam_ht_ops->dualCTSProtection)
836 hdd_ht_ops->stbc_param |=
837 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
838 if (roam_ht_ops->secondaryBeacon)
839 hdd_ht_ops->stbc_param |=
840 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
841 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
842 hdd_ht_ops->stbc_param |=
843 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
844 if (roam_ht_ops->pcoActive)
845 hdd_ht_ops->stbc_param |=
846 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
847 if (roam_ht_ops->pcoPhase)
848 hdd_ht_ops->stbc_param |=
849 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
850
851 /* basic MCs set */
852 for (i = 0; i < 16; ++i)
853 hdd_ht_ops->basic_set[i] =
854 roam_ht_ops->basicMCSSet[i];
855}
856
Dustin Brown8aef46d2017-08-10 15:44:50 -0700857#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
858static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
859 tDot11fIEVHTOperation *roam_ops)
860{
861 ieee_ops->center_freq_seg0_idx = roam_ops->chanCenterFreqSeg1;
862 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg2;
863}
864#else
865static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
866 tDot11fIEVHTOperation *roam_ops)
867{
868 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg1;
869 ieee_ops->center_freq_seg2_idx = roam_ops->chanCenterFreqSeg2;
870}
871#endif /* KERNEL_VERSION(4, 12, 0) */
872
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530873/**
874 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
875 * hdd station context.
876 * @hdd_sta_ctx: pointer to hdd station context
877 * @roam_info: pointer to roam info
878 *
879 * Return: None
880 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700881static void hdd_copy_vht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800882 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530883{
884 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
885 struct ieee80211_vht_operation *hdd_vht_ops =
886 &hdd_sta_ctx->conn_info.vht_operation;
887
888 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
889
890 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
Dustin Brown8aef46d2017-08-10 15:44:50 -0700891 hdd_copy_vht_center_freq(hdd_vht_ops, roam_vht_ops);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530892 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
893}
894
895
896/**
897 * hdd_save_bss_info() - save connection info in hdd sta ctx
898 * @adapter: Pointer to adapter
899 * @roam_info: pointer to roam info
900 *
901 * Return: None
902 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700903static void hdd_save_bss_info(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -0800904 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530905{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700906 struct hdd_station_ctx *hdd_sta_ctx =
907 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530908
909 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
Jeff Johnson8626e932019-02-27 18:35:22 -0800910 hdd_sta_ctx->conn_info.channel);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530911 if (roam_info->vht_caps.present) {
912 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530913 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
914 &roam_info->vht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530915 } else {
916 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
917 }
918 if (roam_info->ht_caps.present) {
919 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530920 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps,
921 &roam_info->ht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530922 } else {
923 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
924 }
925 if (roam_info->reassoc)
926 hdd_sta_ctx->conn_info.roam_count++;
927 if (roam_info->hs20vendor_ie.present) {
928 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
929 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
930 &roam_info->hs20vendor_ie,
931 sizeof(roam_info->hs20vendor_ie));
932 } else {
933 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
934 }
935 if (roam_info->ht_operation.present) {
936 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
937 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
938 } else {
939 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
940 }
941 if (roam_info->vht_operation.present) {
942 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
943 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
944 } else {
945 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
946 }
Ashish Kumar Dhanotiya36d19b02018-02-22 00:59:49 +0530947 /* Cache last connection info */
948 qdf_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +0530949 sizeof(hdd_sta_ctx->cache_conn_info));
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530950}
951
952/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 * hdd_conn_save_connect_info() - save current connection information
Jeff Johnsonba388342017-10-02 13:31:01 -0700954 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -0700955 * @roam_info: pointer to roam info
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800956 * @bss_type: bss type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800957 *
958 * Return: none
959 */
960static void
Jeff Johnson172237b2017-11-07 15:32:59 -0800961hdd_conn_save_connect_info(struct hdd_adapter *adapter,
962 struct csr_roam_info *roam_info,
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800963 eCsrRoamBssType bss_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700965 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson1627e752019-03-23 12:33:37 -0700966 eCsrEncryptionType encrypt_type = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
Jeff Johnsonfd060852017-10-04 10:50:51 -0700968 QDF_ASSERT(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800969
Jeff Johnsonfd060852017-10-04 10:50:51 -0700970 if (roam_info) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 /* Save the BSSID for the connection */
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800972 if (eCSR_BSS_TYPE_INFRASTRUCTURE == bss_type) {
Jeff Johnsonfd060852017-10-04 10:50:51 -0700973 QDF_ASSERT(roam_info->pBssDesc);
Jeff Johnsone04b6992019-02-27 14:06:55 -0800974 qdf_copy_macaddr(&sta_ctx->conn_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700975 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976
977 /*
978 * Save the Station ID for this station from
Jeff Johnson0a082d92019-03-04 12:25:49 -0800979 * the 'Roam Info'. For IBSS mode, sta_id is
980 * assigned in NEW_PEER_IND. For reassoc, the
981 * sta_id doesn't change and it may be invalid
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 * in this structure so no change here.
983 */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700984 if (!roam_info->fReassocReq) {
Jeff Johnson0a082d92019-03-04 12:25:49 -0800985 sta_ctx->conn_info.sta_id[0] =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700986 roam_info->staId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 }
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800988 } else if (eCSR_BSS_TYPE_IBSS == bss_type) {
Jeff Johnsone04b6992019-02-27 14:06:55 -0800989 qdf_copy_macaddr(&sta_ctx->conn_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700990 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800991 } else {
992 /*
993 * can't happen. We need a valid IBSS or Infra setting
994 * in the BSSDescription or we can't function.
995 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530996 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800997 }
998
999 /* notify WMM */
Jeff Johnsonfdb993c2019-02-27 09:38:08 -08001000 hdd_wmm_connect(adapter, roam_info, bss_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001
Jeff Johnsonfd060852017-10-04 10:50:51 -07001002 if (!roam_info->u.pConnectedProfile) {
1003 QDF_ASSERT(roam_info->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 } else {
1005 /* Get Multicast Encryption Type */
Jeff Johnson1627e752019-03-23 12:33:37 -07001006 encrypt_type =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001007 roam_info->u.pConnectedProfile->mcEncryptionType;
Jeff Johnson1627e752019-03-23 12:33:37 -07001008 sta_ctx->conn_info.mc_encrypt_type = encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009 /* Get Unicast Encryption Type */
Jeff Johnson1627e752019-03-23 12:33:37 -07001010 encrypt_type =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001011 roam_info->u.pConnectedProfile->EncryptionType;
Jeff Johnson1627e752019-03-23 12:33:37 -07001012 sta_ctx->conn_info.uc_encrypt_type = encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
Jeff Johnson96e33512019-02-27 15:10:21 -08001014 sta_ctx->conn_info.auth_type =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001015 roam_info->u.pConnectedProfile->AuthType;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001016 sta_ctx->conn_info.last_auth_type =
Jeff Johnson96e33512019-02-27 15:10:21 -08001017 sta_ctx->conn_info.auth_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018
Jeff Johnson8626e932019-02-27 18:35:22 -08001019 sta_ctx->conn_info.channel =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001020 roam_info->u.pConnectedProfile->operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021
1022 /* Save the ssid for the connection */
Jeff Johnson4aea1802019-02-27 10:21:33 -08001023 qdf_mem_copy(&sta_ctx->conn_info.ssid.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001024 &roam_info->u.pConnectedProfile->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 sizeof(tSirMacSSid));
Jeff Johnsond377dce2017-10-04 10:32:42 -07001026 qdf_mem_copy(&sta_ctx->conn_info.last_ssid.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001027 &roam_info->u.pConnectedProfile->SSID,
Zhang Qian32fd43e2017-08-24 18:36:28 +08001028 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001029
1030 /* Save dot11mode in which STA associated to AP */
Jeff Johnsonc52bc8b2019-02-27 17:49:33 -08001031 sta_ctx->conn_info.dot11mode =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001032 roam_info->u.pConnectedProfile->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033
Jeff Johnsonac5170c2019-02-27 10:55:24 -08001034 sta_ctx->conn_info.proxy_arp_service =
1035 roam_info->u.pConnectedProfile->proxy_arp_service;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301036
Jeff Johnsonfd060852017-10-04 10:50:51 -07001037 sta_ctx->conn_info.nss = roam_info->chan_info.nss;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301038
Jeff Johnsond377dce2017-10-04 10:32:42 -07001039 sta_ctx->conn_info.rate_flags =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001040 roam_info->chan_info.rate_flags;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +05301041
1042 sta_ctx->conn_info.ch_width =
1043 roam_info->chan_info.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 }
Jeff Johnsonfd060852017-10-04 10:50:51 -07001045 hdd_save_bss_info(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001046 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047}
1048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049/**
1050 * hdd_send_ft_assoc_response() - send fast transition assoc response
1051 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001052 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001053 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001054 *
1055 * Send the 11R key information to the supplicant. Only then can the supplicant
1056 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
1057 * for the same purpose.)
1058 *
1059 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
1060 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
1061 * This is the Assoc Response.
1062 *
1063 * Return: none
1064 */
1065static void
1066hdd_send_ft_assoc_response(struct net_device *dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07001067 struct hdd_adapter *adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001068 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069{
1070 union iwreq_data wrqu;
1071 char *buff;
1072 unsigned int len = 0;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001073 u8 *assoc_rsp = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001075 if (roam_info->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001076 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 return;
1078 }
1079
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001080 assoc_rsp =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001081 (u8 *) (roam_info->pbFrames + roam_info->nBeaconLength +
1082 roam_info->nAssocReqLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001083 if (!assoc_rsp) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001084 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001085 return;
1086 }
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001087 /* assoc_rsp needs to point to the IEs */
1088 assoc_rsp += FT_ASSOC_RSP_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089
1090 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001091 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Min Liu74a1a502018-10-10 19:59:07 +08001092 if (!buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001093 return;
Min Liu74a1a502018-10-10 19:59:07 +08001094
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001095 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001096 len = roam_info->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097 wrqu.data.length = len;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001098 memcpy(buff, assoc_rsp, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
1100
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001101 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104/**
1105 * hdd_send_ft_event() - send fast transition event
Jeff Johnsonba388342017-10-02 13:31:01 -07001106 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 *
1108 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
1109 * FT events to the supplicant. At the reception of Auth2 we send the RIC
1110 * followed by the auth response IEs to the supplicant.
1111 * Once both are received in the supplicant, an FT event is generated
1112 * to the supplicant.
1113 *
1114 * Return: none
1115 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001116static void hdd_send_ft_event(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117{
1118 uint16_t auth_resp_len = 0;
1119 uint32_t ric_ies_length = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001120 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001121 mac_handle_t mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001122
1123#if defined(KERNEL_SUPPORT_11R_CFG80211)
1124 struct cfg80211_ft_event_params ftEvent;
1125 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1126 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
Jeff Johnsonba388342017-10-02 13:31:01 -07001127 struct net_device *dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001128#else
1129 char *buff;
1130 union iwreq_data wrqu;
1131 uint16_t str_len;
1132#endif
1133
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001134 mac_handle = hdd_ctx->mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301136 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1137 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138
Jeff Johnson1abc5662019-02-04 14:27:02 -08001139 sme_get_rici_es(mac_handle, adapter->vdev_id, (u8 *) ricIe,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001141 if (ric_ies_length == 0)
1142 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001143
1144 ftEvent.ric_ies = ricIe;
1145 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001146 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147
Jeff Johnson1abc5662019-02-04 14:27:02 -08001148 sme_get_ft_pre_auth_response(mac_handle, adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1150 &auth_resp_len);
1151
1152 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001153 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 return;
1155 }
1156
Jeff Johnson1abc5662019-02-04 14:27:02 -08001157 sme_set_ft_pre_auth_state(mac_handle, adapter->vdev_id, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158
1159 ftEvent.target_ap = ftIe;
1160
Anurag Chouhan6d760662016-02-20 16:05:43 +05301161 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1162 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001164 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1165 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1166 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167 ftEvent.target_ap[0], ftEvent.target_ap[1],
1168 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1169 ftEvent.target_ap[5]);
1170
1171 (void)cfg80211_ft_event(dev, &ftEvent);
1172
1173#else
1174 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001175 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Min Liu74a1a502018-10-10 19:59:07 +08001176 if (!buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001178
1179 /* Sme needs to send the RIC IEs first */
1180 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Jeff Johnson1abc5662019-02-04 14:27:02 -08001181 sme_get_rici_es(mac_handle, adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1183 &ric_ies_length);
1184 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001185 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 } else {
1187 wrqu.data.length = str_len + ric_ies_length;
Jeff Johnsonba388342017-10-02 13:31:01 -07001188 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189 }
1190
1191 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301192 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001193 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Jeff Johnson1abc5662019-02-04 14:27:02 -08001194 sme_get_ft_pre_auth_response(mac_handle, adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195 (u8 *) &buff[str_len],
1196 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1197
1198 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001199 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001200 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201 return;
1202 }
1203
1204 wrqu.data.length = str_len + auth_resp_len;
Jeff Johnsonba388342017-10-02 13:31:01 -07001205 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001207 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208#endif
1209}
1210
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211#ifdef FEATURE_WLAN_ESE
1212/**
1213 * hdd_send_new_ap_channel_info() - send new ap channel info
1214 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001215 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001216 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 *
1218 * Send the ESE required "new AP Channel info" to the supplicant.
1219 * (This keeps the supplicant "up to date" on the current channel.)
1220 *
1221 * The current (new AP) channel information is passed in.
1222 *
1223 * Return: none
1224 */
1225static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07001226hdd_send_new_ap_channel_info(struct net_device *dev,
1227 struct hdd_adapter *adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001228 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229{
1230 union iwreq_data wrqu;
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001231 struct bss_description *descriptor = roam_info->pBssDesc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232
Jeff Johnsond36fa332019-03-18 13:42:25 -07001233 if (!descriptor) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001234 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 return;
1236 }
1237 /*
1238 * Send the Channel event, the supplicant needs this to generate
1239 * the Adjacent AP report.
1240 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001241 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001242 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001243 memset(&wrqu, '\0', sizeof(wrqu));
1244 wrqu.freq.m = descriptor->channelId;
1245 wrqu.freq.e = 0;
1246 wrqu.freq.i = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001247 wireless_send_event(adapter->dev, SIOCGIWFREQ, &wrqu, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248}
1249
1250#endif /* FEATURE_WLAN_ESE */
1251
1252/**
1253 * hdd_send_update_beacon_ies_event() - send update beacons ie event
Jeff Johnsonba388342017-10-02 13:31:01 -07001254 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001255 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 *
1257 * Return: none
1258 */
1259static void
Jeff Johnsonba388342017-10-02 13:31:01 -07001260hdd_send_update_beacon_ies_event(struct hdd_adapter *adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001261 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262{
1263 union iwreq_data wrqu;
Jeff Johnson04e00082017-10-04 12:15:58 -07001264 u8 *beacon_ies;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 u8 currentLen = 0;
1266 char *buff;
1267 int totalIeLen = 0, currentOffset = 0, strLen;
1268
1269 memset(&wrqu, '\0', sizeof(wrqu));
1270
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001271 if (0 == roam_info->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001272 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001273 return;
1274 }
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001275 beacon_ies = (u8 *) (roam_info->pbFrames + BEACON_FRAME_IES_OFFSET);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001276 if (!beacon_ies) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001277 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001278 return;
1279 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001280 /* beacon_ies needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001281 hdd_debug("Beacon IEs is now at %02x%02x",
Jeff Johnson04e00082017-10-04 12:15:58 -07001282 (unsigned int)beacon_ies[0],
1283 (unsigned int)beacon_ies[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001284 hdd_debug("Beacon IEs length = %d",
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001285 roam_info->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286
1287 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001288 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Min Liu74a1a502018-10-10 19:59:07 +08001289 if (!buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001291
1292 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1293 currentLen = strLen + 1;
1294
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001295 totalIeLen = roam_info->nBeaconLength - BEACON_FRAME_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001296 do {
1297 /*
1298 * If the beacon size exceeds max CUSTOM event size, break it
1299 * into chunks of CUSTOM event max size and send it to
1300 * supplicant. Changes are done in supplicant to handle this.
1301 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301302 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301304 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Jeff Johnson04e00082017-10-04 12:15:58 -07001305 qdf_mem_copy(&buff[strLen + 1], beacon_ies + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001306 currentLen);
1307 currentOffset += currentLen;
1308 totalIeLen -= currentLen;
1309 wrqu.data.length = strLen + 1 + currentLen;
1310 if (totalIeLen)
1311 buff[strLen] = 1; /* more chunks pending */
1312 else
1313 buff[strLen] = 0; /* last chunk */
1314
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001315 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001316 currentLen);
Jeff Johnsonba388342017-10-02 13:31:01 -07001317 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001318 } while (totalIeLen > 0);
1319
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001320 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321}
1322
1323/**
1324 * hdd_send_association_event() - send association event
1325 * @dev: pointer to net device
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001326 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327 *
1328 * Return: none
1329 */
1330static void hdd_send_association_event(struct net_device *dev,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001331 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332{
Rajeev Kumar78427682017-01-13 16:13:11 -08001333 int ret;
Jeff Johnsonba388342017-10-02 13:31:01 -07001334 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1335 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001336 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337 union iwreq_data wrqu;
1338 int we_event;
1339 char *msg;
Jeff Johnson2d044612019-02-26 20:08:43 -08001340 struct qdf_mac_addr peer_macaddr;
Jeff Johnson844eec72018-03-13 11:48:18 -07001341 struct csr_roam_profile *roam_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342
Jeff Johnson844eec72018-03-13 11:48:18 -07001343 roam_profile = hdd_roam_profile(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 memset(&wrqu, '\0', sizeof(wrqu));
1345 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1346 we_event = SIOCGIWAP;
1347#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsond36fa332019-03-18 13:42:25 -07001348 if (roam_info)
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001349 if (roam_info->roamSynchInProgress) {
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301350 /* Update tdls module about the disconnection event */
Jeff Johnson1abc5662019-02-04 14:27:02 -08001351 hdd_notify_sta_disconnect(adapter->vdev_id,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001352 true, false,
Dustin Brown89fa06e2018-09-07 10:47:27 -07001353 adapter->vdev);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301354 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355#endif
Jeff Johnsone7951512019-02-27 10:02:51 -08001356 if (eConnectionState_Associated == sta_ctx->conn_info.conn_state) {
Jeff Johnsona7d5b542019-02-03 10:15:46 -08001357 struct oem_channel_info chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301358
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001359 if (!roam_info || !roam_info->pBssDesc) {
1360 hdd_warn("STA in associated state but roam_info is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361 return;
1362 }
1363
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001364 if (!hdd_is_roam_sync_in_progress(roam_info)) {
Dustin Brown76cd2932018-09-11 16:03:05 -07001365 policy_mgr_incr_active_session(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001366 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07001367 hdd_green_ap_start_state_mc(hdd_ctx,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05301368 adapter->device_mode, true);
1369 }
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001370 memcpy(wrqu.ap_addr.sa_data, roam_info->pBssDesc->bssId,
1371 sizeof(roam_info->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372
Dustin Brown89fa06e2018-09-07 10:47:27 -07001373 ucfg_p2p_status_connect(adapter->vdev);
Wu Gaoc02785d2017-09-07 18:17:13 +08001374
Abhinav Kumar50d4dc72018-06-15 16:35:50 +05301375 hdd_info("wlan: " MAC_ADDRESS_STR " connected to "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001376 MAC_ADDRESS_STR "\n",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001377 QDF_MAC_ADDR_ARRAY(adapter->mac_addr.bytes),
1378 QDF_MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001379 hdd_send_update_beacon_ies_event(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380
1381 /*
1382 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1383 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001384 * fFTEnable is true.
1385 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001387 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388 eCSR_AUTH_TYPE_FT_RSN_PSK)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001389 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001390 eCSR_AUTH_TYPE_FT_RSN)
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05301391 || (roam_profile->AuthType.authType[0] ==
1392 eCSR_AUTH_TYPE_FT_SAE)
1393 || (roam_profile->AuthType.authType[0] ==
1394 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395#ifdef FEATURE_WLAN_ESE
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001396 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 eCSR_AUTH_TYPE_CCKM_RSN)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001398 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 eCSR_AUTH_TYPE_CCKM_WPA)
1400#endif
1401 ) {
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001402 hdd_send_ft_assoc_response(dev, adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403 }
Jeff Johnson2d044612019-02-26 20:08:43 -08001404 qdf_copy_macaddr(&peer_macaddr,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001405 &sta_ctx->conn_info.bssid);
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001406 chan_info.chan_id = roam_info->chan_info.chan_id;
1407 chan_info.mhz = roam_info->chan_info.mhz;
1408 chan_info.info = roam_info->chan_info.info;
Abhishek Singh1c676222016-05-09 14:20:28 +05301409 chan_info.band_center_freq1 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001410 roam_info->chan_info.band_center_freq1;
Abhishek Singh1c676222016-05-09 14:20:28 +05301411 chan_info.band_center_freq2 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001412 roam_info->chan_info.band_center_freq2;
Abhishek Singh1c676222016-05-09 14:20:28 +05301413 chan_info.reg_info_1 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001414 roam_info->chan_info.reg_info_1;
Abhishek Singh1c676222016-05-09 14:20:28 +05301415 chan_info.reg_info_2 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001416 roam_info->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301417
Dustin Brown89fa06e2018-09-07 10:47:27 -07001418 ret = hdd_objmgr_set_peer_mlme_state(adapter->vdev,
Dustin Brown7d043f62017-03-27 12:07:36 -07001419 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301420 if (ret)
1421 hdd_err("Peer object %pM fail to set associated state",
Jeff Johnson2d044612019-02-26 20:08:43 -08001422 peer_macaddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301423
Abhishek Singh1c676222016-05-09 14:20:28 +05301424 /* send peer status indication to oem app */
Jeff Johnson2d044612019-02-26 20:08:43 -08001425 hdd_send_peer_status_ind_to_app(&peer_macaddr,
Naveen Rawat910726a2017-03-06 11:42:51 -08001426 ePeerConnected,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001427 roam_info->timingMeasCap,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001428 adapter->vdev_id, &chan_info,
Jeff Johnsonba388342017-10-02 13:31:01 -07001429 adapter->device_mode);
jiad7b8a5e02018-11-26 16:37:57 +08001430
1431#ifdef FEATURE_WLAN_TDLS
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001432 /* Update tdls module about connection event */
Jeff Johnson1abc5662019-02-04 14:27:02 -08001433 hdd_notify_sta_connect(adapter->vdev_id,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001434 roam_info->tdls_chan_swit_prohibited,
1435 roam_info->tdls_prohibited,
Dustin Brown89fa06e2018-09-07 10:47:27 -07001436 adapter->vdev);
jiad7b8a5e02018-11-26 16:37:57 +08001437#endif
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001438
Tiger Yu8b119e92019-04-09 13:55:07 +08001439#ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 /* start timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001441 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001442 adapter->prev_tx_packets = adapter->stats.tx_packets;
1443 adapter->prev_rx_packets = adapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001444 cdp_get_intra_bss_fwd_pkts_count(
Jeff Johnson1abc5662019-02-04 14:27:02 -08001445 cds_get_context(QDF_MODULE_ID_SOC), adapter->vdev_id,
Jeff Johnsonba388342017-10-02 13:31:01 -07001446 &adapter->prev_fwd_tx_packets,
1447 &adapter->prev_fwd_rx_packets);
Jeff Johnson8095a312017-09-03 09:13:24 -07001448 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1449 hdd_bus_bw_compute_timer_start(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001451 } else if (eConnectionState_IbssConnected == /* IBss Associated */
Jeff Johnsone7951512019-02-27 10:02:51 -08001452 sta_ctx->conn_info.conn_state) {
Dustin Brown76cd2932018-09-11 16:03:05 -07001453 policy_mgr_update_connection_info(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001454 adapter->vdev_id);
Jeff Johnsone04b6992019-02-27 14:06:55 -08001455 memcpy(wrqu.ap_addr.sa_data, sta_ctx->conn_info.bssid.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001456 ETH_ALEN);
Abhishek Singh44725482017-11-02 16:53:23 +05301457 hdd_debug("wlan: new IBSS peer connection to BSSID " MAC_ADDRESS_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001458 QDF_MAC_ADDR_ARRAY(sta_ctx->conn_info.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 } else { /* Not Associated */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301460 hdd_debug("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Dustin Brown76cd2932018-09-11 16:03:05 -07001462 policy_mgr_decr_session_set_pcl(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001463 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07001464 hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05301465 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466
1467#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001468 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469#endif
1470
Jeff Johnsonba388342017-10-02 13:31:01 -07001471 if ((adapter->device_mode == QDF_STA_MODE) ||
Jeff Johnson844eec72018-03-13 11:48:18 -07001472 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Jeff Johnson2d044612019-02-26 20:08:43 -08001473 qdf_copy_macaddr(&peer_macaddr,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001474 &sta_ctx->conn_info.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475
1476 /* send peer status indication to oem app */
Jeff Johnson2d044612019-02-26 20:08:43 -08001477 hdd_send_peer_status_ind_to_app(&peer_macaddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301478 ePeerDisconnected, 0,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001479 adapter->vdev_id,
Abhishek Singh1c676222016-05-09 14:20:28 +05301480 NULL,
Jeff Johnsonba388342017-10-02 13:31:01 -07001481 adapter->device_mode);
Abhishek Singh44725482017-11-02 16:53:23 +05301482 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301483
Jeff Johnsonba388342017-10-02 13:31:01 -07001484 hdd_lpass_notify_disconnect(adapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001485 /* Update tdls module about the disconnection event */
Jeff Johnson1abc5662019-02-04 14:27:02 -08001486 hdd_notify_sta_disconnect(adapter->vdev_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001487 false,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001488 false,
Dustin Brown89fa06e2018-09-07 10:47:27 -07001489 adapter->vdev);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001490
Tiger Yu8b119e92019-04-09 13:55:07 +08001491#ifdef WLAN_FEATURE_DP_BUS_BANDWIDTH
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 /* stop timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001493 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001494 adapter->prev_tx_packets = 0;
1495 adapter->prev_rx_packets = 0;
1496 adapter->prev_fwd_tx_packets = 0;
1497 adapter->prev_fwd_rx_packets = 0;
Jeff Johnson8095a312017-09-03 09:13:24 -07001498 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1499 hdd_bus_bw_compute_timer_try_stop(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500#endif
1501 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001502 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503
1504 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001505 /* During the WLAN uninitialization,supplicant is stopped before the
1506 * driver so not sending the status of the connection to supplicant
1507 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001508 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 wireless_send_event(dev, we_event, &wrqu, msg);
1510#ifdef FEATURE_WLAN_ESE
1511 if (eConnectionState_Associated ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001512 sta_ctx->conn_info.conn_state) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001513 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 eCSR_AUTH_TYPE_CCKM_RSN) ||
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001515 (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001516 eCSR_AUTH_TYPE_CCKM_WPA))
Jeff Johnsonba388342017-10-02 13:31:01 -07001517 hdd_send_new_ap_channel_info(dev, adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001518 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519 }
1520#endif
1521 }
1522}
1523
1524/**
1525 * hdd_conn_remove_connect_info() - remove connection info
Jeff Johnsond377dce2017-10-04 10:32:42 -07001526 * @sta_ctx: pointer to global HDD station context
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001527 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528 *
1529 * Return: none
1530 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001531static void hdd_conn_remove_connect_info(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532{
Jeff Johnson0a082d92019-03-04 12:25:49 -08001533 /* Remove sta_id, bssid and peer_macaddr */
1534 sta_ctx->conn_info.sta_id[0] = HDD_WLAN_INVALID_STA_ID;
Jeff Johnsone04b6992019-02-27 14:06:55 -08001535 qdf_mem_zero(&sta_ctx->conn_info.bssid, QDF_MAC_ADDR_SIZE);
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08001536 qdf_mem_zero(&sta_ctx->conn_info.peer_macaddr[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301537 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538
1539 /* Clear all security settings */
Jeff Johnson96e33512019-02-27 15:10:21 -08001540 sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonb1959842019-02-27 13:04:04 -08001541 sta_ctx->conn_info.mc_encrypt_type = eCSR_ENCRYPT_TYPE_NONE;
1542 sta_ctx->conn_info.uc_encrypt_type = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543
Jeff Johnsond377dce2017-10-04 10:32:42 -07001544 qdf_mem_zero(&sta_ctx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545
Jeff Johnsonac5170c2019-02-27 10:55:24 -08001546 sta_ctx->conn_info.proxy_arp_service = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001547
Jeff Johnson4aea1802019-02-27 10:21:33 -08001548 qdf_mem_zero(&sta_ctx->conn_info.ssid, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001549}
1550
1551/**
Jeff Johnson7f2c5912018-03-23 11:42:28 -07001552 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
1553 * @adapter: adapter who's IEs are to be cleared
1554 *
1555 * Return: None
1556 */
1557static void hdd_clear_roam_profile_ie(struct hdd_adapter *adapter)
1558{
1559 struct hdd_station_ctx *sta_ctx;
1560 struct csr_roam_profile *roam_profile;
1561
1562 hdd_enter();
1563
1564 /* clear WPA/RSN/WSC IE information in the profile */
1565 roam_profile = hdd_roam_profile(adapter);
1566
1567 roam_profile->nWPAReqIELength = 0;
1568 roam_profile->pWPAReqIE = NULL;
1569 roam_profile->nRSNReqIELength = 0;
1570 roam_profile->pRSNReqIE = NULL;
1571
1572#ifdef FEATURE_WLAN_WAPI
1573 roam_profile->nWAPIReqIELength = 0;
1574 roam_profile->pWAPIReqIE = NULL;
1575#endif
1576
1577 roam_profile->bWPSAssociation = false;
1578 roam_profile->bOSENAssociation = false;
1579 roam_profile->pAddIEScan = NULL;
1580 roam_profile->nAddIEScanLength = 0;
1581 roam_profile->pAddIEAssoc = NULL;
1582 roam_profile->nAddIEAssocLength = 0;
1583
1584 roam_profile->EncryptionType.numEntries = 1;
1585 roam_profile->EncryptionType.encryptionType[0] =
1586 eCSR_ENCRYPT_TYPE_NONE;
1587
1588 roam_profile->mcEncryptionType.numEntries = 1;
1589 roam_profile->mcEncryptionType.encryptionType[0] =
1590 eCSR_ENCRYPT_TYPE_NONE;
1591
1592 roam_profile->AuthType.numEntries = 1;
1593 roam_profile->AuthType.authType[0] =
1594 eCSR_AUTH_TYPE_OPEN_SYSTEM;
1595
1596 qdf_mem_zero(roam_profile->bssid_hint.bytes, QDF_MAC_ADDR_SIZE);
1597
1598#ifdef WLAN_FEATURE_11W
1599 roam_profile->MFPEnabled = false;
1600 roam_profile->MFPRequired = 0;
1601 roam_profile->MFPCapable = 0;
1602#endif
1603
1604 qdf_mem_zero(roam_profile->Keys.KeyLength, CSR_MAX_NUM_KEY);
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +05301605 qdf_mem_zero(roam_profile->Keys.KeyMaterial,
1606 sizeof(roam_profile->Keys.KeyMaterial));
Jeff Johnson7f2c5912018-03-23 11:42:28 -07001607#ifdef FEATURE_WLAN_WAPI
1608 adapter->wapi_info.wapi_auth_mode = WAPI_AUTH_MODE_OPEN;
1609 adapter->wapi_info.wapi_mode = false;
1610#endif
1611
1612 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1613 sta_ctx->auth_key_mgmt = 0;
1614 qdf_zero_macaddr(&sta_ctx->requested_bssid);
Srinivas Dasarie3ef7c62018-12-28 13:16:09 +05301615 hdd_clear_fils_connection_info(adapter);
Jeff Johnson7f2c5912018-03-23 11:42:28 -07001616 hdd_exit();
1617}
1618
1619/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 * hdd_roam_deregister_sta() - deregister station
Jeff Johnsonba388342017-10-02 13:31:01 -07001621 * @adapter: pointer to adapter
Jeff Johnson0a082d92019-03-04 12:25:49 -08001622 * @sta_id: station identifier
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301624 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08001626QDF_STATUS hdd_roam_deregister_sta(struct hdd_adapter *adapter, uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301628 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001630 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001631 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Jeff Johnson0a082d92019-03-04 12:25:49 -08001632 sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301633 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08001634 hdd_err("cdp_clear_peer() failed for sta_id %d. Status(%d) [0x%08X]",
1635 sta_id, qdf_status, qdf_status);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301636 }
1637
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301638 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639}
1640
1641/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301642 * hdd_print_bss_info() - print bss info
1643 * @hdd_sta_ctx: pointer to hdd station context
1644 *
1645 * Return: None
1646 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001647static void hdd_print_bss_info(struct hdd_station_ctx *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301648{
1649 uint32_t *cap_info;
1650
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301651 hdd_debug("WIFI DATA LOGGER");
1652 hdd_debug("channel: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301653 hdd_sta_ctx->conn_info.freq);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301654 hdd_debug("dot11mode: %d",
Jeff Johnsonc52bc8b2019-02-27 17:49:33 -08001655 hdd_sta_ctx->conn_info.dot11mode);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301656 hdd_debug("AKM: %d",
1657 hdd_sta_ctx->conn_info.last_auth_type);
1658 hdd_debug("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001659 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1660 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301661 hdd_debug("roam count: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301662 hdd_sta_ctx->conn_info.roam_count);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301663 hdd_debug("ant_info: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301664 hdd_sta_ctx->conn_info.txrate.nss);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301665 hdd_debug("datarate legacy %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301666 hdd_sta_ctx->conn_info.txrate.legacy);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301667 hdd_debug("datarate mcs: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301668 hdd_sta_ctx->conn_info.txrate.mcs);
1669 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1670 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301671 hdd_debug("ht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301672 }
1673 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1674 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301675 hdd_debug("vht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301676 }
1677 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301678 hdd_debug("hs20 info: %x",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301679 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301680 hdd_debug("signal: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301681 hdd_sta_ctx->conn_info.signal);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301682 hdd_debug("noise: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301683 hdd_sta_ctx->conn_info.noise);
1684}
1685
1686/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 * hdd_dis_connect_handler() - disconnect event handler
Jeff Johnsonba388342017-10-02 13:31:01 -07001688 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07001689 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08001690 * @roam_id: roam identifier
1691 * @roam_status: roam status
1692 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 *
1694 * This function handles disconnect event:
1695 * 1. Disable transmit queues;
1696 * 2. Clean up internal connection states and data structures;
1697 * 3. Send disconnect indication to supplicant.
1698 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301699 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001701static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001702 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08001703 uint32_t roam_id,
1704 eRoamCmdStatus roam_status,
1705 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301707 QDF_STATUS status = QDF_STATUS_SUCCESS;
1708 QDF_STATUS vstatus;
Jeff Johnsonba388342017-10-02 13:31:01 -07001709 struct net_device *dev = adapter->dev;
1710 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001711 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712 uint8_t sta_id;
1713 bool sendDisconInd = true;
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001714 mac_handle_t mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715
Jeff Johnsond36fa332019-03-18 13:42:25 -07001716 if (!dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001717 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301718 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 }
1720 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001721 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07001722 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301723 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1724 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725
gaurank kathpalia63311d12018-04-12 14:34:26 +05301726 if (ucfg_ipa_is_enabled() &&
Jeff Johnson0a082d92019-03-04 12:25:49 -08001727 (sta_ctx->conn_info.sta_id[0] != HDD_WLAN_INVALID_STA_ID))
Dustin Brown07901ec2018-09-07 11:02:41 -07001728 ucfg_ipa_wlan_evt(hdd_ctx->pdev, adapter->dev,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05301729 adapter->device_mode,
Jeff Johnson0a082d92019-03-04 12:25:49 -08001730 sta_ctx->conn_info.sta_id[0],
Jeff Johnson1abc5662019-02-04 14:27:02 -08001731 adapter->vdev_id,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05301732 WLAN_IPA_STA_DISCONNECT,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001733 sta_ctx->conn_info.bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734
1735#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001736 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737#endif
1738
Nirav Shah1da77682016-05-03 20:16:39 +05301739 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001740 adapter->vdev_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001741 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301742 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743
1744 /* HDD has initiated disconnect, do not send disconnect indication
1745 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301746 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001747 * to cfg80211_disconnected.
1748 */
1749 if ((eConnectionState_Disconnecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001750 sta_ctx->conn_info.conn_state) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 (eConnectionState_NotConnected ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001752 sta_ctx->conn_info.conn_state) ||
Abhinav Kumar74948192018-05-09 17:17:50 +05301753 (eConnectionState_Connecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001754 sta_ctx->conn_info.conn_state)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001755 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 sendDisconInd = false;
Abhinav Kumar74948192018-05-09 17:17:50 +05301757 } else {
Jeff Johnsonba388342017-10-02 13:31:01 -07001758 INIT_COMPLETION(adapter->disconnect_comp_var);
1759 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 eConnectionState_Disconnecting);
1761 }
1762
Jeff Johnsonba388342017-10-02 13:31:01 -07001763 hdd_clear_roam_profile_ie(adapter);
1764 hdd_wmm_init(adapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001765 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301766 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767
1768 /* indicate 'disconnect' status to wpa_supplicant... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07001769 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 /* indicate disconnected event to nl80211 */
Jeff Johnson29c78672019-02-26 21:05:53 -08001771 if (roam_status != eCSR_ROAM_IBSS_LEAVE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 /*
1773 * Only send indication to kernel if not initiated
1774 * by kernel
1775 */
1776 if (sendDisconInd) {
1777 /*
1778 * To avoid wpa_supplicant sending "HANGED" CMD
1779 * to ICS UI.
1780 */
Jeff Johnson29c78672019-02-26 21:05:53 -08001781 if (eCSR_ROAM_LOSTLINK == roam_status) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07001782 if (roam_info->reasonCode ==
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001783 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
Jeff Johnson435e1b82017-10-07 14:13:10 -07001784 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n",
1785 roam_info->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301786 wlan_hdd_cfg80211_indicate_disconnect(
1787 dev, false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001788 roam_info->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001789 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301790 wlan_hdd_cfg80211_indicate_disconnect(
1791 dev, false,
1792 WLAN_REASON_UNSPECIFIED
1793 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001794 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301796 hdd_debug("sent disconnected event to nl80211, reason code %d",
Jeff Johnson29c78672019-02-26 21:05:53 -08001797 (eCSR_ROAM_LOSTLINK == roam_status) ?
Jeff Johnsonfd060852017-10-04 10:50:51 -07001798 roam_info->reasonCode :
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301799 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001801
Wu Gaoc02785d2017-09-07 18:17:13 +08001802 /* update P2P connection status */
Dustin Brown89fa06e2018-09-07 10:47:27 -07001803 ucfg_p2p_status_disconnect(adapter->vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 }
1805
Jeff Johnsonba388342017-10-02 13:31:01 -07001806 hdd_wmm_adapter_clear(adapter);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001807 mac_handle = hdd_ctx->mac_handle;
Jeff Johnson1abc5662019-02-04 14:27:02 -08001808 sme_ft_reset(mac_handle, adapter->vdev_id);
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +05301809 sme_reset_key(mac_handle, adapter->vdev_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001810 if (hdd_remove_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001811 hdd_err("hdd_remove_beacon_filter() failed");
1812
Jeff Johnson29c78672019-02-26 21:05:53 -08001813 if (eCSR_ROAM_IBSS_LEAVE == roam_status) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301814 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001815
Jeff Johnson0a082d92019-03-04 12:25:49 -08001816 sta_id = sta_ctx->broadcast_sta_id;
Jeff Johnsonba388342017-10-02 13:31:01 -07001817 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301818 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001819 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301820 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301821 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001823 if (sta_id < HDD_MAX_ADAPTERS)
1824 hdd_ctx->sta_to_adapter[sta_id] = NULL;
1825 else
1826 hdd_debug("invalid sta id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301827 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001828 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001829 if (HDD_WLAN_INVALID_STA_ID ==
Jeff Johnson0a082d92019-03-04 12:25:49 -08001830 sta_ctx->conn_info.sta_id[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301831 continue;
Jeff Johnson0a082d92019-03-04 12:25:49 -08001832 sta_id = sta_ctx->conn_info.sta_id[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001833 hdd_debug("Deregister StaID %d", sta_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001834 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301835 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001836 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301837 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301838 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301839 }
Jeff Johnson0a082d92019-03-04 12:25:49 -08001840 /* set the sta_id and peer mac as 0, all other
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301841 * reset are done in hdd_connRemoveConnectInfo.
1842 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08001843 sta_ctx->conn_info.sta_id[i] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301844 HDD_WLAN_INVALID_STA_ID;
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08001845 qdf_mem_zero(&sta_ctx->conn_info.peer_macaddr[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301846 sizeof(struct qdf_mac_addr));
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001847 if (sta_id < HDD_MAX_ADAPTERS)
Jeff Johnson8095a312017-09-03 09:13:24 -07001848 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001849 else
1850 hdd_debug("invalid sta_id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301851 }
1852 } else {
Jeff Johnson0a082d92019-03-04 12:25:49 -08001853 sta_id = sta_ctx->conn_info.sta_id[0];
Jeff Johnson29c78672019-02-26 21:05:53 -08001854 hdd_debug("roam_result: %d", roam_result);
Abhishek Singhc9941602016-08-09 16:06:22 +05301855
1856 /* clear scan cache for Link Lost */
Jeff Johnson29c78672019-02-26 21:05:53 -08001857 if (eCSR_ROAM_RESULT_DEAUTH_IND == roam_result ||
1858 eCSR_ROAM_RESULT_DISASSOC_IND == roam_result ||
1859 eCSR_ROAM_LOSTLINK == roam_status) {
Abhishek Singh85283ae2019-03-08 12:00:51 +05301860 wlan_hdd_cfg80211_unlink_bss(adapter,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001861 sta_ctx->conn_info.bssid.bytes);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001862 sme_remove_bssid_from_scan_list(mac_handle,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001863 sta_ctx->conn_info.bssid.bytes);
Abhishek Singhc9941602016-08-09 16:06:22 +05301864 }
Rajeev Kumar4bc998f2017-10-19 14:41:43 -07001865 if (sta_id < HDD_MAX_ADAPTERS)
1866 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001867 else
1868 hdd_debug("invalid sta_id %d", sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870 /* Clear saved connection information in HDD */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001871 hdd_conn_remove_connect_info(sta_ctx);
Abhinav Kumar74948192018-05-09 17:17:50 +05301872 /*
1873 * eConnectionState_Connecting state mean that connection is in
1874 * progress so no need to set state to eConnectionState_NotConnected
1875 */
Jeff Johnsone7951512019-02-27 10:02:51 -08001876 if ((eConnectionState_Connecting != sta_ctx->conn_info.conn_state)) {
Srinivas Girigowda683726a2018-09-07 15:10:40 -07001877 hdd_conn_set_connection_state(adapter,
Abhinav Kumar74948192018-05-09 17:17:50 +05301878 eConnectionState_NotConnected);
Dundi Raviteja04037a12018-08-31 18:41:44 +05301879 hdd_set_roaming_in_progress(false);
Abhinav Kumar74948192018-05-09 17:17:50 +05301880 }
Wu Gaod7dd6e42018-10-16 17:22:56 +08001881 ucfg_pmo_flush_gtk_offload_req(adapter->vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882
Jeff Johnsonba388342017-10-02 13:31:01 -07001883 if ((QDF_STA_MODE == adapter->device_mode) ||
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001884 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
1885 sme_ps_disable_auto_ps_timer(mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001886 adapter->vdev_id);
Yeshwanth Sriram Guntuka4fe30bd2018-06-13 11:41:42 +05301887 adapter->send_mode_change = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 }
Jeff Johnsonba388342017-10-02 13:31:01 -07001889 wlan_hdd_clear_link_layer_stats(adapter);
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301890
Bala Venkatesh9f958142018-06-27 12:36:08 +05301891 hdd_debug("check for SAP restart");
Dustin Brown76cd2932018-09-11 16:03:05 -07001892 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->psoc);
Jeff Johnson6ced42c2017-10-20 12:48:11 -07001893 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301894
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895 /* Unblock anyone waiting for disconnect to complete */
Jeff Johnsonba388342017-10-02 13:31:01 -07001896 complete(&adapter->disconnect_comp_var);
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301897
Alok Kumarb64650c2018-03-23 17:05:11 +05301898 hdd_nud_reset_tracking(adapter);
1899
1900 hdd_set_disconnect_status(adapter, false);
1901
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301902 hdd_reset_limit_off_chan(adapter);
1903
Jeff Johnsond377dce2017-10-04 10:32:42 -07001904 hdd_print_bss_info(sta_ctx);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05301905
Dustin Brown76cd2932018-09-11 16:03:05 -07001906 if (policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc))
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001907 sme_enable_roaming_on_connected_sta(mac_handle);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05301908
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001909 return status;
1910}
1911
1912/**
1913 * hdd_set_peer_authorized_event() - set peer_authorized_event
1914 * @vdev_id: vdevid
1915 *
1916 * Return: None
1917 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001918static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001919{
Jeff Johnson49432062017-08-28 12:08:45 -07001920 struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001921 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922
Ashish Kumar Dhanotiyaab2a9292018-06-16 15:11:27 +05301923 if (!hdd_ctx) {
1924 hdd_err("Invalid hdd context");
1925 return;
1926 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001928 if (!adapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001929 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001930 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 }
1932 complete(&adapter->sta_authorized_event);
1933}
1934
1935/**
1936 * hdd_change_peer_state() - change peer state
Jeff Johnsonba388342017-10-02 13:31:01 -07001937 * @adapter: HDD adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938 * @sta_state: peer state
1939 * @roam_synch_in_progress: roam synch in progress
1940 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301941 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001943QDF_STATUS hdd_change_peer_state(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 uint8_t sta_id,
1945 enum ol_txrx_peer_state sta_state,
1946 bool roam_synch_in_progress)
1947{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301948 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001949 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001950 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1951 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1952 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953
1954 if (!pdev) {
1955 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301956 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 }
1958
1959 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001960 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301961 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 }
1963
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001964 peer = cdp_peer_find_by_local_id(soc,
1965 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301967 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001968
Leo Changfdb45c32016-10-28 11:09:23 -07001969 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001970 if (!peer_mac_addr) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001971 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001972 return QDF_STATUS_E_FAULT;
1973 }
1974
Leo Changfdb45c32016-10-28 11:09:23 -07001975 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301976 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001977 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301978 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 }
1980#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1981 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301982 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983#endif
1984
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001985 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Abhinav Kumar2b431b62019-03-18 20:23:58 +05301986 /* Reset scan reject params on successful set key */
1987 hdd_debug("Reset scan reject params");
1988 hdd_init_scan_reject_params(adapter->hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001989#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1990 /* make sure event is reset */
Jeff Johnsonba388342017-10-02 13:31:01 -07001991 INIT_COMPLETION(adapter->sta_authorized_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992#endif
1993
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001994 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 hdd_set_peer_authorized_event,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001996 adapter->vdev_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301997 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001998 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301999 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000 }
2001
Jeff Johnsonba388342017-10-02 13:31:01 -07002002 if (adapter->device_mode == QDF_STA_MODE ||
2003 adapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07002005 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 unsigned long rc;
2007
2008 /* wait for event from firmware to set the event */
2009 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07002010 &adapter->sta_authorized_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002011 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002012 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002013 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002014
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002015 vdev = (void *)cdp_peer_get_vdev(soc, peer);
2016 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07002017 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018#endif
2019 }
2020 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302021 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022}
2023
2024/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07002025 * hdd_update_dp_vdev_flags() - update datapath vdev flags
2026 * @cbk_data: callback data
2027 * @sta_id: station id
2028 * @vdev_param: vdev parameter
2029 * @is_link_up: link state up or down
2030 *
2031 * Return: QDF status
2032 */
2033QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
2034 uint8_t sta_id,
2035 uint32_t vdev_param,
2036 bool is_link_up)
2037{
2038 struct cdp_vdev *data_vdev;
2039 QDF_STATUS status = QDF_STATUS_SUCCESS;
2040 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Jeff Johnson49432062017-08-28 12:08:45 -07002041 struct hdd_context *hdd_ctx;
Yun Park0dad1002017-07-14 14:57:01 -07002042 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Kabilan Kannan256e3182017-05-02 16:02:37 -07002043 struct wlan_objmgr_psoc **psoc;
2044
2045 if (!cbk_data)
2046 return status;
2047
2048 psoc = cbk_data;
Kabilan Kannan256e3182017-05-02 16:02:37 -07002049
Kabilan Kannanc0e3d582017-09-13 00:26:33 -07002050 hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Sourav Mohapatra5febc932018-01-08 14:38:30 +05302051 if (!hdd_ctx) {
2052 hdd_err("Invalid HDD Context");
2053 return QDF_STATUS_E_INVAL;
2054 }
2055
Kabilan Kannan256e3182017-05-02 16:02:37 -07002056 if (!hdd_ctx->tdls_nap_active)
2057 return status;
2058
Yun Park0dad1002017-07-14 14:57:01 -07002059 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, pdev, sta_id);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002060 if (!data_vdev) {
Kabilan Kannan256e3182017-05-02 16:02:37 -07002061 status = QDF_STATUS_E_FAILURE;
2062 return status;
2063 }
2064
2065 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
2066
2067 return status;
2068}
2069
2070/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071 * hdd_roam_register_sta() - register station
Jeff Johnsonba388342017-10-02 13:31:01 -07002072 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002073 * @roam_info: pointer to roam info
Jeff Johnson0a082d92019-03-04 12:25:49 -08002074 * @sta_id: station identifier
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 * @pBssDesc: pointer to BSS description
2076 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302077 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002079QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002080 struct csr_roam_info *roam_info,
Jeff Johnson0a082d92019-03-04 12:25:49 -08002081 uint8_t sta_id,
Jeff Johnson4ba73cb2017-10-06 11:12:33 -07002082 struct bss_description *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302084 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsonc419c172019-03-05 10:59:32 -08002085 struct ol_txrx_desc_type txrx_desc = { 0 };
Jeff Johnsond377dce2017-10-04 10:32:42 -07002086 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08002087 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07002088 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2089 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090
Jeff Johnsond36fa332019-03-18 13:42:25 -07002091 if (!pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302092 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093
2094 /* Get the Station ID from the one saved during the association */
Jeff Johnsonc419c172019-03-05 10:59:32 -08002095 txrx_desc.sta_id = sta_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096
2097 /* set the QoS field appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07002098 if (hdd_wmm_is_active(adapter))
Jeff Johnsonc419c172019-03-05 10:59:32 -08002099 txrx_desc.is_qos_enabled = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100 else
Jeff Johnsonc419c172019-03-05 10:59:32 -08002101 txrx_desc.is_qos_enabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102
2103#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07002104 hdd_debug("WAPI STA Registered: %d",
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002105 adapter->wapi_info.is_wapi_sta);
2106 if (adapter->wapi_info.is_wapi_sta)
Jeff Johnsonc419c172019-03-05 10:59:32 -08002107 txrx_desc.is_wapi_supported = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 else
Jeff Johnsonc419c172019-03-05 10:59:32 -08002109 txrx_desc.is_wapi_supported = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110#endif /* FEATURE_WLAN_WAPI */
2111
Dhanashri Atre50141c52016-04-07 13:15:29 -07002112 /* Register the vdev transmit and receive functions */
2113 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
Mohit Khanna70322002018-05-15 19:21:32 -07002114
2115 if (adapter->hdd_ctx->enable_dp_rx_threads) {
2116 txrx_ops.rx.rx = hdd_rx_pkt_thread_enqueue_cbk;
2117 txrx_ops.rx.rx_stack = hdd_rx_packet_cbk;
2118 } else {
2119 txrx_ops.rx.rx = hdd_rx_packet_cbk;
2120 txrx_ops.rx.rx_stack = NULL;
2121 }
2122
Poddar, Siddarth31797fa2018-01-22 17:24:15 +05302123 txrx_ops.rx.stats_rx = hdd_tx_rx_collect_connectivity_stats_info;
Leo Changfdb45c32016-10-28 11:09:23 -07002124
Jeff Johnsonba388342017-10-02 13:31:01 -07002125 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002126 (struct cdp_pdev *)pdev,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002127 adapter->vdev_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07002128 if (!adapter->txrx_vdev) {
Leo Changfdb45c32016-10-28 11:09:23 -07002129 hdd_err("%s find vdev fail", __func__);
2130 return QDF_STATUS_E_FAILURE;
2131 }
2132
2133 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002134 cdp_vdev_register(soc,
Sravan Kumar Kairam43f191b2018-05-04 17:00:39 +05302135 (struct cdp_vdev *)adapter->txrx_vdev, adapter,
Dustin Brown89fa06e2018-09-07 10:47:27 -07002136 (struct cdp_ctrl_objmgr_vdev *)adapter->vdev, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07002137 if (!txrx_ops.tx.tx) {
2138 hdd_err("%s vdev register fail", __func__);
2139 return QDF_STATUS_E_FAILURE;
2140 }
2141
Jeff Johnsonba388342017-10-02 13:31:01 -07002142 adapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002143 qdf_status = cdp_peer_register(soc,
Jeff Johnsonc419c172019-03-05 10:59:32 -08002144 (struct cdp_pdev *)pdev, &txrx_desc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302145 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002146 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002147 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302148 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149 }
2150
Jeff Johnsonfd060852017-10-04 10:50:51 -07002151 if (!roam_info->fAuthRequired) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002152 /*
2153 * Connections that do not need Upper layer auth, transition
2154 * TLSHIM directly to 'Authenticated' state
2155 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302156 qdf_status =
Jeff Johnsonc419c172019-03-05 10:59:32 -08002157 hdd_change_peer_state(adapter, txrx_desc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002158 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002159#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002160 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161#else
2162 false
2163#endif
2164 );
2165
Jeff Johnsonba388342017-10-02 13:31:01 -07002166 hdd_conn_set_authenticated(adapter, true);
Dustin Brown89fa06e2018-09-07 10:47:27 -07002167 hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002169 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnson0a082d92019-03-04 12:25:49 -08002170 sta_ctx->conn_info.sta_id[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302171 qdf_status =
Jeff Johnsonc419c172019-03-05 10:59:32 -08002172 hdd_change_peer_state(adapter, txrx_desc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002173 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002175 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002176#else
2177 false
2178#endif
2179 );
Jeff Johnsonba388342017-10-02 13:31:01 -07002180 hdd_conn_set_authenticated(adapter, false);
Dustin Brown89fa06e2018-09-07 10:47:27 -07002181 hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002182 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302183 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184}
2185
2186/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302187 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2188 * @dev: network device
2189 * @bss: cfg80211 roamed bss pointer
2190 * @req_ie: IEs used in reassociation request
2191 * @req_ie_len: Length of the @req_ie
2192 * @resp_ie: IEs received in successful reassociation response
2193 * @resp_ie_len: Length of @resp_ie
2194 *
2195 * Return: none
2196 */
2197#if defined CFG80211_ROAMED_API_UNIFIED || \
2198 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2199static void hdd_send_roamed_ind(struct net_device *dev,
2200 struct cfg80211_bss *bss, const uint8_t *req_ie,
2201 size_t req_ie_len, const uint8_t *resp_ie,
2202 size_t resp_ie_len)
2203{
2204 struct cfg80211_roam_info info = {0};
2205
2206 info.bss = bss;
2207 info.req_ie = req_ie;
2208 info.req_ie_len = req_ie_len;
2209 info.resp_ie = resp_ie;
2210 info.resp_ie_len = resp_ie_len;
2211 cfg80211_roamed(dev, &info, GFP_KERNEL);
2212}
2213#else
2214static inline void hdd_send_roamed_ind(struct net_device *dev,
2215 struct cfg80211_bss *bss,
2216 const uint8_t *req_ie, size_t req_ie_len,
2217 const uint8_t *resp_ie,
2218 size_t resp_ie_len)
2219{
2220 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2221 GFP_KERNEL);
2222}
2223#endif
2224
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302225#if defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302226#if defined(WLAN_FEATURE_FILS_SK)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302227void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002228 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302229{
2230 uint8_t *kek;
2231 uint32_t kek_len;
2232
2233 if (is_reassoc) {
2234 kek = csr_roam_info->kek;
2235 kek_len = csr_roam_info->kek_len;
2236 } else {
2237 /*
2238 * This should come for FILS case only.
2239 * Caller should make sure fils_join_rsp is
2240 * not NULL, if there is need to use else where.
2241 */
2242 kek = csr_roam_info->fils_join_rsp->kek;
2243 kek_len = csr_roam_info->fils_join_rsp->kek_len;
2244 }
2245
2246 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2247 csr_roam_info->replay_ctr, true);
2248
2249 hdd_debug("Kek len %d", kek_len);
2250}
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302251#else
2252void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002253 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302254{
2255 uint8_t *kek;
2256 uint32_t kek_len;
2257
2258 /*
2259 * is_reassoc is set to true always for Legacy GTK offload
2260 * case, It is false only for FILS case
2261 */
2262 kek = csr_roam_info->kek;
2263 kek_len = csr_roam_info->kek_len;
2264
2265 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2266 csr_roam_info->replay_ctr, true);
2267
2268 hdd_debug("Kek len %d", kek_len);
2269}
2270#endif
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302271#endif
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302272/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002273 * hdd_send_re_assoc_event() - send reassoc event
2274 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07002275 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002276 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002277 * @reqRsnIe: pointer to RSN Information element
2278 * @reqRsnLength: length of RSN IE
2279 *
2280 * Return: none
2281 */
2282static void hdd_send_re_assoc_event(struct net_device *dev,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002283 struct hdd_adapter *adapter, struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002284 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2285{
2286 unsigned int len = 0;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002287 u8 *assoc_rsp = NULL;
Jeff Johnson48b56b12019-03-09 19:51:48 -08002288 uint8_t *rsp_rsn_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002289 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002290 uint32_t rsp_rsn_lemgth = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 struct ieee80211_channel *chan;
Srinivas Girigowdab8fdc642019-03-19 15:33:03 -07002292 uint8_t buf_ssid_ie[2 + WLAN_SSID_MAX_LEN]; /* 2 bytes-EID and len */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 uint8_t *buf_ptr, ssid_ie_len;
2294 struct cfg80211_bss *bss = NULL;
2295 uint8_t *final_req_ie = NULL;
2296 tCsrRoamConnectedProfile roam_profile;
Jeff Johnsonba388342017-10-02 13:31:01 -07002297 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302298 int chan_no;
2299 int freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002300
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002301 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2302
Jeff Johnson48b56b12019-03-09 19:51:48 -08002303 if (!rsp_rsn_ie) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002304 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002305 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 }
2307
Naveen Rawat14298b92015-11-25 16:27:41 -08002308 if (!assoc_req_ies) {
2309 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002310 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002311 }
Rajeev Kumar Sirasanagandlae5582aa2018-05-02 18:20:20 +05302312
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002313 if (!roam_info || !roam_info->pBssDesc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002314 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315 goto done;
2316 }
2317
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002318 if (roam_info->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002319 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002320 goto done;
2321 }
2322
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002323 assoc_rsp =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002324 (u8 *) (roam_info->pbFrames + roam_info->nBeaconLength +
2325 roam_info->nAssocReqLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002326 if (!assoc_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002327 goto done;
2328
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002329 /* assoc_rsp needs to point to the IEs */
2330 assoc_rsp += FT_ASSOC_RSP_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002331
2332 /*
2333 * Active session count is decremented upon disconnection, but during
2334 * roaming, there is no disconnect indication and hence active session
2335 * count is not decremented.
2336 * After roaming is completed, active session count is incremented
2337 * as a part of connect indication but effectively after roaming the
2338 * active session count should still be the same and hence upon
2339 * successful reassoc decrement the active session count here.
2340 */
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002341 if (!hdd_is_roam_sync_in_progress(roam_info)) {
Dustin Brown76cd2932018-09-11 16:03:05 -07002342 policy_mgr_decr_session_set_pcl(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002343 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07002344 hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05302345 false);
2346 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347
2348 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002349 len = roam_info->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002350 rsp_rsn_lemgth = len;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002351 qdf_mem_copy(rsp_rsn_ie, assoc_rsp, len);
Jeff Johnson48b56b12019-03-09 19:51:48 -08002352 qdf_mem_zero(rsp_rsn_ie + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002353
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002354 chan_no = roam_info->pBssDesc->channelId;
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302355 if (chan_no <= 14)
2356 freq = ieee80211_channel_to_frequency(chan_no,
2357 NL80211_BAND_2GHZ);
2358 else
2359 freq = ieee80211_channel_to_frequency(chan_no,
2360 NL80211_BAND_5GHZ);
Jeff Johnsonba388342017-10-02 13:31:01 -07002361 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302362
Jeff Johnson1abc5662019-02-04 14:27:02 -08002363 sme_roam_get_connect_profile(hdd_ctx->mac_handle, adapter->vdev_id,
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002364 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302365
Abhishek Singh59cdca12019-03-08 13:48:20 +05302366 bss = wlan_cfg80211_get_bss(adapter->wdev.wiphy,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002367 chan, roam_info->bssid.bytes,
Abhishek Singh59cdca12019-03-08 13:48:20 +05302368 &roam_profile.SSID.ssId[0],
2369 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370
Jeff Johnsond36fa332019-03-18 13:42:25 -07002371 if (!bss)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002372 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002373 buf_ptr = buf_ssid_ie;
Srinivas Girigowda61771262019-04-01 11:55:19 -07002374 *buf_ptr = WLAN_ELEMID_SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 buf_ptr++;
2376 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2377 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302378 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002379 roam_profile.SSID.length);
2380 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002381 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302382 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002383 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002384 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002385 if (!final_req_ie) {
Kapil Gupta8731e812017-07-11 18:42:39 +05302386 if (bss)
Jeff Johnsonba388342017-10-02 13:31:01 -07002387 cfg80211_put_bss(adapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302389 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002390 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302391 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302393 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002394 qdf_mem_copy(rsp_rsn_ie, assoc_rsp, len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302395 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002396 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002397 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302398 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002399 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302400 hdd_send_roamed_ind(dev, bss, final_req_ie,
Jeff Johnson48b56b12019-03-09 19:51:48 -08002401 (ssid_ie_len + reqRsnLength), rsp_rsn_ie,
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002402 rsp_rsn_lemgth);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002403
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302404 qdf_mem_copy(assoc_req_ies,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002405 (u8 *)roam_info->pbFrames + roam_info->nBeaconLength,
2406 roam_info->nAssocReqLength);
Naveen Rawat14298b92015-11-25 16:27:41 -08002407
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002408 hdd_save_gtk_params(adapter, roam_info, true);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302409
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002410 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302411 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002412 assoc_req_ies, roam_info->nAssocReqLength);
Naveen Rawat14298b92015-11-25 16:27:41 -08002413
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002414 wlan_hdd_send_roam_auth_event(adapter, roam_info->bssid.bytes,
2415 assoc_req_ies, roam_info->nAssocReqLength,
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002416 rsp_rsn_ie, rsp_rsn_lemgth,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002417 roam_info);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302418
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002419 hdd_update_hlp_info(dev, roam_info);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302420
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002421done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002422 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002424 qdf_mem_free(final_req_ie);
Jeff Johnson48b56b12019-03-09 19:51:48 -08002425 qdf_mem_free(rsp_rsn_ie);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002426 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427}
2428
2429/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302430 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002431 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302432 *
2433 * Return: roam sync status if roaming offloaded else false
2434 */
2435#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson172237b2017-11-07 15:32:59 -08002436bool hdd_is_roam_sync_in_progress(struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302437{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002438 if (roaminfo)
2439 return roaminfo->roamSynchInProgress;
2440 else
2441 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302442}
2443#endif
2444
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002445/**
Jeff Johnson0a082d92019-03-04 12:25:49 -08002446 * hdd_get_ibss_peer_sta_id() - get sta id for IBSS peer
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002447 * @hddstactx: pointer to HDD sta context
2448 * @roaminfo: pointer to roaminfo structure
2449 *
Jeff Johnson0a082d92019-03-04 12:25:49 -08002450 * This function returns sta_id for IBSS peer. If peer is broadcast
2451 * MAC address return self sta_id(0) else find the peer sta id of
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002452 * the peer.
2453 *
2454 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2455 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08002456static uint8_t hdd_get_ibss_peer_sta_id(struct hdd_station_ctx *hddstactx,
2457 struct csr_roam_info *roaminfo)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002458{
Jeff Johnson0a082d92019-03-04 12:25:49 -08002459 uint8_t sta_id = HDD_WLAN_INVALID_STA_ID;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002460 QDF_STATUS status;
2461
2462 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08002463 sta_id = 0;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002464 } else {
2465 status = hdd_get_peer_sta_id(hddstactx,
Jeff Johnson0a082d92019-03-04 12:25:49 -08002466 &roaminfo->peerMac, &sta_id);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002467 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08002468 hdd_err("Unable to find station ID for "
2469 MAC_ADDRESS_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002470 QDF_MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002471 }
2472 }
2473
Jeff Johnson0a082d92019-03-04 12:25:49 -08002474 return sta_id;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002475}
Govind Singhedc5cda2015-10-23 17:11:35 +05302476
2477/**
2478 * hdd_change_sta_state_authenticated()-
2479 * This function changes STA state to authenticated
2480 * @adapter: pointer to the adapter structure.
2481 * @roaminfo: pointer to the RoamInfo structure.
2482 *
2483 * This is called from hdd_RoamSetKeyCompleteHandler
2484 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2485 *
2486 * Return: 0 on success and errno on failure
2487 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002488static int hdd_change_sta_state_authenticated(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002489 struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302490{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002491 QDF_STATUS status;
Pragaspathi Thilagaraj784c4922018-12-02 22:47:29 +05302492 uint32_t timeout, auto_bmps_timer_val;
Jeff Johnson0a082d92019-03-04 12:25:49 -08002493 uint8_t sta_id = HDD_WLAN_INVALID_STA_ID;
Jeff Johnson435e1b82017-10-07 14:13:10 -07002494 struct hdd_station_ctx *hddstactx =
2495 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson49432062017-08-28 12:08:45 -07002496 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302497
Pragaspathi Thilagaraj784c4922018-12-02 22:47:29 +05302498 ucfg_mlme_get_auto_bmps_timer_value(hdd_ctx->psoc,
2499 &auto_bmps_timer_val);
Jeff Johnson690fe952017-10-25 11:48:39 -07002500 timeout = hddstactx->hdd_reassoc_scenario ?
Dustin Brownf660fb42016-09-09 12:04:00 -07002501 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Pragaspathi Thilagaraj784c4922018-12-02 22:47:29 +05302502 (auto_bmps_timer_val * 1000);
Dustin Brownf660fb42016-09-09 12:04:00 -07002503
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002504 if (QDF_IBSS_MODE == adapter->device_mode)
Jeff Johnson0a082d92019-03-04 12:25:49 -08002505 sta_id = hdd_get_ibss_peer_sta_id(hddstactx, roaminfo);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002506 else
Jeff Johnson0a082d92019-03-04 12:25:49 -08002507 sta_id = hddstactx->conn_info.sta_id[0];
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002508
Jeff Johnson0a082d92019-03-04 12:25:49 -08002509 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d",
2510 sta_id);
Govind Singhedc5cda2015-10-23 17:11:35 +05302511
2512 /* Connections that do not need Upper layer authentication,
2513 * transition TL to 'Authenticated' state after the keys are set
2514 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08002515 status = hdd_change_peer_state(adapter, sta_id, OL_TXRX_PEER_STATE_AUTH,
2516 hdd_is_roam_sync_in_progress(roaminfo));
Govind Singhedc5cda2015-10-23 17:11:35 +05302517 hdd_conn_set_authenticated(adapter, true);
Dustin Brown89fa06e2018-09-07 10:47:27 -07002518 hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002519
Krunal Sonibe766b02016-03-10 13:00:44 -08002520 if ((QDF_STA_MODE == adapter->device_mode) ||
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002521 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
2522 sme_ps_enable_auto_ps_timer(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002523 adapter->vdev_id,
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002524 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302525 }
2526
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002527 return qdf_status_to_os_return(status);
2528}
2529
2530/**
2531 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2532 * if key installation is required
2533 * @encr_type: encryption type
2534 *
2535 * Return: true if key installation is required and false otherwise.
2536 */
2537static inline bool hdd_is_key_install_required_for_ibss(
2538 eCsrEncryptionType encr_type)
2539{
2540 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2541 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2542 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302543 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2544 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002545 eCSR_ENCRYPT_TYPE_AES == encr_type)
2546 return true;
2547 else
2548 return false;
2549}
2550
2551/**
2552 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2553 * complete
2554 * @adapter: pointer to HDD adapter
2555 * @roaminfo: pointer to roam info
2556 * @roam_result: roam result
2557 *
2558 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2559 * This function checks for the successful set key completion and update
2560 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2561 *
2562 * Return: None
2563 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002564static void hdd_change_peer_state_after_set_key(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002565 struct csr_roam_info *roaminfo,
2566 eCsrRoamResult roam_result)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002567{
Jeff Johnson435e1b82017-10-07 14:13:10 -07002568 struct hdd_station_ctx *hdd_sta_ctx =
2569 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonb1959842019-02-27 13:04:04 -08002570 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.uc_encrypt_type;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002571
2572 /*
2573 * If the security mode is one of the following, IBSS peer will be
2574 * waiting in CONN state and we will move the peer state to AUTH
2575 * here. For non-secure connection, no need to wait for set-key complete
2576 * peer will be moved to AUTH in hdd_roam_register_sta.
2577 */
2578 if (QDF_IBSS_MODE == adapter->device_mode) {
2579 if (hdd_is_key_install_required_for_ibss(encr_type))
2580 hdd_change_sta_state_authenticated(adapter, roaminfo);
2581
2582 return;
2583 }
2584
2585 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2586 hdd_sta_ctx->conn_info.gtk_installed = true;
2587 /*
2588 * PTK exchange happens in preauthentication itself if key_mgmt
2589 * is FT-PSK, ptk_installed was false as there is no set PTK
2590 * after roaming. STA TL state moves to authenticated only if
2591 * ptk_installed is true. So, make ptk_installed to true in
2592 * case of 11R roaming.
2593 */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002594 if (sme_neighbor_roam_is11r_assoc(adapter->hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002595 adapter->vdev_id))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002596 hdd_sta_ctx->conn_info.ptk_installed = true;
2597 } else {
2598 hdd_sta_ctx->conn_info.ptk_installed = true;
2599 }
2600
2601 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2602 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2603 * unicast key and it was resulting in sending few un-encrypted packet.
2604 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2605 * set the unicast and broadcast key.
2606 */
2607 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2608 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2609 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2610 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2611 if (hdd_sta_ctx->conn_info.gtk_installed &&
2612 hdd_sta_ctx->conn_info.ptk_installed)
2613 hdd_change_sta_state_authenticated(adapter, roaminfo);
2614 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2615 hdd_change_sta_state_authenticated(adapter, roaminfo);
2616 }
2617
2618 if (hdd_sta_ctx->conn_info.gtk_installed &&
2619 hdd_sta_ctx->conn_info.ptk_installed) {
2620 hdd_sta_ctx->conn_info.gtk_installed = false;
2621 hdd_sta_ctx->conn_info.ptk_installed = false;
2622 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302623}
2624
2625/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002626 * hdd_roam_set_key_complete_handler() - Update the security parameters
Jeff Johnsonba388342017-10-02 13:31:01 -07002627 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002628 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08002629 * @roam_id: roam id
2630 * @roam_status: roam status
2631 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302633 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002634 */
Jeff Johnson172237b2017-11-07 15:32:59 -08002635static QDF_STATUS
2636hdd_roam_set_key_complete_handler(struct hdd_adapter *adapter,
2637 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08002638 uint32_t roam_id,
2639 eRoamCmdStatus roam_status,
2640 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641{
Jeff Johnsone16f0822019-03-10 18:27:30 -07002642 eCsrEncryptionType algorithm;
Jeff Johnson389e16b2018-05-05 23:32:55 -07002643 bool connected = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002644 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302645
Dustin Brown491d54b2018-03-14 12:39:11 -07002646 hdd_enter();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647
Jeff Johnsond36fa332019-03-18 13:42:25 -07002648 if (!roam_info) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002649 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302650 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002651 }
2652 /*
2653 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2654 * then go to 'authenticated'. For all other authentication types
2655 * (those that do not require upper layer authentication) we can put TL
2656 * directly into 'authenticated' state.
2657 */
Jeff Johnson29c78672019-02-26 21:05:53 -08002658 hdd_debug("Set Key completion roam_status =%d roam_result=%d "
2659 MAC_ADDRESS_STR, roam_status, roam_result,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002660 QDF_MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661
Jeff Johnson389e16b2018-05-05 23:32:55 -07002662 connected = hdd_conn_get_connected_cipher_algo(sta_ctx,
Jeff Johnsone16f0822019-03-10 18:27:30 -07002663 &algorithm);
Jeff Johnson389e16b2018-05-05 23:32:55 -07002664 if (connected) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002665 hdd_change_peer_state_after_set_key(adapter, roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08002666 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 }
2668
Jianmin Zhu4bcf8372018-12-27 19:38:55 +08002669 if (!adapter->hdd_ctx || !adapter->hdd_ctx->psoc) {
2670 hdd_err("hdd_ctx or psoc is NULL");
2671 return QDF_STATUS_E_FAILURE;
2672 }
2673 policy_mgr_restart_opportunistic_timer(adapter->hdd_ctx->psoc, false);
2674
Dustin Browne74003f2018-03-14 12:51:58 -07002675 hdd_exit();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302676 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677}
2678
2679/**
2680 * hdd_perform_roam_set_key_complete() - perform set key complete
Jeff Johnsonba388342017-10-02 13:31:01 -07002681 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 *
2683 * Return: none
2684 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002685void hdd_perform_roam_set_key_complete(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302687 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002688 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Min Liu3621ede2018-11-07 18:36:00 +08002689 struct csr_roam_info *roam_info;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002690
Min Liu3621ede2018-11-07 18:36:00 +08002691 roam_info = qdf_mem_malloc(sizeof(*roam_info));
2692 if (!roam_info)
2693 return;
2694 roam_info->fAuthRequired = false;
2695 qdf_mem_copy(roam_info->bssid.bytes,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002696 sta_ctx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Min Liu3621ede2018-11-07 18:36:00 +08002697 qdf_mem_copy(roam_info->peerMac.bytes,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002698 sta_ctx->roam_info.peer_mac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302700 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002701 hdd_roam_set_key_complete_handler(adapter,
Min Liu3621ede2018-11-07 18:36:00 +08002702 roam_info,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002703 sta_ctx->roam_info.roam_id,
2704 sta_ctx->roam_info.roam_status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302706 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002707 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002709 sta_ctx->roam_info.defer_key_complete = false;
Min Liu3621ede2018-11-07 18:36:00 +08002710 qdf_mem_free(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711}
2712
Vignesh Viswanathan3fa1d382017-08-02 19:36:43 +05302713#if defined(WLAN_FEATURE_FILS_SK) && \
2714 (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \
2715 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)))
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002716void hdd_clear_fils_connection_info(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302717{
Jeff Johnson844eec72018-03-13 11:48:18 -07002718 struct csr_roam_profile *roam_profile;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302719
2720 if ((adapter->device_mode == QDF_SAP_MODE) ||
2721 (adapter->device_mode == QDF_P2P_GO_MODE))
2722 return;
2723
Jeff Johnson844eec72018-03-13 11:48:18 -07002724 roam_profile = hdd_roam_profile(adapter);
2725 if (roam_profile->fils_con_info) {
2726 qdf_mem_free(roam_profile->fils_con_info);
2727 roam_profile->fils_con_info = NULL;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302728 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302729
Jeff Johnson844eec72018-03-13 11:48:18 -07002730 if (roam_profile->hlp_ie) {
2731 qdf_mem_free(roam_profile->hlp_ie);
2732 roam_profile->hlp_ie = NULL;
2733 roam_profile->hlp_ie_len = 0;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302734 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302735}
2736#endif
2737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738/**
2739 * hdd_association_completion_handler() - association completion handler
Jeff Johnsonba388342017-10-02 13:31:01 -07002740 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002741 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08002742 * @roam_id: roam id
2743 * @roam_status: roam status
2744 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302746 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002747 */
Jeff Johnson435e1b82017-10-07 14:13:10 -07002748static QDF_STATUS
2749hdd_association_completion_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002750 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08002751 uint32_t roam_id,
2752 eRoamCmdStatus roam_status,
2753 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754{
Jeff Johnsonba388342017-10-02 13:31:01 -07002755 struct net_device *dev = adapter->dev;
2756 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002757 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302758 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002760 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 bool hddDisconInProgress = false;
2763 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302764 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302765 bool ok;
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002766 mac_handle_t mac_handle;
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05302767 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768
Jeff Johnson8095a312017-09-03 09:13:24 -07002769 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302771 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002772 }
2773
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302774 /* validate config */
Jeff Johnson8095a312017-09-03 09:13:24 -07002775 if (!hdd_ctx->config) {
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302776 hdd_err("config is NULL");
2777 return QDF_STATUS_E_NULL_VALUE;
2778 }
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05302779
2780 /*
Paul Zhangcb573e02018-11-06 10:37:16 +08002781 * reset scan reject params if connection is success or we received
2782 * final failure from CSR after trying with all APs.
2783 */
Jeff Johnson29c78672019-02-26 21:05:53 -08002784 hdd_reset_scan_reject_params(hdd_ctx, roam_status, roam_result);
Paul Zhangcb573e02018-11-06 10:37:16 +08002785
2786 /*
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05302787 * Enable roaming on other STA iface except this one.
2788 * Firmware dosent support connection on one STA iface while
2789 * roaming on other STA iface
2790 */
2791 wlan_hdd_enable_roaming(adapter);
2792
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002793 /* HDD has initiated disconnect, do not send connect result indication
2794 * to kernel as it will be handled by __cfg80211_disconnect.
2795 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302796 if (((eConnectionState_Disconnecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -08002797 sta_ctx->conn_info.conn_state) ||
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302798 (eConnectionState_NotConnected ==
Jeff Johnsone7951512019-02-27 10:02:51 -08002799 sta_ctx->conn_info.conn_state)) &&
Jeff Johnson29c78672019-02-26 21:05:53 -08002800 ((eCSR_ROAM_RESULT_ASSOCIATED == roam_result) ||
2801 (eCSR_ROAM_ASSOCIATION_FAILURE == roam_status))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002802 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
Jeff Johnsone7951512019-02-27 10:02:51 -08002803 sta_ctx->conn_info.conn_state,
Jeff Johnson29c78672019-02-26 21:05:53 -08002804 roam_result, roam_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002805 hddDisconInProgress = true;
2806 }
2807
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002808 mac_handle = hdd_ctx->mac_handle;
2809
Jeff Johnson29c78672019-02-26 21:05:53 -08002810 if (eCSR_ROAM_RESULT_ASSOCIATED == roam_result) {
Jeff Johnsond36fa332019-03-18 13:42:25 -07002811 if (!roam_info) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002812 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302813 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 }
2815 if (!hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07002816 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817 eConnectionState_Associated);
2818 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002821 hdd_conn_save_connect_info(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002822 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002823
Jeff Johnsonba388342017-10-02 13:31:01 -07002824 if (hdd_add_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002825 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826#ifdef FEATURE_WLAN_WAPI
Jeff Johnsonfd060852017-10-04 10:50:51 -07002827 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
Jeff Johnsonfd060852017-10-04 10:50:51 -07002829 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002831 adapter->wapi_info.is_wapi_sta = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832 } else {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002833 adapter->wapi_info.is_wapi_sta = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002834 }
2835#endif /* FEATURE_WLAN_WAPI */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002836 hdd_debug("bss_descr[%d] devicemode[%d]", !!roam_info->pBssDesc,
Jeff Johnsonba388342017-10-02 13:31:01 -07002837 adapter->device_mode);
2838 if ((QDF_STA_MODE == adapter->device_mode) &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07002839 roam_info->pBssDesc) {
2840 ie_len = GET_IE_LEN_IN_BSS(roam_info->pBssDesc->length);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002841 sta_ctx->ap_supports_immediate_power_save =
Krunal Soni364e0872017-05-10 21:24:34 -07002842 wlan_hdd_is_ap_supports_immediate_power_save(
Jeff Johnsonfd060852017-10-04 10:50:51 -07002843 (uint8_t *) roam_info->pBssDesc->ieFields,
Krunal Soni364e0872017-05-10 21:24:34 -07002844 ie_len);
2845 hdd_debug("ap_supports_immediate_power_save flag [%d]",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002846 sta_ctx->ap_supports_immediate_power_save);
Krunal Soni364e0872017-05-10 21:24:34 -07002847 }
2848
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 /* Indicate 'connect' status to user space */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002850 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002851
Dustin Brown76cd2932018-09-11 16:03:05 -07002852 if (policy_mgr_is_mcc_in_24G(hdd_ctx->psoc)) {
Jeff Johnson8095a312017-09-03 09:13:24 -07002853 if (hdd_ctx->miracast_value)
Jeff Johnsonba388342017-10-02 13:31:01 -07002854 wlan_hdd_set_mas(adapter,
Jeff Johnson8095a312017-09-03 09:13:24 -07002855 hdd_ctx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 }
2857
2858 /* Initialize the Linkup event completion variable */
Jeff Johnsonba388342017-10-02 13:31:01 -07002859 INIT_COMPLETION(adapter->linkup_event_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860
2861 /*
2862 * Sometimes Switching ON the Carrier is taking time to activate
2863 * the device properly. Before allowing any packet to go up to
2864 * the application, device activation has to be ensured for
2865 * proper queue mapping by the kernel. we have registered net
2866 * device notifier for device change notification. With this we
2867 * will come to know that the device is getting
2868 * activated properly.
2869 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07002870 if (sta_ctx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002871 /*
2872 * Enable Linkup Event Servicing which allows the net
2873 * device notifier to set the linkup event variable.
2874 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002875 adapter->is_link_up_service_needed = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002877 /* Switch on the Carrier to activate the device */
Jeff Johnsonba388342017-10-02 13:31:01 -07002878 wlan_hdd_netif_queue_control(adapter,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002879 WLAN_NETIF_CARRIER_ON,
2880 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002881
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002882 /*
2883 * Wait for the Link to up to ensure all the queues
2884 * are set properly by the kernel.
2885 */
2886 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07002887 &adapter->linkup_event_var,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002888 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2889 );
2890 if (!rc)
2891 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002893 /*
2894 * Disable Linkup Event Servicing - no more service
2895 * required from the net device notifier call.
2896 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002897 adapter->is_link_up_service_needed = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002898 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07002899 sta_ctx->ft_carrier_on = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002900 ft_carrier_on = true;
2901 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07002902 if (roam_info->staId < HDD_MAX_ADAPTERS)
Jeff Johnsonfd060852017-10-04 10:50:51 -07002903 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 else
Jeff Johnsonfd060852017-10-04 10:50:51 -07002905 hdd_err("Wrong Staid: %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05302907 if (ucfg_ipa_is_enabled())
Dustin Brown07901ec2018-09-07 11:02:41 -07002908 ucfg_ipa_wlan_evt(hdd_ctx->pdev, adapter->dev,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05302909 adapter->device_mode,
2910 roam_info->staId,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002911 adapter->vdev_id,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05302912 WLAN_IPA_STA_CONNECT,
2913 roam_info->bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914
2915#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07002916 wlan_hdd_auto_shutdown_enable(hdd_ctx, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917#endif
2918
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302919 hdd_debug("check if STA chan ok for DNBS");
Dustin Brown76cd2932018-09-11 16:03:05 -07002920 if (policy_mgr_is_chan_ok_for_dnbs(hdd_ctx->psoc,
Jeff Johnson8626e932019-02-27 18:35:22 -08002921 sta_ctx->conn_info.channel,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302922 &ok)) {
2923 hdd_err("Unable to check DNBS eligibility for chan:%d",
Jeff Johnson8626e932019-02-27 18:35:22 -08002924 sta_ctx->conn_info.channel);
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302925 return QDF_STATUS_E_FAILURE;
2926 }
2927
2928 if (!ok) {
2929 hdd_err("Chan:%d not suitable for DNBS",
Jeff Johnson8626e932019-02-27 18:35:22 -08002930 sta_ctx->conn_info.channel);
Jeff Johnsonba388342017-10-02 13:31:01 -07002931 wlan_hdd_netif_queue_control(adapter,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302932 WLAN_NETIF_CARRIER_OFF,
2933 WLAN_CONTROL_PATH);
2934 if (!hddDisconInProgress) {
2935 hdd_err("Disconnecting...");
2936 sme_roam_disconnect(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002937 mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002938 adapter->vdev_id,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302939 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2940 }
2941 return QDF_STATUS_E_FAILURE;
2942 }
2943
Nirav Shah1da77682016-05-03 20:16:39 +05302944 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002945 adapter->vdev_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002946 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302947 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 /*
2950 * For reassoc, the station is already registered, all we need
2951 * is to change the state of the STA in TL.
2952 * If authentication is required (WPA/WPA2/DWEP), change TL to
2953 * CONNECTED instead of AUTHENTICATED.
2954 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002955 if (!roam_info->fReassocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002956 struct cfg80211_bss *bss;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002957 u8 *assoc_rsp = NULL;
2958 unsigned int assoc_rsp_len = 0;
Jeff Johnson8152d892019-03-10 18:37:50 -07002959 u8 *assoc_req = NULL;
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07002960 unsigned int assoc_req_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 struct ieee80211_channel *chan;
Jeff Johnson48b56b12019-03-09 19:51:48 -08002962 uint8_t rsp_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002963 uint32_t rsp_rsn_lemgth = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964
2965 /* add bss_id to cfg80211 data base */
2966 bss =
Jeff Johnsonba388342017-10-02 13:31:01 -07002967 wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002968 roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002969 if (!bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302970 hdd_err("wlan: Not able to create BSS entry");
Jeff Johnsonba388342017-10-02 13:31:01 -07002971 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 WLAN_NETIF_CARRIER_OFF,
2973 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302974 if (!hddDisconInProgress) {
2975 /*
2976 * Here driver was not able to add bss
2977 * in cfg80211 database this can happen
2978 * if connected channel is not valid,
2979 * i.e reg domain was changed during
2980 * connection. Queue disconnect for the
2981 * session if disconnect is not in
2982 * progress.
2983 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002984 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302985 sme_roam_disconnect(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002986 mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002987 adapter->vdev_id,
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302988 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2989 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302990 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002991 }
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302992
Jeff Johnsonc66d3102018-02-28 11:58:26 -08002993 cfg80211_put_bss(hdd_ctx->wiphy, bss);
2994
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302995 /* Association Response */
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002996 assoc_rsp =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302997 (u8 *) (roam_info->pbFrames +
2998 roam_info->nBeaconLength +
2999 roam_info->nAssocReqLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003000 if (assoc_rsp) {
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303001 /*
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003002 * assoc_rsp needs to point to the IEs
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303003 */
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003004 assoc_rsp += FT_ASSOC_RSP_IES_OFFSET;
3005 assoc_rsp_len =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303006 roam_info->nAssocRspLength -
3007 FT_ASSOC_RSP_IES_OFFSET;
3008
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003009 hdd_debug("assoc_rsp_len %d", assoc_rsp_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303010 hdd_debug("Assoc Rsp IE dump");
3011 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
3012 QDF_TRACE_LEVEL_DEBUG,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003013 assoc_rsp,
3014 assoc_rsp_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303015 } else {
3016 hdd_debug("AssocRsp is NULL");
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003017 assoc_rsp_len = 0;
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303018 }
3019
3020 /* Association Request */
Jeff Johnson8152d892019-03-10 18:37:50 -07003021 assoc_req = (u8 *) (roam_info->pbFrames +
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303022 roam_info->nBeaconLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003023 if (assoc_req) {
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303024 if (!ft_carrier_on) {
3025 /*
Jeff Johnson8152d892019-03-10 18:37:50 -07003026 * assoc_req needs to point to
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303027 * the IEs
3028 */
Jeff Johnson8152d892019-03-10 18:37:50 -07003029 assoc_req +=
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303030 FT_ASSOC_REQ_IES_OFFSET;
Jeff Johnson8152d892019-03-10 18:37:50 -07003031 hdd_debug("assoc_req is now at %02x%02x",
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303032 (unsigned int)
Jeff Johnson8152d892019-03-10 18:37:50 -07003033 assoc_req[0],
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303034 (unsigned int)
Jeff Johnson8152d892019-03-10 18:37:50 -07003035 assoc_req[1]);
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003036 assoc_req_len =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303037 roam_info->nAssocReqLength -
3038 FT_ASSOC_REQ_IES_OFFSET;
3039 } else {
3040 /*
3041 * This should contain only the
3042 * FTIEs
3043 */
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003044 assoc_req_len =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303045 roam_info->nAssocReqLength;
3046 }
3047
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003048 hdd_debug("assoc_req_len %d", assoc_req_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303049 hdd_debug("Assoc/Reassoc Req IE dump");
3050 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
3051 QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson8152d892019-03-10 18:37:50 -07003052 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003053 assoc_req_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303054 } else {
3055 hdd_debug("AssocReq is NULL");
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003056 assoc_req_len = 0;
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303057 }
3058
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05303059 if ((roam_info->u.pConnectedProfile->AuthType ==
3060 eCSR_AUTH_TYPE_FT_RSN) ||
3061 (roam_info->u.pConnectedProfile->AuthType ==
3062 eCSR_AUTH_TYPE_FT_RSN_PSK) ||
3063 (roam_info->u.pConnectedProfile->AuthType ==
3064 eCSR_AUTH_TYPE_FT_SAE) ||
3065 (roam_info->u.pConnectedProfile->AuthType ==
3066 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003067 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08003068 if (!hddDisconInProgress &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07003069 roam_info->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05303070 struct cfg80211_bss *roam_bss;
3071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 /*
3073 * After roaming is completed,
3074 * active session count is
3075 * incremented as a part of
3076 * connect indication but
3077 * effectively the active
3078 * session count should still
3079 * be the same and hence upon
3080 * successful reassoc
3081 * decrement the active session
3082 * count here.
3083 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08003084 if (!hdd_is_roam_sync_in_progress
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303085 (roam_info)) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003086 policy_mgr_decr_session_set_pcl(
Dustin Brown76cd2932018-09-11 16:03:05 -07003087 hdd_ctx->psoc,
Jeff Johnsonba388342017-10-02 13:31:01 -07003088 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003089 adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07003090 hdd_green_ap_start_state_mc(
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303091 hdd_ctx,
3092 adapter->device_mode,
3093 false);
3094 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003095 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003096 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097 chan =
3098 ieee80211_get_channel
Jeff Johnsonba388342017-10-02 13:31:01 -07003099 (adapter->wdev.wiphy,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003100 (int)roam_info->pBssDesc->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003101 channelId);
Naveen Rawat14298b92015-11-25 16:27:41 -08003102
Abhishek Singh533c9da2017-05-04 10:23:34 +05303103 roam_bss =
Abhishek Singh59cdca12019-03-08 13:48:20 +05303104 wlan_cfg80211_get_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003105 adapter->wdev.wiphy,
Abhishek Singh533c9da2017-05-04 10:23:34 +05303106 chan,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003107 roam_info->bssid.bytes,
3108 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05303109 pConnectedProfile->SSID.ssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003110 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05303111 pConnectedProfile->SSID.length);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303112
3113 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003114 adapter->vdev_id,
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303115 sta_ctx->
Jeff Johnson8626e932019-02-27 18:35:22 -08003116 conn_info.channel);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303117
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05303118 hdd_send_roamed_ind(
3119 dev,
3120 roam_bss,
Jeff Johnson8152d892019-03-10 18:37:50 -07003121 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003122 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003123 assoc_rsp,
3124 assoc_rsp_len);
Abhishek Singh533c9da2017-05-04 10:23:34 +05303125 wlan_hdd_send_roam_auth_event(
Jeff Johnsonba388342017-10-02 13:31:01 -07003126 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003127 roam_info->bssid.bytes,
Jeff Johnson8152d892019-03-10 18:37:50 -07003128 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003129 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003130 assoc_rsp,
3131 assoc_rsp_len,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003132 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133 }
3134 if (sme_get_ftptk_state
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003135 (mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003136 adapter->vdev_id)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137 sme_set_ftptk_state
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003138 (mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003139 adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 false);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003141 roam_info->fAuthRequired =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003142 false;
3143
Jeff Johnsond377dce2017-10-04 10:32:42 -07003144 qdf_mem_copy(sta_ctx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003145 roam_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003146 roam_info->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303147 QDF_MAC_ADDR_SIZE);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003148 qdf_mem_copy(sta_ctx->
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003149 roam_info.peer_mac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003150 roam_info->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303151 QDF_MAC_ADDR_SIZE);
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003152 sta_ctx->roam_info.roam_id =
Jeff Johnson29c78672019-02-26 21:05:53 -08003153 roam_id;
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003154 sta_ctx->roam_info.roam_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08003155 roam_status;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003156 sta_ctx->roam_info.
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003157 defer_key_complete = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003158 }
3159 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003160 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003161 ft_carrier_on);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303162 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003163 adapter->vdev_id,
Jeff Johnson8626e932019-02-27 18:35:22 -08003164 sta_ctx->conn_info.channel);
Anurag Chouhanc4092922016-09-08 15:56:11 +05303165 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003166 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303167 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003168 roam_info,
Jeff Johnson8152d892019-03-10 18:37:50 -07003169 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003170 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003171 assoc_rsp,
3172 assoc_rsp_len,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303173 WLAN_STATUS_SUCCESS,
3174 GFP_KERNEL,
3175 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003176 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003177 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08003178 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 /*
3180 * wpa supplicant expecting WPA/RSN IE in
3181 * connect result.
3182 */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003183 sme_roam_get_wpa_rsn_req_ie(mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003184 adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003185 &reqRsnLength,
3186 reqRsnIe);
3187
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003188 sme_roam_get_wpa_rsn_rsp_ie(mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003189 adapter->vdev_id,
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08003190 &rsp_rsn_lemgth,
Jeff Johnson48b56b12019-03-09 19:51:48 -08003191 rsp_rsn_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 if (ft_carrier_on)
3194 hdd_send_re_assoc_event(dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07003195 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003196 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 reqRsnIe,
3198 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07003199 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003200 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003201 MAC_ADDRESS_STR
3202 " result:%d and Status:%d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003203 QDF_MAC_ADDR_ARRAY
Jeff Johnsonfd060852017-10-04 10:50:51 -07003204 (roam_info->bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003205 roam_result, roam_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003206
3207 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05303208 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003209 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303210 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003211 roam_info,
Jeff Johnson8152d892019-03-10 18:37:50 -07003212 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003213 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003214 assoc_rsp,
3215 assoc_rsp_len,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303216 WLAN_STATUS_SUCCESS,
3217 GFP_KERNEL,
3218 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003219 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003220 }
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303221 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003222 adapter->vdev_id,
Jeff Johnson8626e932019-02-27 18:35:22 -08003223 sta_ctx->conn_info.channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 }
3225 }
3226 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 /*
3228 * Perform any WMM-related association
3229 * processing.
3230 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003231 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 eCSR_BSS_TYPE_INFRASTRUCTURE);
3233
3234 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08003235 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003237 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003238 roam_info,
Jeff Johnson0a082d92019-03-04 12:25:49 -08003239 sta_ctx->conn_info.sta_id[0],
Jeff Johnson71a1d5c2018-12-30 11:31:04 -08003240 roam_info->pBssDesc);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303241 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003242 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 WLAN_WAKE_ALL_NETIF_QUEUE,
3244 WLAN_CONTROL_PATH);
3245
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003246 }
3247 } else {
3248 /*
3249 * wpa supplicant expecting WPA/RSN IE in connect result
3250 * in case of reassociation also need to indicate it to
3251 * supplicant.
3252 */
Jeff Johnson0a078b52018-06-01 16:15:54 -07003253 sme_roam_get_wpa_rsn_req_ie(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003254 mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003255 adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 &reqRsnLength, reqRsnIe);
3257
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303258 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003259 adapter->vdev_id,
Jeff Johnson8626e932019-02-27 18:35:22 -08003260 sta_ctx->conn_info.channel);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003261 hdd_send_re_assoc_event(dev, adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003262 reqRsnIe, reqRsnLength);
3263 /* Reassoc successfully */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003264 if (roam_info->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303265 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003266 hdd_change_peer_state(adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08003267 sta_ctx->conn_info.sta_id[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003268 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003270 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271#else
3272 false
3273#endif
3274 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003275 hdd_conn_set_authenticated(adapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003276 hdd_objmgr_set_peer_mlme_auth_state(
Dustin Brown89fa06e2018-09-07 10:47:27 -07003277 adapter->vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003278 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279 } else {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003280 hdd_debug("sta_id: %d Changing TL state to AUTHENTICATED",
3281 sta_ctx->conn_info.sta_id[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303282 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003283 hdd_change_peer_state(adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08003284 sta_ctx->conn_info.sta_id[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003285 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003287 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288#else
3289 false
3290#endif
3291 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003292 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003293 hdd_objmgr_set_peer_mlme_auth_state(
Dustin Brown89fa06e2018-09-07 10:47:27 -07003294 adapter->vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003295 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 }
3297
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303298 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003299 /*
3300 * Perform any WMM-related association
3301 * processing
3302 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003303 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304 eCSR_BSS_TYPE_INFRASTRUCTURE);
3305 }
3306
3307 /* Start the tx queues */
3308#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003309 if (roam_info->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003310 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311#endif
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303312 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003313 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003314 WLAN_WAKE_ALL_NETIF_QUEUE,
3315 WLAN_CONTROL_PATH);
3316 }
3317
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303318 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003319 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303320 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 }
3322#ifdef WLAN_FEATURE_11W
Jeff Johnsondc179f42017-10-21 11:27:26 -07003323 qdf_mem_zero(&adapter->hdd_stats.hdd_pmf_stats,
3324 sizeof(adapter->hdd_stats.hdd_pmf_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325#endif
Abhishek Singhbfaebe32019-03-19 13:37:55 +05303326 policy_mgr_check_n_start_opportunistic_timer(hdd_ctx->psoc);
Frank Liu064ebd42018-05-03 14:22:39 +08003327 hdd_debug("check for SAP restart");
3328 policy_mgr_check_concurrent_intf_and_restart_sap(
Dustin Brown76cd2932018-09-11 16:03:05 -07003329 hdd_ctx->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303331 bool connect_timeout = false;
Tushnim Bhattacharyya3f780532018-08-01 19:11:40 -07003332 /* do we need to change the HW mode */
Dustin Brown76cd2932018-09-11 16:03:05 -07003333 policy_mgr_check_n_start_opportunistic_timer(hdd_ctx->psoc);
Vignesh Viswanathan014096a2017-12-07 01:24:44 +05303334 if (roam_info && roam_info->is_fils_connection &&
Jeff Johnson29c78672019-02-26 21:05:53 -08003335 eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roam_result)
Vignesh Viswanathan014096a2017-12-07 01:24:44 +05303336 qdf_copy_macaddr(&roam_info->bssid,
3337 &sta_ctx->requested_bssid);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003338 if (roam_info)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303339 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003340 " result: %d and Status: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003341 QDF_MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003342 roam_result, roam_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003343 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303344 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003345 " result: %d and Status: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003346 QDF_MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003347 roam_result, roam_status);
Abhishek Singhc9941602016-08-09 16:06:22 +05303348
Jeff Johnson29c78672019-02-26 21:05:53 -08003349 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roam_result) ||
Jeff Johnsonfd060852017-10-04 10:50:51 -07003350 (roam_info &&
Abhishek Singhc9941602016-08-09 16:06:22 +05303351 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003352 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303353 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003354 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303355 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003356 roam_info->statusCode)))) {
Abhishek Singh85283ae2019-03-08 12:00:51 +05303357 wlan_hdd_cfg80211_unlink_bss(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003358 roam_info ?
3359 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003360 sta_ctx->requested_bssid.bytes);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003361 sme_remove_bssid_from_scan_list(mac_handle,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003362 roam_info ?
3363 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003364 sta_ctx->requested_bssid.bytes);
Jeff Johnson29c78672019-02-26 21:05:53 -08003365 if (roam_result !=
Arun Kumar Khandavalli34f69cf2019-02-25 16:46:52 +05303366 eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE)
3367 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303368 }
3369
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 /*
3371 * CR465478: Only send up a connection failure result when CSR
3372 * has completed operation - with a ASSOCIATION_FAILURE status.
3373 */
Jeff Johnson29c78672019-02-26 21:05:53 -08003374 if (eCSR_ROAM_ASSOCIATION_FAILURE == roam_status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375 && !hddDisconInProgress) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003376 if (roam_info) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003377 hdd_err("send connect failure to nl80211: for bssid "
3378 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003379 " result: %d and Status: %d reasoncode: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003380 QDF_MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003381 roam_result, roam_status,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003382 roam_info->reasonCode);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003383 sta_ctx->conn_info.assoc_status_code =
Jeff Johnsonfd060852017-10-04 10:50:51 -07003384 roam_info->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003385 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003386 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003388 " result: %d and status: %d ",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003389 QDF_MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003390 roam_result, roam_status);
Jeff Johnson03294f12016-12-09 17:10:24 -08003391 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003392 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303393 wlan_deregister_txrx_packetdump();
3394
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 /* inform association failure event to nl80211 */
3396 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
Jeff Johnson29c78672019-02-26 21:05:53 -08003397 roam_result) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003398 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303399 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003400 roam_info->bssid.bytes,
3401 roam_info, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303403 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303404 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003405 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303407 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003408 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303409 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303411 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303412 connect_timeout,
3413 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003415 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303416 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003417 roam_info->bssid.bytes,
3418 roam_info, NULL, 0, NULL, 0,
3419 roam_info->reasonCode ?
3420 roam_info->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303422 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303423 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003424 roam_info->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003425 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303426 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003427 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303428 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303430 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303431 connect_timeout,
3432 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003434 hdd_clear_roam_profile_ie(adapter);
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +05303435 sme_reset_key(hdd_ctx->mac_handle,
3436 adapter->vdev_id);
Jeff Johnson29c78672019-02-26 21:05:53 -08003437 } else if ((eCSR_ROAM_CANCELLED == roam_status
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003438 && !hddDisconInProgress)) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003439 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003440 sta_ctx->requested_bssid.bytes,
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003441 NULL, NULL, 0, NULL, 0,
3442 WLAN_STATUS_UNSPECIFIED_FAILURE,
3443 GFP_KERNEL,
3444 connect_timeout,
3445 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 }
3447
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 /*
3449 * Set connection state to eConnectionState_NotConnected only
3450 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003451 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 */
Jeff Johnson29c78672019-02-26 21:05:53 -08003453 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roam_status) ||
3454 (eCSR_ROAM_CANCELLED == roam_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 && !hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003456 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 eConnectionState_NotConnected);
3458 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003459 hdd_wmm_init(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003460
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303461 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003462 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303463 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 WLAN_CONTROL_PATH);
Abhishek Singh0edeba02018-06-05 10:04:08 +05303465 /*
Jeff Johnson29c78672019-02-26 21:05:53 -08003466 * if hddDisconInProgress is set and roam_result is
Abhishek Singh0edeba02018-06-05 10:04:08 +05303467 * eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE that mean HDD is
3468 * waiting on disconnect_comp_var so unblock anyone waiting for
3469 * disconnect to complete.
3470 */
Jeff Johnson29c78672019-02-26 21:05:53 -08003471 if ((roam_result == eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE) &&
Abhishek Singh0edeba02018-06-05 10:04:08 +05303472 hddDisconInProgress)
3473 complete(&adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474 }
3475
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303476 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003477}
3478
3479/**
3480 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
Jeff Johnsonba388342017-10-02 13:31:01 -07003481 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003482 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08003483 * @roam_id: roam id
3484 * @roam_status: roam status
3485 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003486 *
3487 * Here we update the status of the Ibss when we receive information that we
3488 * have started/joined an ibss session.
3489 *
3490 * Return: none
3491 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003492static void hdd_roam_ibss_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003493 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08003494 uint32_t roam_id,
3495 eRoamCmdStatus roam_status,
3496 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003497{
Jeff Johnsonba388342017-10-02 13:31:01 -07003498 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003499
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003500 hdd_debug("%s: id %d, status %d, result %d",
Jeff Johnson29c78672019-02-26 21:05:53 -08003501 adapter->dev->name, roam_id,
3502 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503
Jeff Johnson29c78672019-02-26 21:05:53 -08003504 switch (roam_result) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 /* both IBSS Started and IBSS Join should come in here. */
3506 case eCSR_ROAM_RESULT_IBSS_STARTED:
3507 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3508 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3509 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003510 struct hdd_station_ctx *hdd_sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003511 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512
Jeff Johnsond36fa332019-03-18 13:42:25 -07003513 if (!roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303514 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003515 return;
3516 }
3517
3518 /* When IBSS Started comes from CSR, we need to move
3519 * connection state to IBSS Disconnected (meaning no peers
3520 * are in the IBSS).
3521 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003522 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 eConnectionState_IbssDisconnected);
3524 /* notify wmm */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003525 hdd_wmm_connect(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303527
Jeff Johnson0a082d92019-03-04 12:25:49 -08003528 hdd_sta_ctx->broadcast_sta_id = roam_info->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303529
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003530 if (roam_info->staId < HDD_MAX_ADAPTERS)
3531 hdd_ctx->sta_to_adapter[roam_info->staId] =
3532 adapter;
3533 else
3534 hdd_debug("invalid sta id %d", roam_info->staId);
Abhishek Singh44725482017-11-02 16:53:23 +05303535
Jeff Johnsonfd060852017-10-04 10:50:51 -07003536 hdd_roam_register_sta(adapter, roam_info,
3537 roam_info->staId,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003538 roam_info->pBssDesc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003539
Jeff Johnsonfd060852017-10-04 10:50:51 -07003540 if (roam_info->pBssDesc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541 struct cfg80211_bss *bss;
3542#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3543 struct ieee80211_channel *chan;
3544 int chan_no;
3545 unsigned int freq;
3546#endif
3547 /* we created the IBSS, notify supplicant */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303548 hdd_debug("%s: created ibss " MAC_ADDRESS_STR,
Jeff Johnsonba388342017-10-02 13:31:01 -07003549 adapter->dev->name,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003550 QDF_MAC_ADDR_ARRAY(
Jeff Johnsonfd060852017-10-04 10:50:51 -07003551 roam_info->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552
3553 /* we must first give cfg80211 the BSS information */
Jeff Johnsonba388342017-10-02 13:31:01 -07003554 bss = wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003555 roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003556 if (!bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003557 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003558 adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 return;
3560 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303561 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003562 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3564 WLAN_CONTROL_PATH);
3565
3566#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003567 chan_no = roam_info->pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568
3569 if (chan_no <= 14)
3570 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003571 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 else
3573 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003574 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575
Jeff Johnsonba388342017-10-02 13:31:01 -07003576 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003577
3578 if (chan)
Jeff Johnsonba388342017-10-02 13:31:01 -07003579 cfg80211_ibss_joined(adapter->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003580 bss->bssid, chan,
3581 GFP_KERNEL);
3582 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003583 hdd_warn("%s: chanId: %d, can't find channel",
Jeff Johnsonba388342017-10-02 13:31:01 -07003584 adapter->dev->name,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003585 (int)roam_info->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003587 cfg80211_ibss_joined(adapter->dev, bss->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588 GFP_KERNEL);
3589#endif
3590 cfg80211_put_bss(
Jeff Johnson8095a312017-09-03 09:13:24 -07003591 hdd_ctx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003592 bss);
3593 }
Jeff Johnson29c78672019-02-26 21:05:53 -08003594 if (eCSR_ROAM_RESULT_IBSS_STARTED == roam_result) {
Dustin Brown76cd2932018-09-11 16:03:05 -07003595 policy_mgr_incr_active_session(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003596 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07003597 hdd_green_ap_start_state_mc(hdd_ctx,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303598 adapter->device_mode, true);
Jeff Johnson29c78672019-02-26 21:05:53 -08003599 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roam_result ||
3600 eCSR_ROAM_RESULT_IBSS_COALESCED == roam_result) {
Dustin Brown76cd2932018-09-11 16:03:05 -07003601 policy_mgr_update_connection_info(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003602 adapter->vdev_id);
Krunal Soni2c68f232015-10-26 20:52:51 -07003603 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003604 break;
3605 }
3606
3607 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3608 {
Jeff Johnsonba388342017-10-02 13:31:01 -07003609 hdd_err("%s: unable to create IBSS", adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 break;
3611 }
3612
3613 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003614 hdd_err("%s: unexpected result %d",
Jeff Johnson29c78672019-02-26 21:05:53 -08003615 adapter->dev->name, (int)roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 break;
3617 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618}
3619
3620/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003621 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3622 * @sta_ctx: pointer to hdd station context
3623 * @sta_id: station ID
3624 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625 *
3626 * This information is passed to iwconfig later. The peer that joined
3627 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003628
3629 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003631bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003632 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003634 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003636 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003637 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.sta_id[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003638 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003639 peer_mac_addr, sta_id, idx);
Jeff Johnson0a082d92019-03-04 12:25:49 -08003640 sta_ctx->conn_info.sta_id[idx] = sta_id;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003641 qdf_copy_macaddr(
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003642 &sta_ctx->conn_info.peer_macaddr[idx],
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003643 peer_mac_addr);
3644 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 }
3646 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003647 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003648}
3649
3650/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003651 * hdd_delete_peer() - removes peer from hdd station context peer table
3652 * @sta_ctx: pointer to hdd station context
3653 * @sta_id: station ID
3654 *
3655 * Return: None
3656 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003657void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id)
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003658{
3659 int i;
3660
3661 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003662 if (sta_id == sta_ctx->conn_info.sta_id[i]) {
3663 sta_ctx->conn_info.sta_id[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003664 return;
3665 }
3666 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003667}
3668
3669/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
Jeff Johnsonba388342017-10-02 13:31:01 -07003671 * @adapter: pointer to adapter
Jeff Johnson0a082d92019-03-04 12:25:49 -08003672 * @sta_id: station id
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673 *
3674 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003675 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 * false otherwise.
3677 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08003678static bool roam_remove_ibss_station(struct hdd_adapter *adapter,
3679 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680{
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003681 bool successful = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 int idx = 0;
3683 uint8_t valid_idx = 0;
3684 uint8_t del_idx = 0;
3685 uint8_t empty_slots = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003686 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003687
Naveen Rawatc45d1622016-07-05 12:20:09 -07003688 for (idx = 0; idx < MAX_PEERS; idx++) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003689 if (sta_id == sta_ctx->conn_info.sta_id[idx]) {
3690 sta_ctx->conn_info.sta_id[idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303691 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692
Jeff Johnsond377dce2017-10-04 10:32:42 -07003693 qdf_zero_macaddr(&sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003694 peer_macaddr[idx]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003696 successful = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697
3698 /*
3699 * Note the deleted Index, if its 0 we need special
3700 * handling.
3701 */
3702 del_idx = idx;
3703
3704 empty_slots++;
3705 } else {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003706 if (sta_ctx->conn_info.sta_id[idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003707 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 valid_idx = idx;
3709 } else {
3710 /* Found an empty slot */
3711 empty_slots++;
3712 }
3713 }
3714 }
3715
Naveen Rawatc45d1622016-07-05 12:20:09 -07003716 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 /* Last peer departed, set the IBSS state appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07003718 hdd_conn_set_connection_state(adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003719 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003720 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003721 }
Jeff Johnson0a082d92019-03-04 12:25:49 -08003722 /* Find next active sta_id, to have a valid sta trigger for TL. */
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003723 if (successful) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724 if (del_idx == 0) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003725 if (sta_ctx->conn_info.sta_id[valid_idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003726 HDD_WLAN_INVALID_STA_ID) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003727 sta_ctx->conn_info.sta_id[0] =
3728 sta_ctx->conn_info.sta_id[valid_idx];
Jeff Johnsond377dce2017-10-04 10:32:42 -07003729 qdf_copy_macaddr(&sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003730 peer_macaddr[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07003731 &sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003732 peer_macaddr[valid_idx]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733
Jeff Johnson0a082d92019-03-04 12:25:49 -08003734 sta_ctx->conn_info.sta_id[valid_idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303735 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003736 qdf_zero_macaddr(&sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003737 peer_macaddr[valid_idx]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738 }
3739 }
3740 }
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003741 return successful;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003742}
3743
3744/**
3745 * roam_ibss_connect_handler() - IBSS connection handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003746 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003747 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 *
3749 * We update the status of the IBSS to connected in this function.
3750 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303751 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003753static QDF_STATUS roam_ibss_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003754 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003755{
3756 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003757 /*
3758 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3759 * a partner stations).
3760 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003761 hdd_conn_set_connection_state(adapter, eConnectionState_IbssConnected);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762
3763 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003764 hdd_conn_save_connect_info(adapter, roam_info, eCSR_BSS_TYPE_IBSS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003765
3766 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003767 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003768 /* add bss_id to cfg80211 data base */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003769 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003770 if (!bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003771 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003772 adapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303773 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003774 }
3775 cfg80211_put_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003776 WLAN_HDD_GET_CTX(adapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777 bss);
3778
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303779 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780}
3781
3782/**
3783 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003784 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003785 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08003786 * @roam_id: roam id
3787 * @roam_status: roam status
3788 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003789 *
3790 * This function indicates the Mic failure to the supplicant
3791 *
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003792 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003793 */
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003794static void
Jeff Johnsonba388342017-10-02 13:31:01 -07003795hdd_roam_mic_error_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003796 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797{
Jeff Johnsond377dce2017-10-04 10:32:42 -07003798 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003799 tSirMicFailureInfo *mic_failure_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800
Jeff Johnsone7951512019-02-27 10:02:51 -08003801 if (eConnectionState_Associated != sta_ctx->conn_info.conn_state)
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003802 return;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003803
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003804 mic_failure_info = roam_info->u.pMICFailureInfo;
3805 cfg80211_michael_mic_failure(adapter->dev,
3806 mic_failure_info->taMacAddr,
3807 mic_failure_info->multicast ?
3808 NL80211_KEYTYPE_GROUP :
3809 NL80211_KEYTYPE_PAIRWISE,
3810 mic_failure_info->keyId,
3811 mic_failure_info->TSC,
3812 GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003813}
3814
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003815#ifdef CRYPTO_SET_KEY_CONVERGED
3816static QDF_STATUS wlan_hdd_set_key_helper(struct hdd_adapter *adapter,
3817 uint32_t *roam_id)
3818{
3819 int ret;
3820 struct wlan_objmgr_vdev *vdev;
3821
3822 vdev = hdd_objmgr_get_vdev(adapter);
3823 if (!vdev)
3824 return QDF_STATUS_E_FAILURE;
Kiran Kumar Lokere47d0dac2019-01-24 18:38:33 -08003825 ret = wlan_cfg80211_crypto_add_key(vdev,
3826 WLAN_CRYPTO_KEY_TYPE_UNICAST, 0);
Rajeev Kumar Sirasanagandla25bdfad2019-02-15 19:15:49 +05303827 hdd_objmgr_put_vdev(vdev);
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003828 if (ret != 0) {
3829 hdd_err("crypto add key fail, status: %d", ret);
3830 return QDF_STATUS_E_FAILURE;
3831 }
3832
3833 return QDF_STATUS_SUCCESS;
3834}
3835#else
3836static QDF_STATUS wlan_hdd_set_key_helper(struct hdd_adapter *adapter,
3837 uint32_t *roam_id)
3838{
3839 struct hdd_station_ctx *sta_ctx =
3840 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
3841 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3842
3843 return sme_roam_set_key(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003844 adapter->vdev_id,
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003845 &sta_ctx->ibss_enc_key,
3846 roam_id);
3847}
3848#endif
3849
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850/**
3851 * roam_roam_connect_status_update_handler() - IBSS connect status update
Jeff Johnsonba388342017-10-02 13:31:01 -07003852 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003853 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08003854 * @roam_id: roam id
3855 * @roam_status: roam status
3856 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857 *
3858 * The Ibss connection status is updated regularly here in this function.
3859 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303860 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303862static QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07003863roam_roam_connect_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003864 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08003865 uint32_t roam_id,
3866 eRoamCmdStatus roam_status,
3867 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003868{
Jeff Johnsonba388342017-10-02 13:31:01 -07003869 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003870 struct wlan_objmgr_vdev *vdev;
Rajeev Kumardfa37072017-01-13 16:27:22 -08003871 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303872
Jeff Johnson29c78672019-02-26 21:05:53 -08003873 switch (roam_result) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003874 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3875 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003876 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003877 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003878 struct station_info *stainfo;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003879 eCsrEncryptionType encr_type = sta_ctx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303881 hdd_debug("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303882 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3883 MAC_ADDRESS_STR " and stationID= %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003884 QDF_MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3885 QDF_MAC_ADDR_ARRAY(sta_ctx->conn_info.bssid.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003886 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003888 if (!hdd_save_peer
Jeff Johnsonba388342017-10-02 13:31:01 -07003889 (WLAN_HDD_GET_STATION_CTX_PTR(adapter),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003890 roam_info->staId,
3891 &roam_info->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003892 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003893 break;
3894 }
3895
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003896 if (roam_info->staId < HDD_MAX_ADAPTERS)
3897 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
3898 else
3899 hdd_debug("invalid sta id %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003900
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003901 if (hdd_is_key_install_required_for_ibss(encr_type))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003902 roam_info->fAuthRequired = true;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003903
Jeff Johnson71a1d5c2018-12-30 11:31:04 -08003904 /* Register the Station with datapath for the new peer. */
Jeff Johnsonba388342017-10-02 13:31:01 -07003905 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003906 roam_info,
3907 roam_info->staId,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003908 roam_info->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303909 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson71a1d5c2018-12-30 11:31:04 -08003910 hdd_err("Cannot register STA for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303911 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003912 }
Jeff Johnsond377dce2017-10-04 10:32:42 -07003913 sta_ctx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003914 stainfo = qdf_mem_malloc(sizeof(*stainfo));
Min Liu74a1a502018-10-10 19:59:07 +08003915 if (!stainfo)
Kai Liu7400c5b2016-09-29 15:28:36 +08003916 return QDF_STATUS_E_NOMEM;
Min Liu74a1a502018-10-10 19:59:07 +08003917
Kai Liu7400c5b2016-09-29 15:28:36 +08003918 stainfo->filled = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003919 stainfo->generation = sta_ctx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920
Jeff Johnsonba388342017-10-02 13:31:01 -07003921 cfg80211_new_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003922 (const u8 *)roam_info->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003923 stainfo, GFP_KERNEL);
3924 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003925
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003926 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003927 sta_ctx->ibss_enc_key.keyDirection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928 eSIR_TX_RX;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003929 qdf_copy_macaddr(&sta_ctx->ibss_enc_key.peerMac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003930 &roam_info->peerMac);
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003931 vdev = hdd_objmgr_get_vdev(adapter);
3932 if (!vdev)
3933 return QDF_STATUS_E_FAILURE;
3934 wlan_crypto_update_set_key_peer(vdev, true, 0,
3935 &roam_info->peerMac);
Rajeev Kumar Sirasanagandla25bdfad2019-02-15 19:15:49 +05303936 hdd_objmgr_put_vdev(vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303938 hdd_debug("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003939 encr_type);
Jeff Johnson29c78672019-02-26 21:05:53 -08003940 qdf_status = wlan_hdd_set_key_helper(adapter, &roam_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303941 if (QDF_STATUS_SUCCESS != qdf_status) {
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003942 hdd_err("sme set_key fail status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003943 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303944 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003945 }
3946 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303947 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003948 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3950 WLAN_CONTROL_PATH);
3951 break;
3952 }
3953
3954 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3955 {
3956
Jeff Johnsonfd060852017-10-04 10:50:51 -07003957 roam_ibss_connect_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958
3959 break;
3960 }
3961 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3962 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003963 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003964 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965
Jeff Johnsonfd060852017-10-04 10:50:51 -07003966 if (!roam_remove_ibss_station(adapter, roam_info->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003967 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303969 hdd_debug("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303970 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3971 MAC_ADDRESS_STR " and stationID= %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003972 QDF_MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3973 QDF_MAC_ADDR_ARRAY(sta_ctx->conn_info.bssid.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003974 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003975
Jeff Johnsonfd060852017-10-04 10:50:51 -07003976 hdd_roam_deregister_sta(adapter, roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003978 if (roam_info->staId < HDD_MAX_ADAPTERS)
3979 hdd_ctx->sta_to_adapter[roam_info->staId] = NULL;
3980 else
3981 hdd_debug("invalid sta id %d", roam_info->staId);
3982
Jeff Johnsond377dce2017-10-04 10:32:42 -07003983 sta_ctx->ibss_sta_generation++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984
Jeff Johnsonba388342017-10-02 13:31:01 -07003985 cfg80211_del_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003986 (const u8 *)&roam_info->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 GFP_KERNEL);
3988 break;
3989 }
3990 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3991 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003992 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 /* Stop only when we are inactive */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303994 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003995 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303996 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003997 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07003998 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 eConnectionState_NotConnected);
4000
4001 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07004002 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 break;
4004 }
4005 default:
4006 break;
4007
4008 }
4009
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304010 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004011}
4012
4013#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonba388342017-10-02 13:31:01 -07004014QDF_STATUS hdd_roam_register_tdlssta(struct hdd_adapter *adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08004015 const uint8_t *peerMac, uint16_t sta_id,
Jeff Johnsona8ce1272018-03-01 14:39:10 -08004016 uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304018 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsonc419c172019-03-05 10:59:32 -08004019 struct ol_txrx_desc_type txrx_desc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08004020 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07004021 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4022 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004023
4024 /*
4025 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
4026 * be peer MAC, here we are working on direct Link
4027 */
Jeff Johnsonc419c172019-03-05 10:59:32 -08004028 txrx_desc.sta_id = sta_id;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029
4030 /* set the QoS field appropriately .. */
Jeff Johnsonc419c172019-03-05 10:59:32 -08004031 txrx_desc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032
Dhanashri Atre50141c52016-04-07 13:15:29 -07004033 /* Register the vdev transmit and receive functions */
4034 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
Jinwei Chene6143972019-03-25 19:38:05 +08004035 if (adapter->hdd_ctx->enable_dp_rx_threads) {
4036 txrx_ops.rx.rx = hdd_rx_pkt_thread_enqueue_cbk;
4037 txrx_ops.rx.rx_stack = hdd_rx_packet_cbk;
4038 } else {
4039 txrx_ops.rx.rx = hdd_rx_packet_cbk;
4040 txrx_ops.rx.rx_stack = NULL;
4041 }
4042
Leo Changfdb45c32016-10-28 11:09:23 -07004043 cdp_vdev_register(soc,
Sravan Kumar Kairam43f191b2018-05-04 17:00:39 +05304044 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08004045 (struct cdp_pdev *)pdev, adapter->vdev_id),
Dustin Brown89fa06e2018-09-07 10:47:27 -07004046 adapter, (struct cdp_ctrl_objmgr_vdev *)adapter->vdev,
Sravan Kumar Kairam43f191b2018-05-04 17:00:39 +05304047 &txrx_ops);
Jeff Johnsonba388342017-10-02 13:31:01 -07004048 adapter->tx_fn = txrx_ops.tx.tx;
Poddar, Siddarth31797fa2018-01-22 17:24:15 +05304049 txrx_ops.rx.stats_rx = hdd_tx_rx_collect_connectivity_stats_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050
4051 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004052 qdf_status = cdp_peer_register(soc,
Jeff Johnsonc419c172019-03-05 10:59:32 -08004053 (struct cdp_pdev *)pdev, &txrx_desc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304054 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004055 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304056 qdf_status, qdf_status);
4057 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 }
4059
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304060 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061}
4062
4063/**
4064 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
Jeff Johnsonba388342017-10-02 13:31:01 -07004065 * @adapter: pointer to adapter
Jeff Johnson0a082d92019-03-04 12:25:49 -08004066 * @sta_id: station identifier
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304068 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069 */
Jeff Johnson53367842017-10-03 11:10:34 -07004070QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08004071 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304073 QDF_STATUS qdf_status;
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07004074
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08004075 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004076 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Jeff Johnson0a082d92019-03-04 12:25:49 -08004077 sta_id);
Kabilan Kannanb4e01372018-01-15 13:33:10 -08004078
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304079 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004080}
4081
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004082#else
4083
Jeff Johnsonba388342017-10-02 13:31:01 -07004084inline QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08004085 uint8_t sta_id)
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004086{
4087 return QDF_STATUS_SUCCESS;
4088}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004089#endif
4090
4091#ifdef WLAN_FEATURE_11W
Jeff Johnson72afbf82019-03-10 11:32:52 -07004092
4093#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4094
4095static void hdd_rx_unprot_disassoc(struct net_device *dev,
4096 const u8 *buf, size_t len)
4097{
4098 cfg80211_rx_unprot_mlme_mgmt(dev, buf, len);
4099}
4100
4101static void hdd_rx_unprot_deauth(struct net_device *dev,
4102 const u8 *buf, size_t len)
4103{
4104 cfg80211_rx_unprot_mlme_mgmt(dev, buf, len);
4105}
4106
4107#else
4108
4109static void hdd_rx_unprot_disassoc(struct net_device *dev,
4110 const u8 *buf, size_t len)
4111{
4112 cfg80211_send_unprot_disassoc(dev, buf, len);
4113}
4114
4115static void hdd_rx_unprot_deauth(struct net_device *dev,
4116 const u8 *buf, size_t len)
4117{
4118 cfg80211_send_unprot_deauth(dev, buf, len);
4119}
4120
4121#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) */
4122
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004123/**
4124 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
Jeff Johnson72afbf82019-03-10 11:32:52 -07004125 * @adapter: pointer to the adapter
4126 * @frame_length: Length of the unprotected frame being passed
4127 * @frame: Pointer to the frame buffer
4128 * @frame_type: 802.11 frame type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 *
4130 * This function forwards the unprotected management frame to the supplicant.
4131 *
4132 * Return: nothing
4133 */
4134static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07004135hdd_indicate_unprot_mgmt_frame(struct hdd_adapter *adapter,
Jeff Johnson72afbf82019-03-10 11:32:52 -07004136 uint32_t frame_length,
4137 uint8_t *frame, uint8_t frame_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138{
Jeff Johnson72afbf82019-03-10 11:32:52 -07004139 uint8_t type, subtype;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004141 hdd_debug("Frame Type = %d Frame Length = %d",
Jeff Johnson72afbf82019-03-10 11:32:52 -07004142 frame_type, frame_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004143
Jeff Johnson72afbf82019-03-10 11:32:52 -07004144 if (hdd_validate_adapter(adapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146
Jeff Johnson72afbf82019-03-10 11:32:52 -07004147 if (!frame_length) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004148 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 return;
4150 }
4151
Jeff Johnson72afbf82019-03-10 11:32:52 -07004152 if (!frame) {
4153 hdd_err("frame is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004154 return;
4155 }
4156
Jeff Johnson72afbf82019-03-10 11:32:52 -07004157 type = WLAN_HDD_GET_TYPE_FRM_FC(frame[0]);
4158 if (type != SIR_MAC_MGMT_FRAME) {
4159 hdd_warn("Unexpected frame type %d", type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 return;
4161 }
Jeff Johnson72afbf82019-03-10 11:32:52 -07004162
4163 subtype = WLAN_HDD_GET_SUBTYPE_FRM_FC(frame[0]);
4164 switch (subtype) {
4165 case SIR_MAC_MGMT_DISASSOC:
4166 hdd_rx_unprot_disassoc(adapter->dev, frame, frame_length);
4167 adapter->hdd_stats.hdd_pmf_stats.num_unprot_disassoc_rx++;
4168 break;
4169 case SIR_MAC_MGMT_DEAUTH:
4170 hdd_rx_unprot_deauth(adapter->dev, frame, frame_length);
4171 adapter->hdd_stats.hdd_pmf_stats.num_unprot_deauth_rx++;
4172 break;
4173 default:
4174 hdd_warn("Unexpected frame subtype %d", subtype);
4175 break;
4176 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177}
Jeff Johnson72afbf82019-03-10 11:32:52 -07004178#endif /* WLAN_FEATURE_11W */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004179
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004180#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181/**
4182 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
Jeff Johnsonba388342017-10-02 13:31:01 -07004183 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004184 * @tid: traffic identifier
4185 * @state: state
4186 * @measInterval: measurement interval
4187 *
4188 * This function sends traffic stream metrics IE information to
4189 * the supplicant via wireless event.
4190 *
4191 * Return: none
4192 */
4193static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004194hdd_indicate_tsm_ie(struct hdd_adapter *adapter, uint8_t tid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 uint8_t state, uint16_t measInterval)
4196{
4197 union iwreq_data wrqu;
4198 char buf[IW_CUSTOM_MAX + 1];
4199 int nBytes = 0;
4200
Jeff Johnsond36fa332019-03-18 13:42:25 -07004201 if (!adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004202 return;
4203
4204 /* create the event */
4205 memset(&wrqu, '\0', sizeof(wrqu));
4206 memset(buf, '\0', sizeof(buf));
4207
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004208 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004209 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210
4211 nBytes =
4212 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4213 measInterval);
4214
4215 wrqu.data.pointer = buf;
4216 wrqu.data.length = nBytes;
4217 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004218 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219}
4220
4221/**
4222 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004223 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004224 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 *
4226 * This function sends cckm preauth indication to the supplicant
4227 * via wireless custom event.
4228 *
4229 * Return: none
4230 */
4231static void
Jeff Johnson172237b2017-11-07 15:32:59 -08004232hdd_indicate_cckm_pre_auth(struct hdd_adapter *adapter,
4233 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004234{
4235 union iwreq_data wrqu;
4236 char buf[IW_CUSTOM_MAX + 1];
4237 char *pos = buf;
4238 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4239
Jeff Johnsond36fa332019-03-18 13:42:25 -07004240 if ((!adapter) || (!roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 return;
4242
4243 /* create the event */
4244 memset(&wrqu, '\0', sizeof(wrqu));
4245 memset(buf, '\0', sizeof(buf));
4246
4247 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004248 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004249 QDF_MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07004250 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251
4252 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4253 pos += nBytes;
4254 freeBytes -= nBytes;
4255
Jeff Johnsonfd060852017-10-04 10:50:51 -07004256 qdf_mem_copy(pos, roam_info->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304257 pos += QDF_MAC_ADDR_SIZE;
4258 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259
4260 nBytes = snprintf(pos, freeBytes, " %u:%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004261 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004262 freeBytes -= nBytes;
4263
4264 wrqu.data.pointer = buf;
4265 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4266
4267 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004268 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004269}
4270
4271/**
4272 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004273 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004274 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004275 *
4276 * Return: none
4277 */
4278static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004279hdd_indicate_ese_adj_ap_rep_ind(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004280 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281{
4282 union iwreq_data wrqu;
4283 char buf[IW_CUSTOM_MAX + 1];
4284 int nBytes = 0;
4285
Jeff Johnsond36fa332019-03-18 13:42:25 -07004286 if ((!adapter) || (!roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004287 return;
4288
4289 /* create the event */
4290 memset(&wrqu, '\0', sizeof(wrqu));
4291 memset(buf, '\0', sizeof(buf));
4292
Jeff Johnsonfd060852017-10-04 10:50:51 -07004293 hdd_debug("CCXADJAPREP=%u", roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294
4295 nBytes =
4296 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004297 roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004298
4299 wrqu.data.pointer = buf;
4300 wrqu.data.length = nBytes;
4301
4302 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004303 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004304}
4305
4306/**
4307 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
Jeff Johnsonba388342017-10-02 13:31:01 -07004308 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 * @measurementToken: measurement token
4310 * @flag: flag
4311 * @numBss: number of bss
4312 *
4313 * If the measurement is none and no scan results found,
4314 * indicate the supplicant about measurement done.
4315 *
4316 * Return: none
4317 */
4318void
Jeff Johnsonba388342017-10-02 13:31:01 -07004319hdd_indicate_ese_bcn_report_no_results(const struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320 const uint16_t measurementToken,
4321 const bool flag, const uint8_t numBss)
4322{
4323 union iwreq_data wrqu;
4324 char buf[IW_CUSTOM_MAX];
4325 char *pos = buf;
4326 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4327
4328 memset(&wrqu, '\0', sizeof(wrqu));
4329 memset(buf, '\0', sizeof(buf));
4330
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004331 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004332 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004333
4334 nBytes =
4335 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4336 flag, numBss);
4337
4338 wrqu.data.pointer = buf;
4339 wrqu.data.length = nBytes;
4340 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004341 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004342}
4343
4344/**
4345 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004346 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004347 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004348 *
4349 * If the measurement is none and no scan results found,
4350 * indicate the supplicant about measurement done.
4351 *
4352 * Return: none
4353 */
4354static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004355hdd_indicate_ese_bcn_report_ind(const struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004356 const struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004357{
4358 union iwreq_data wrqu;
4359 char buf[IW_CUSTOM_MAX];
4360 char *pos = buf;
4361 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4362 uint8_t i = 0, len = 0;
4363 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4364 uint8_t lastSent = 0, sendBss = 0;
4365 int bcnRepFieldSize =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004366 sizeof(roam_info->pEseBcnReportRsp->bcnRepBssInfo[0].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004367 bcnReportFields);
4368 uint8_t ieLenByte = 1;
4369 /*
4370 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4371 */
4372#define ESEBCNREPHEADER_LEN (18)
4373
Jeff Johnsond36fa332019-03-18 13:42:25 -07004374 if ((!adapter) || (!roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375 return;
4376
4377 /*
4378 * Custom event can pass maximum of 256 bytes of data,
4379 * based on the IE len we need to identify how many BSS info can
4380 * be filled in to custom event data.
4381 */
4382 /*
4383 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4384 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4385 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4386 */
4387
Jeff Johnsonfd060852017-10-04 10:50:51 -07004388 if ((roam_info->pEseBcnReportRsp->flag >> 1)
4389 && (!roam_info->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004390 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004391 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004392 * indicate the supplicant about measurement done
4393 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 hdd_indicate_ese_bcn_report_no_results(
Jeff Johnsonba388342017-10-02 13:31:01 -07004395 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004396 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004397 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004398 roam_info->pEseBcnReportRsp->flag,
4399 roam_info->pEseBcnReportRsp->numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004401 while (lastSent < roam_info->pEseBcnReportRsp->numBss) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004402 memset(&wrqu, '\0', sizeof(wrqu));
4403 memset(buf, '\0', sizeof(buf));
4404 tot_bcn_ieLen = 0;
4405 sendBss = 0;
4406 pos = buf;
4407 freeBytes = IW_CUSTOM_MAX;
4408
4409 for (i = lastSent;
Jeff Johnsonfd060852017-10-04 10:50:51 -07004410 i < roam_info->pEseBcnReportRsp->numBss; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 len =
4412 bcnRepFieldSize + ieLenByte +
Jeff Johnsonfd060852017-10-04 10:50:51 -07004413 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414 bcnRepBssInfo[i].ieLen;
4415 if ((len + tot_bcn_ieLen) >
4416 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4417 break;
4418 }
4419 tot_bcn_ieLen += len;
4420 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004421 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004422 i, bcnRepFieldSize, 1,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004423 roam_info->pEseBcnReportRsp->
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004424 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004425 }
4426
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004427 hdd_debug("Sending %d BSS Info", sendBss);
4428 hdd_debug("CCXBCNREP=%d %d %d %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004429 roam_info->pEseBcnReportRsp->measurementToken,
4430 roam_info->pEseBcnReportRsp->flag, sendBss,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004431 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004432
4433 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004434 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004436 roam_info->pEseBcnReportRsp->flag,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 sendBss);
4438 pos += nBytes;
4439 freeBytes -= nBytes;
4440
4441 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304442 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443 sizeof(tot_bcn_ieLen));
4444 pos += sizeof(tot_bcn_ieLen);
4445 freeBytes -= sizeof(tot_bcn_ieLen);
4446
4447 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004448 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004449 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4450 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4451 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004452 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453 bcnRepBssInfo[i +
4454 lastSent].bcnReportFields.
4455 ChanNum,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004456 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004457 bcnRepBssInfo[i +
4458 lastSent].bcnReportFields.
4459 Spare,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004460 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 bcnRepBssInfo[i +
4462 lastSent].bcnReportFields.
4463 MeasDuration,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004464 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004465 bcnRepBssInfo[i +
4466 lastSent].bcnReportFields.
4467 PhyType,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004468 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 bcnRepBssInfo[i +
4470 lastSent].bcnReportFields.
4471 RecvSigPower,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004472 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004473 bcnRepBssInfo[i +
4474 lastSent].bcnReportFields.
4475 ParentTsf,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004476 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004477 bcnRepBssInfo[i +
4478 lastSent].bcnReportFields.
4479 TargetTsf[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004480 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004481 bcnRepBssInfo[i +
4482 lastSent].bcnReportFields.
4483 TargetTsf[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004484 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004485 bcnRepBssInfo[i +
4486 lastSent].bcnReportFields.
4487 BcnInterval,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004488 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 bcnRepBssInfo[i +
4490 lastSent].bcnReportFields.
4491 CapabilityInfo,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004492 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 bcnRepBssInfo[i +
4494 lastSent].bcnReportFields.
4495 Bssid[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004496 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 bcnRepBssInfo[i +
4498 lastSent].bcnReportFields.
4499 Bssid[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004500 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004501 bcnRepBssInfo[i +
4502 lastSent].bcnReportFields.
4503 Bssid[2],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004504 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 bcnRepBssInfo[i +
4506 lastSent].bcnReportFields.
4507 Bssid[3],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004508 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 bcnRepBssInfo[i +
4510 lastSent].bcnReportFields.
4511 Bssid[4],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004512 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513 bcnRepBssInfo[i +
4514 lastSent].bcnReportFields.
4515 Bssid[5]);
4516
4517 /* bcn report fields are copied */
4518 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004519 sizeof(roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520 bcnRepBssInfo[i +
4521 lastSent].
4522 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304523 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004524 (char *)&roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004525 pEseBcnReportRsp->bcnRepBssInfo[i +
4526 lastSent].
4527 bcnReportFields, len);
4528 pos += len;
4529 freeBytes -= len;
4530
4531 /* Add 1 byte of ie len */
4532 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004533 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004534 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304535 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004536 pos += sizeof(len);
4537 freeBytes -= sizeof(len);
4538
4539 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304540 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004541 (char *)roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004542 pEseBcnReportRsp->bcnRepBssInfo[i +
4543 lastSent].
4544 pBuf, len);
4545 pos += len;
4546 freeBytes -= len;
4547 }
4548
4549 wrqu.data.pointer = buf;
4550 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4551
4552 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004553 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004554 buf);
4555 lastSent += sendBss;
4556 }
4557 }
4558}
4559
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004560#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004561
4562/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304563 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
Jeff Johnsond377dce2017-10-04 10:32:42 -07004564 * @sta_ctx: Station Context
Komal Seelam98760ba2015-12-15 11:05:18 +05304565 *
4566 * API to check if the connection authentication type is 8021x_sha256.
4567 *
4568 * Return: bool
4569 */
4570#ifdef WLAN_FEATURE_11W
Jeff Johnson435e1b82017-10-07 14:13:10 -07004571static inline bool
4572hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304573{
4574 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
Jeff Johnson96e33512019-02-27 15:10:21 -08004575 sta_ctx->conn_info.auth_type;
Komal Seelam98760ba2015-12-15 11:05:18 +05304576}
4577#else
Jeff Johnson435e1b82017-10-07 14:13:10 -07004578static inline bool
4579hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304580{
4581 return false;
4582}
4583#endif
4584
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304585/*
4586 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4587 * @adapter: Pointer to adapter context
4588 * @roam_info: Pointer to roam info
4589 *
4590 * Return: None
4591 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004592static void hdd_roam_channel_switch_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004593 struct csr_roam_info *roam_info)
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304594{
4595 struct hdd_chan_change_params chan_change;
4596 struct cfg80211_bss *bss;
4597 struct net_device *dev = adapter->dev;
4598 struct wireless_dev *wdev = dev->ieee80211_ptr;
4599 struct wiphy *wiphy = wdev->wiphy;
4600 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -07004601 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304602 mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304603
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004604 hdd_debug("channel switch for session:%d to channel:%d",
Jeff Johnson1abc5662019-02-04 14:27:02 -08004605 adapter->vdev_id, roam_info->chan_info.chan_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304606
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304607 /* Enable Roaming on STA interface which was disabled before CSA */
4608 if (adapter->device_mode == QDF_STA_MODE)
Jeff Johnson1abc5662019-02-04 14:27:02 -08004609 sme_start_roaming(mac_handle, adapter->vdev_id,
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304610 REASON_DRIVER_ENABLED);
4611
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304612 chan_change.chan = roam_info->chan_info.chan_id;
4613 chan_change.chan_params.ch_width =
4614 roam_info->chan_info.ch_width;
4615 chan_change.chan_params.sec_ch_offset =
4616 roam_info->chan_info.sec_ch_offset;
4617 chan_change.chan_params.center_freq_seg0 =
4618 roam_info->chan_info.band_center_freq1;
4619 chan_change.chan_params.center_freq_seg1 =
4620 roam_info->chan_info.band_center_freq2;
4621
4622 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07004623 if (!bss)
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304624 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4625 else
4626 cfg80211_put_bss(wiphy, bss);
4627
bings58ce8622017-07-10 15:55:36 +08004628 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4629 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304630 if (QDF_IS_STATUS_ERROR(status))
4631 hdd_err("channel change notification failed");
4632
Dustin Brown76cd2932018-09-11 16:03:05 -07004633 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08004634 adapter->vdev_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304635 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004636 hdd_debug("set hw mode change not done");
Abhishek Singhbfaebe32019-03-19 13:37:55 +05304637
4638 hdd_debug("check for SAP restart");
4639 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->psoc);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304640}
4641
Komal Seelam98760ba2015-12-15 11:05:18 +05304642/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004643 * hdd_sme_roam_callback() - hdd sme roam callback
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004644 * @context: pointer to adapter context
Jeff Johnsonfd060852017-10-04 10:50:51 -07004645 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08004646 * @roam_id: roam id
4647 * @roam_status: roam status
4648 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304650 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304652QDF_STATUS
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004653hdd_sme_roam_callback(void *context, struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004654 uint32_t roam_id,
4655 eRoamCmdStatus roam_status, eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004656{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304657 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004658 struct hdd_adapter *adapter = context;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004659 struct hdd_station_ctx *sta_ctx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304660 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304661 struct cfg80211_bss *bss_status;
Jeff Johnson49432062017-08-28 12:08:45 -07004662 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004663
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004664 hdd_debug("CSR Callback: status=%d result=%d roamID=%d",
4665 roam_status, roam_result, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666
4667 /* Sanity check */
Jeff Johnsond36fa332019-03-18 13:42:25 -07004668 if ((!adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004669 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304670 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 }
4672
Jeff Johnsond377dce2017-10-04 10:32:42 -07004673 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonba388342017-10-02 13:31:01 -07004674 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675
Abhishek Singhf723e3d2018-02-20 18:02:37 +05304676 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Jeff Johnson29c78672019-02-26 21:05:53 -08004677 adapter->vdev_id, roam_status));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304678
Jeff Johnson29c78672019-02-26 21:05:53 -08004679 switch (roam_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004680 /*
4681 * We did pre-auth,then we attempted a 11r or ese reassoc.
4682 * reassoc failed due to failure, timeout, reject from ap
4683 * in any case tell the OS, our carrier is off and mark
4684 * interface down.
4685 */
4686 case eCSR_ROAM_FT_REASSOC_FAILED:
Jeff Johnson29c78672019-02-26 21:05:53 -08004687 hdd_err("Reassoc Failed with roam_status: %d roam_result: %d SessionID: %d",
4688 roam_status, roam_result, adapter->vdev_id);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304689 qdf_ret_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08004690 hdd_dis_connect_handler(adapter, roam_info, roam_id,
4691 roam_status, roam_result);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004692 sta_ctx->ft_carrier_on = false;
Jeff Johnson690fe952017-10-25 11:48:39 -07004693 sta_ctx->hdd_reassoc_scenario = false;
4694 hdd_debug("hdd_reassoc_scenario set to: %d, ReAssoc Failed, session: %d",
Jeff Johnson1abc5662019-02-04 14:27:02 -08004695 sta_ctx->hdd_reassoc_scenario, adapter->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004696 break;
4697
4698 case eCSR_ROAM_FT_START:
4699 /*
4700 * When we roam for ESE and 11r, we dont want the OS to be
4701 * informed that the link is down. So mark the link ready for
4702 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4703 * be received. Where in we will not mark the link down
4704 * Also we want to stop tx at this point when we will be
4705 * doing disassoc at this time. This saves 30-60 msec
4706 * after reassoc.
4707 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304708 hdd_debug("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004709 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004710 hdd_napi_serialize(1);
Jeff Johnsonba388342017-10-02 13:31:01 -07004711 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304712 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004713 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07004714 status = hdd_roam_deregister_sta(adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08004715 sta_ctx->conn_info.sta_id[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304716 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304717 qdf_ret_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004718 sta_ctx->ft_carrier_on = true;
Jeff Johnson690fe952017-10-25 11:48:39 -07004719 sta_ctx->hdd_reassoc_scenario = true;
4720 hdd_debug("hdd_reassoc_scenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
Jeff Johnson1abc5662019-02-04 14:27:02 -08004721 sta_ctx->hdd_reassoc_scenario, adapter->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004723 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004724 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004725 hdd_napi_serialize(0);
Jeff Johnson29c78672019-02-26 21:05:53 -08004726 if (roam_result == eCSR_ROAM_RESULT_FAILURE) {
Jeff Johnsonba388342017-10-02 13:31:01 -07004727 adapter->roam_ho_fail = true;
Pragaspathi Thilagaraj8ea625d2019-02-14 16:11:45 +05304728 hdd_set_roaming_in_progress(false);
4729 } else {
Jeff Johnsonba388342017-10-02 13:31:01 -07004730 adapter->roam_ho_fail = false;
Pragaspathi Thilagaraj8ea625d2019-02-14 16:11:45 +05304731 }
Jeff Johnsonba388342017-10-02 13:31:01 -07004732 complete(&adapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004733 break;
Pragaspathi Thilagaraj8ea625d2019-02-14 16:11:45 +05304734 case eCSR_ROAM_SYNCH_COMPLETE:
4735 hdd_debug("LFR3: Roam synch complete");
4736 hdd_set_roaming_in_progress(false);
4737 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004738 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004739 /* notify apps that we can't pass traffic anymore */
Dustin Browna7bb6ae2018-08-16 16:51:50 -07004740 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004741 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304742 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743 WLAN_CONTROL_PATH);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004744 if (sta_ctx->ft_carrier_on == false) {
Jeff Johnsonba388342017-10-02 13:31:01 -07004745 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004746 WLAN_NETIF_CARRIER_OFF,
4747 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004748 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004749 break;
4750 case eCSR_ROAM_LOSTLINK:
Jeff Johnson29c78672019-02-26 21:05:53 -08004751 if (roam_result == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004752 hdd_debug("Roaming started due to connection lost");
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304753 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004754 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304755 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 WLAN_CONTROL_PATH);
4757 break;
4758 }
4759 case eCSR_ROAM_DISASSOCIATED:
4760 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004761 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304762 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004763 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304764 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004765 adapter->roam_ho_fail = false;
4766 complete(&adapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 /* Call to clear any MC Addr List filter applied after
4769 * successful connection.
4770 */
Jeff Johnsonba388342017-10-02 13:31:01 -07004771 hdd_disable_and_flush_mc_addr_list(adapter,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304772 pmo_peer_disconnect);
4773 qdf_ret_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08004774 hdd_dis_connect_handler(adapter, roam_info, roam_id,
4775 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004776 }
4777 break;
4778 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004779 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304780 qdf_ret_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08004781 hdd_dis_connect_handler(adapter, roam_info, roam_id,
4782 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004783 break;
4784 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004785 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 /*
4787 * To Do - address probable memory leak with WEP encryption upon
4788 * successful association.
4789 */
Jeff Johnson29c78672019-02-26 21:05:53 -08004790 if (eCSR_ROAM_RESULT_ASSOCIATED != roam_result) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004791 /* Clear saved connection information in HDD */
4792 hdd_conn_remove_connect_info(
Jeff Johnsonba388342017-10-02 13:31:01 -07004793 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304795 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004796 hdd_association_completion_handler(adapter, roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004797 roam_id, roam_status,
4798 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004799#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004800 if (roam_info)
4801 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802#endif
4803 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004804 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004805 hdd_debug("****eCSR_ROAM_CANCELLED****");
Jeff Johnson48c05c72018-04-29 19:47:12 -07004806 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 case eCSR_ROAM_ASSOCIATION_FAILURE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004808 qdf_ret_status = hdd_association_completion_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004809 roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004810 roam_id,
4811 roam_status,
4812 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004813 break;
4814 case eCSR_ROAM_IBSS_IND:
Jeff Johnson29c78672019-02-26 21:05:53 -08004815 hdd_roam_ibss_indication_handler(adapter, roam_info, roam_id,
4816 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004817 break;
4818
4819 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304820 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07004821 roam_roam_connect_status_update_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004822 roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004823 roam_id,
4824 roam_status,
4825 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004826 break;
4827
4828 case eCSR_ROAM_MIC_ERROR_IND:
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07004829 hdd_roam_mic_error_indication_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004830 break;
4831
4832 case eCSR_ROAM_SET_KEY_COMPLETE:
4833 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304834 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004835 hdd_roam_set_key_complete_handler(adapter, roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004836 roam_id, roam_status,
4837 roam_result);
4838 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
Jeff Johnson690fe952017-10-25 11:48:39 -07004839 sta_ctx->hdd_reassoc_scenario = false;
4840 hdd_debug("hdd_reassoc_scenario set to: %d, set key complete, session: %d",
4841 sta_ctx->hdd_reassoc_scenario,
Jeff Johnson1abc5662019-02-04 14:27:02 -08004842 adapter->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843 }
4844 }
4845#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsond36fa332019-03-18 13:42:25 -07004846 if (roam_info)
Jeff Johnsonfd060852017-10-04 10:50:51 -07004847 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004848#endif
4849 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004850
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 case eCSR_ROAM_FT_RESPONSE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004852 hdd_send_ft_event(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004854
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnson96e33512019-02-27 15:10:21 -08004856 if (eCSR_AUTH_TYPE_RSN == sta_ctx->conn_info.auth_type
Jeff Johnsond377dce2017-10-04 10:32:42 -07004857 || hdd_is_8021x_sha256_auth_type(sta_ctx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004858 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304859 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 wlan_hdd_cfg80211_pmksa_candidate_notify(
Jeff Johnsonfd060852017-10-04 10:50:51 -07004861 adapter, roam_info, 1, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004862 }
4863 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004864
4865#ifdef FEATURE_WLAN_LFR_METRICS
4866 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4867 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304868 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004869 wlan_hdd_cfg80211_roam_metrics_preauth(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004870 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304871 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 }
4873 break;
4874 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4875 /*
4876 * This event will notify pre-auth completion in case of success
4877 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304878 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004879 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004880 roam_info, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304881 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 }
4883 break;
4884 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4885 /*
4886 * This event will notify pre-auth completion incase of failure.
4887 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304888 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004889 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004890 roam_info, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304891 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004892 }
4893 break;
4894 case eCSR_ROAM_HANDOVER_SUCCESS:
4895 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004896 * It will be only invoked on success
4897 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304898 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004899 wlan_hdd_cfg80211_roam_metrics_handover(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004900 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304901 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 }
4903 break;
4904#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004905#ifdef WLAN_FEATURE_11W
4906 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
gaurank kathpaliaea6b5e62018-07-05 20:41:28 +05304907 if (roam_info)
4908 hdd_indicate_unprot_mgmt_frame(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004909 roam_info->nFrameLength,
4910 roam_info->pbFrames,
4911 roam_info->frameType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 break;
4913#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004914#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004915 case eCSR_ROAM_TSM_IE_IND:
gaurank kathpaliaea6b5e62018-07-05 20:41:28 +05304916 if (roam_info)
Jeff Johnson85ddb772019-02-02 19:01:52 -08004917 hdd_indicate_tsm_ie(adapter, roam_info->tsm_ie.tsid,
4918 roam_info->tsm_ie.state,
4919 roam_info->tsm_ie.msmt_interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 break;
4921
4922 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4923 {
4924 if (eCSR_AUTH_TYPE_CCKM_WPA ==
Jeff Johnson96e33512019-02-27 15:10:21 -08004925 sta_ctx->conn_info.auth_type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926 || eCSR_AUTH_TYPE_CCKM_RSN ==
Jeff Johnson96e33512019-02-27 15:10:21 -08004927 sta_ctx->conn_info.auth_type) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004928 hdd_indicate_cckm_pre_auth(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 }
4930 break;
4931 }
4932
4933 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4934 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004935 hdd_indicate_ese_adj_ap_rep_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936 break;
4937 }
4938
4939 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4940 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004941 hdd_indicate_ese_bcn_report_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 break;
4943 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004944#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304945 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004946 hdd_roam_channel_switch_handler(adapter, roam_info);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304947 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304948
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304949 case eCSR_ROAM_UPDATE_SCAN_RESULT:
Jeff Johnsond36fa332019-03-18 13:42:25 -07004950 if ((roam_info) && (roam_info->pBssDesc)) {
Abhishek Singhf05b0cb62018-02-20 18:06:13 +05304951 bss_status = wlan_hdd_inform_bss_frame(adapter,
4952 roam_info->pBssDesc);
Jeff Johnsond36fa332019-03-18 13:42:25 -07004953 if (!bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004954 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304955 else
4956 cfg80211_put_bss(
4957#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
Jeff Johnsonba388342017-10-02 13:31:01 -07004958 (WLAN_HDD_GET_CTX(adapter))->wiphy,
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304959#endif
4960 bss_status);
4961 }
4962 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004963 case eCSR_ROAM_NDP_STATUS_UPDATE:
Jeff Johnson29c78672019-02-26 21:05:53 -08004964 hdd_ndp_event_handler(adapter, roam_info, roam_id, roam_status,
4965 roam_result);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004966 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004967 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004968 hdd_debug("Process ROAM_START from firmware");
Jeff Johnsonba388342017-10-02 13:31:01 -07004969 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304970 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004971 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004972 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004973 hdd_set_roaming_in_progress(true);
Dustin Brown76cd2932018-09-11 16:03:05 -07004974 policy_mgr_restart_opportunistic_timer(hdd_ctx->psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004975 break;
4976 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004977 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004978 hdd_napi_serialize(0);
Jeff Johnsonba388342017-10-02 13:31:01 -07004979 wlan_hdd_netif_queue_control(adapter,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004980 WLAN_WAKE_ALL_NETIF_QUEUE,
4981 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004982 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004983 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004984 adapter->roam_ho_fail = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004985 sta_ctx->ft_carrier_on = false;
Jeff Johnsonba388342017-10-02 13:31:01 -07004986 complete(&adapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004987 break;
4988
Padma, Santhosh Kumareb90a552018-01-16 19:41:58 +05304989 case eCSR_ROAM_SAE_COMPUTE:
4990 if (roam_info)
4991 wlan_hdd_sae_callback(adapter, roam_info);
4992 break;
4993
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05304994 case eCSR_ROAM_ROAMING_START:
4995 /*
4996 * For LFR2, Handle roaming start to remove disassociated
4997 * session
4998 */
4999 if (roaming_offload_enabled(hdd_ctx))
5000 break;
Jeff Johnson29c78672019-02-26 21:05:53 -08005001 if (roam_result == eCSR_ROAM_RESULT_NOT_ASSOCIATED) {
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05305002 hdd_debug("Decrement session of disassociated AP device_mode %d sessionId %d",
5003 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08005004 adapter->vdev_id);
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05305005 policy_mgr_decr_session_set_pcl(hdd_ctx->psoc,
5006 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08005007 adapter->vdev_id);
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05305008 }
5009 break;
5010
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005011 default:
5012 break;
5013 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305014 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015}
5016
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305017#ifdef WLAN_FEATURE_FILS_SK
5018/**
5019 * hdd_translate_fils_rsn_to_csr_auth() - Translate FILS RSN to CSR auth type
5020 * @auth_suite: auth suite
5021 * @auth_type: pointer to eCsrAuthType
5022 *
5023 * Return: None
5024 */
5025static void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
5026 eCsrAuthType *auth_type)
5027{
5028 if (!memcmp(auth_suite, ccp_rsn_oui_0e, 4))
5029 *auth_type = eCSR_AUTH_TYPE_FILS_SHA256;
5030 else if (!memcmp(auth_suite, ccp_rsn_oui_0f, 4))
5031 *auth_type = eCSR_AUTH_TYPE_FILS_SHA384;
5032 else if (!memcmp(auth_suite, ccp_rsn_oui_10, 4))
5033 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA256;
5034 else if (!memcmp(auth_suite, ccp_rsn_oui_11, 4))
5035 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA384;
5036}
5037#else
5038static inline void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
5039 eCsrAuthType *auth_type)
5040{
5041}
5042#endif
5043
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305044#ifdef WLAN_FEATURE_SAE
5045/**
5046 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
5047 * @auth_suite: auth suite
5048 * @auth_type: pointer to eCsrAuthType
5049 *
5050 * Return: None
5051 */
5052static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
5053 eCsrAuthType *auth_type)
5054{
5055 if (qdf_mem_cmp(auth_suite, ccp_rsn_oui_80, 4) == 0)
5056 *auth_type = eCSR_AUTH_TYPE_SAE;
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305057 else if (qdf_mem_cmp(auth_suite, ccp_rsn_oui_90, 4) == 0)
5058 *auth_type = eCSR_AUTH_TYPE_FT_SAE;
5059
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305060}
5061#else
5062static inline void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
5063 eCsrAuthType *auth_type)
5064{
5065}
5066#endif
5067
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005068/**
5069 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5070 * @auth_suite: auth suite
5071 *
5072 * Return: eCsrAuthType enumeration
5073 */
5074eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5075{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305076 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 /* is the auth type supported? */
5078 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5079 auth_type = eCSR_AUTH_TYPE_RSN;
5080 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5081 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005082 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083 /* Check for 11r FT Authentication with PSK */
5084 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5085 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5086 /* Check for 11R FT Authentication with 802.1X */
5087 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5088 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089#ifdef FEATURE_WLAN_ESE
5090 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5091 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5092 } else
5093#endif /* FEATURE_WLAN_ESE */
5094#ifdef WLAN_FEATURE_11W
5095 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5096 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5097 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5098 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305099 } else if (memcmp(auth_suite, ccp_rsn_oui_18, 4) == 0) {
5100 auth_type = eCSR_AUTH_TYPE_OWE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005101 } else
5102#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305103 if (memcmp(auth_suite, ccp_rsn_oui_12, 4) == 0) {
5104 auth_type = eCSR_AUTH_TYPE_DPP_RSN;
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305105 } else if (memcmp(auth_suite, ccp_rsn_oui_0b, 4) == 0) {
5106 /* Check for Suite B EAP 256 */
5107 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
5108 } else if (memcmp(auth_suite, ccp_rsn_oui_0c, 4) == 0) {
5109 /* Check for Suite B EAP 384 */
5110 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305111 } else if (memcmp(auth_suite, ccp_rsn_oui_0d, 4) == 0) {
5112 /* Check for FT Suite B EAP 384 */
5113 auth_type = eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384;
Srinivas Dasarib328f1a2018-12-18 17:45:06 +05305114 } else if (memcmp(auth_suite, ccp_rsn_oui_13, 4) == 0) {
5115 auth_type = eCSR_AUTH_TYPE_OSEN;
Jeff Johnson109e79d2018-02-27 15:10:04 -08005116 } else {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305117 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305118 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005119 }
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305120 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005121 return auth_type;
5122}
5123
5124/**
5125 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5126 * @auth_suite: auth suite
5127 *
5128 * Return: eCsrAuthType enumeration
5129 */
5130eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5131{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305132 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005133 /* is the auth type supported? */
5134 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5135 auth_type = eCSR_AUTH_TYPE_WPA;
5136 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5137 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5138 } else
5139#ifdef FEATURE_WLAN_ESE
5140 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5141 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5142 } else
5143#endif /* FEATURE_WLAN_ESE */
5144 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305145 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005146 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005147 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 return auth_type;
5149}
5150
5151/**
5152 * hdd_translate_rsn_to_csr_encryption_type() -
5153 * Translate RSN to CSR encryption type
5154 * @cipher_suite: cipher suite
5155 *
5156 * Return: eCsrEncryptionType enumeration
5157 */
5158eCsrEncryptionType
5159hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5160{
5161 eCsrEncryptionType cipher_type;
5162
5163 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5164 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05305165 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
5166 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
5167 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
5168 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5170 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5171 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5172 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5173 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5174 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5175 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5176 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5177 else
5178 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5179
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005180 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005181 return cipher_type;
5182}
5183
5184/**
5185 * hdd_translate_wpa_to_csr_encryption_type() -
5186 * Translate WPA to CSR encryption type
5187 * @cipher_suite: cipher suite
5188 *
5189 * Return: eCsrEncryptionType enumeration
5190 */
5191eCsrEncryptionType
5192hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5193{
5194 eCsrEncryptionType cipher_type;
5195
5196 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5197 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5198 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5199 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5200 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5201 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5202 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5203 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5204 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5205 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5206 else
5207 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5208
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005209 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 return cipher_type;
5211}
5212
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305213#ifdef WLAN_FEATURE_FILS_SK
gaurank kathpalia82a1b2b2018-07-10 16:49:10 +05305214bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305215{
Jeff Johnson844eec72018-03-13 11:48:18 -07005216 struct csr_roam_profile *roam_profile;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305217
Jeff Johnson844eec72018-03-13 11:48:18 -07005218 roam_profile = hdd_roam_profile(adapter);
5219 if (roam_profile->fils_con_info)
5220 return roam_profile->fils_con_info->is_fils_connection;
Min Liuab6ed4f2018-01-09 13:13:57 +08005221
5222 return false;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305223}
5224#else
gaurank kathpalia82a1b2b2018-07-10 16:49:10 +05305225bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305226{
5227 return false;
5228}
5229#endif
5230
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005231/**
5232 * hdd_process_genie() - process gen ie
Jeff Johnsonba388342017-10-02 13:31:01 -07005233 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 * @bssid: pointer to mac address
Jeff Johnsona376a032019-03-09 22:39:27 -08005235 * @encrypt_type: pointer to encryption type
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005236 * @mc_encrypt_type: pointer to multicast encryption type
Jeff Johnson4f1be2d2019-03-09 22:52:04 -08005237 * @auth_type: pointer to auth type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005238 *
5239 * Return: 0 on success, error number otherwise
5240 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005241static int32_t hdd_process_genie(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005242 u8 *bssid,
Jeff Johnsona376a032019-03-09 22:39:27 -08005243 eCsrEncryptionType *encrypt_type,
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005244 eCsrEncryptionType *mc_encrypt_type,
Jeff Johnson4f1be2d2019-03-09 22:52:04 -08005245 eCsrAuthType *auth_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005246#ifdef WLAN_FEATURE_11W
Jeff Johnson78cbade2019-03-10 21:59:35 -07005247 uint8_t *mfp_required, uint8_t *mfp_capable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005248#endif
5249 uint16_t gen_ie_len, uint8_t *gen_ie)
5250{
Jeff Johnsonf7187f22018-06-13 22:02:19 -07005251 mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter);
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005252 tDot11fIERSN dot11_rsn_ie = {0};
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005253 tDot11fIEWPA dot11_wpa_ie = {0};
Jeff Johnsond062b8d2019-03-09 20:31:13 -08005254 uint8_t *rsn_ie;
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005255 uint16_t rsn_ie_len;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305256 uint32_t parse_status;
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005257#ifdef WLAN_CONV_CRYPTO_SUPPORTED
5258 uint16_t rsn_cap = 0;
5259#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260
5261 /*
5262 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5263 * setting present flag to 0.
5264 */
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005265 memset(&dot11_wpa_ie, 0, sizeof(tDot11fIEWPA));
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005266 memset(&dot11_rsn_ie, 0, sizeof(tDot11fIERSN));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005267
5268 /* Type check */
5269 if (gen_ie[0] == DOT11F_EID_RSN) {
5270 /* Validity checks */
5271 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5272 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005273 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005274 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 return -EINVAL;
5276 }
5277 /* Skip past the EID byte and length byte */
Jeff Johnsond062b8d2019-03-09 20:31:13 -08005278 rsn_ie = gen_ie + 2;
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005279 rsn_ie_len = gen_ie_len - 2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005280 /* Unpack the RSN IE */
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005281 parse_status = sme_unpack_rsn_ie(mac_handle, rsn_ie, rsn_ie_len,
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005282 &dot11_rsn_ie, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305283 if (!DOT11F_SUCCEEDED(parse_status)) {
5284 hdd_err("Invalid RSN IE: parse status %d",
5285 parse_status);
5286 return -EINVAL;
5287 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05305288 hdd_debug("gp_cipher_suite_present: %d",
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005289 dot11_rsn_ie.gp_cipher_suite_present);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005290 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005291 hdd_debug("pairwise cipher suite count: %d",
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005292 dot11_rsn_ie.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005293 hdd_debug("authentication suite count: %d",
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005294 dot11_rsn_ie.akm_suite_cnt);
5295 /* dot11_rsn_ie.akm_suite_cnt */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296 /* Just translate the FIRST one */
Jeff Johnson4f1be2d2019-03-09 22:52:04 -08005297 *auth_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005298 hdd_translate_rsn_to_csr_auth_type(
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005299 dot11_rsn_ie.akm_suite[0]);
5300 /* dot11_rsn_ie.pwise_cipher_suite_count */
Jeff Johnsona376a032019-03-09 22:39:27 -08005301 *encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005302 hdd_translate_rsn_to_csr_encryption_type(
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005303 dot11_rsn_ie.pwise_cipher_suites[0]);
5304 /* dot11_rsn_ie.gp_cipher_suite_count */
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005305 *mc_encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306 hdd_translate_rsn_to_csr_encryption_type(
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005307 dot11_rsn_ie.gp_cipher_suite);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005308#ifdef WLAN_FEATURE_11W
Jeff Johnson9bf800e2019-03-10 21:58:34 -07005309 *mfp_required = (dot11_rsn_ie.RSN_Cap[0] >> 6) & 0x1;
Jeff Johnson78cbade2019-03-10 21:59:35 -07005310 *mfp_capable = csr_is_mfpc_capable(&dot11_rsn_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005311#endif
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005312#ifdef WLAN_CONV_CRYPTO_SUPPORTED
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005313 qdf_mem_copy(&rsn_cap, dot11_rsn_ie.RSN_Cap, sizeof(rsn_cap));
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005314 wlan_crypto_set_vdev_param(adapter->vdev,
5315 WLAN_CRYPTO_PARAM_RSN_CAP, rsn_cap);
5316#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5318 /* Validity checks */
5319 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5320 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005321 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005322 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 return -EINVAL;
5324 }
5325 /* Skip past the EID and length byte - and four byte WiFi OUI */
Jeff Johnsond062b8d2019-03-09 20:31:13 -08005326 rsn_ie = gen_ie + 2 + 4;
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005327 rsn_ie_len = gen_ie_len - (2 + 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 /* Unpack the WPA IE */
Jeff Johnson034f3c92018-11-09 10:46:21 -08005329 parse_status = dot11f_unpack_ie_wpa(MAC_CONTEXT(mac_handle),
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005330 rsn_ie, rsn_ie_len,
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005331 &dot11_wpa_ie, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305332 if (!DOT11F_SUCCEEDED(parse_status)) {
5333 hdd_err("Invalid WPA IE: parse status %d",
5334 parse_status);
5335 return -EINVAL;
5336 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005338 hdd_debug("WPA unicast cipher suite count: %d",
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005339 dot11_wpa_ie.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005340 hdd_debug("WPA authentication suite count: %d",
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005341 dot11_wpa_ie.auth_suite_count);
5342 /* dot11_wpa_ie.auth_suite_count */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005343 /* Just translate the FIRST one */
Jeff Johnson4f1be2d2019-03-09 22:52:04 -08005344 *auth_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 hdd_translate_wpa_to_csr_auth_type(
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005346 dot11_wpa_ie.auth_suites[0]);
5347 /* dot11_wpa_ie.unicast_cipher_count */
Jeff Johnsona376a032019-03-09 22:39:27 -08005348 *encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005349 hdd_translate_wpa_to_csr_encryption_type(
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005350 dot11_wpa_ie.unicast_ciphers[0]);
5351 /* dot11_wpa_ie.unicast_cipher_count */
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005352 *mc_encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 hdd_translate_wpa_to_csr_encryption_type(
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005354 dot11_wpa_ie.multicast_cipher);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005355 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005356 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 return -EINVAL;
5358 }
5359 return 0;
5360}
5361
5362/**
Abhishek Singh6454ad32017-12-20 10:42:21 +05305363 * hdd_set_def_rsne_override() - set default encryption type and auth type
5364 * in profile.
5365 * @roam_profile: pointer to adapter
5366 * @auth_type: pointer to auth type
5367 *
5368 * Set default value of encryption type and auth type in profile to
5369 * search the AP using filter, as in force_rsne_override the RSNIE can be
5370 * currupt and we might not get the proper encryption type and auth type
5371 * while parsing the RSNIE.
5372 *
5373 * Return: void
5374 */
5375static void hdd_set_def_rsne_override(
Jeff Johnson61b5e982018-03-15 11:33:31 -07005376 struct csr_roam_profile *roam_profile, eCsrAuthType *auth_type)
Abhishek Singh6454ad32017-12-20 10:42:21 +05305377{
5378
5379 hdd_debug("Set def values in roam profile");
5380 roam_profile->MFPCapable = roam_profile->MFPEnabled;
5381 roam_profile->EncryptionType.numEntries = 2;
5382 roam_profile->mcEncryptionType.numEntries = 2;
5383 /* Use the cipher type in the RSN IE */
5384 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
5385 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
5386 roam_profile->mcEncryptionType.encryptionType[0] =
5387 eCSR_ENCRYPT_TYPE_AES;
5388 roam_profile->mcEncryptionType.encryptionType[1] =
5389 eCSR_ENCRYPT_TYPE_TKIP;
5390 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
5391}
5392
5393/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005394 * hdd_set_genie_to_csr() - set genie to csr
Jeff Johnsonba388342017-10-02 13:31:01 -07005395 * @adapter: pointer to adapter
Jeff Johnson784efe22019-03-09 18:31:13 -08005396 * @rsn_auth_type: pointer to auth type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005397 *
5398 * Return: 0 on success, error number otherwise
5399 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005400int hdd_set_genie_to_csr(struct hdd_adapter *adapter,
Jeff Johnson784efe22019-03-09 18:31:13 -08005401 eCsrAuthType *rsn_auth_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402{
Jeff Johnson844eec72018-03-13 11:48:18 -07005403 struct csr_roam_profile *roam_profile;
5404 uint8_t *security_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005405 uint32_t status = 0;
Jeff Johnson51203af2019-03-09 18:38:09 -08005406 eCsrEncryptionType rsn_encrypt_type;
5407 eCsrEncryptionType mc_rsn_encrypt_type;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305408 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409#ifdef WLAN_FEATURE_11W
Jeff Johnson5abc32d2019-03-10 22:01:17 -07005410 uint8_t mfp_required = 0;
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005411 uint8_t mfp_capable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005412#endif
5413 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
Jeff Johnson844eec72018-03-13 11:48:18 -07005414
5415 roam_profile = hdd_roam_profile(adapter);
5416 security_ie = hdd_security_ie(adapter);
5417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 /* MAC address of assoc peer */
5419 /* But, this routine is only called when we are NOT associated. */
Jeff Johnson844eec72018-03-13 11:48:18 -07005420 qdf_mem_copy(bssid, roam_profile->BSSIDs.bssid, sizeof(bssid));
5421 if (security_ie[0] == DOT11F_EID_RSN ||
5422 security_ie[0] == DOT11F_EID_WPA) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 /* continue */
5424 } else {
5425 return 0;
5426 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305427
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005428 /* The actual processing may eventually be more extensive than this. */
5429 /* Right now, just consume any PMKIDs that are sent in by the app. */
Jeff Johnsonba388342017-10-02 13:31:01 -07005430 status = hdd_process_genie(adapter, bssid,
Jeff Johnson51203af2019-03-09 18:38:09 -08005431 &rsn_encrypt_type,
5432 &mc_rsn_encrypt_type, rsn_auth_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005433#ifdef WLAN_FEATURE_11W
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005434 &mfp_required, &mfp_capable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005435#endif
Jeff Johnson844eec72018-03-13 11:48:18 -07005436 security_ie[1] + 2,
5437 security_ie);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305438
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005439 if (status == 0) {
5440 /*
5441 * Now copy over all the security attributes
5442 * you have parsed out.
5443 */
Jeff Johnson844eec72018-03-13 11:48:18 -07005444 roam_profile->EncryptionType.numEntries = 1;
5445 roam_profile->mcEncryptionType.numEntries = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005446
Jeff Johnson435e1b82017-10-07 14:13:10 -07005447 /* Use the cipher type in the RSN IE */
Jeff Johnson844eec72018-03-13 11:48:18 -07005448 roam_profile->EncryptionType.encryptionType[0] =
Jeff Johnson51203af2019-03-09 18:38:09 -08005449 rsn_encrypt_type;
Jeff Johnson844eec72018-03-13 11:48:18 -07005450 roam_profile->mcEncryptionType.encryptionType[0] =
Jeff Johnson51203af2019-03-09 18:38:09 -08005451 mc_rsn_encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452
Jeff Johnsonba388342017-10-02 13:31:01 -07005453 if ((QDF_IBSS_MODE == adapter->device_mode) &&
Jeff Johnson51203af2019-03-09 18:38:09 -08005454 ((eCSR_ENCRYPT_TYPE_AES == mc_rsn_encrypt_type) ||
5455 (eCSR_ENCRYPT_TYPE_AES_GCMP == mc_rsn_encrypt_type) ||
5456 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mc_rsn_encrypt_type) ||
5457 (eCSR_ENCRYPT_TYPE_TKIP == mc_rsn_encrypt_type))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005458 /*
5459 * For wpa none supplicant sends the WPA IE with unicast
5460 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5461 * multicast cipher as either AES/TKIP based on group
5462 * cipher configuration mentioned in the
5463 * wpa_supplicant.conf.
5464 */
5465
5466 /* Set the unicast cipher same as multicast cipher */
Jeff Johnson844eec72018-03-13 11:48:18 -07005467 roam_profile->EncryptionType.encryptionType[0]
Jeff Johnson51203af2019-03-09 18:38:09 -08005468 = mc_rsn_encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005469 }
5470#ifdef WLAN_FEATURE_11W
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005471 hdd_debug("mfp_required = %d, mfp_capable = %d",
5472 mfp_required, mfp_capable);
Jeff Johnson5abc32d2019-03-10 22:01:17 -07005473 roam_profile->MFPRequired = mfp_required;
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005474 roam_profile->MFPCapable = mfp_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005476 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Jeff Johnson51203af2019-03-09 18:38:09 -08005477 *rsn_auth_type, rsn_encrypt_type, mc_rsn_encrypt_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005478 }
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005479#ifdef WLAN_CONV_CRYPTO_SUPPORTED
5480 if (QDF_STATUS_SUCCESS != wlan_set_vdev_crypto_prarams_from_ie(
5481 adapter->vdev, security_ie,
5482 (security_ie[1] + 2)))
5483 hdd_err("Failed to set the crypto params from IE");
5484#endif
Abhishek Singh6454ad32017-12-20 10:42:21 +05305485
5486 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5487 if (hdd_ctx->force_rsne_override &&
Jeff Johnson844eec72018-03-13 11:48:18 -07005488 (security_ie[0] == DOT11F_EID_RSN)) {
Abhishek Singh6454ad32017-12-20 10:42:21 +05305489 hdd_warn("Test mode enabled set def Auth and enc type. RSN IE passed in connect req: ");
5490 qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
Jeff Johnson844eec72018-03-13 11:48:18 -07005491 roam_profile->pRSNReqIE,
5492 roam_profile->nRSNReqIELength);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305493
Jeff Johnson844eec72018-03-13 11:48:18 -07005494 roam_profile->force_rsne_override = true;
Abhishek Singh63781032018-02-23 14:59:22 +05305495
Jeff Johnson844eec72018-03-13 11:48:18 -07005496 hdd_debug("MFPEnabled %d", roam_profile->MFPEnabled);
Abhishek Singh63781032018-02-23 14:59:22 +05305497 /*
Jeff Johnson33142e62018-05-06 17:58:36 -07005498 * Reset MFPEnabled if testmode RSNE passed doesn't have MFPR
Abhishek Singh63781032018-02-23 14:59:22 +05305499 * or MFPC bit set
5500 */
Jeff Johnson844eec72018-03-13 11:48:18 -07005501 if (roam_profile->MFPEnabled &&
5502 !(roam_profile->MFPRequired ||
5503 roam_profile->MFPCapable)) {
Abhishek Singh63781032018-02-23 14:59:22 +05305504 hdd_debug("Reset MFPEnabled");
Jeff Johnson844eec72018-03-13 11:48:18 -07005505 roam_profile->MFPEnabled = 0;
Abhishek Singh63781032018-02-23 14:59:22 +05305506 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305507 /* If parsing failed set the def value for the roam profile */
5508 if (status)
Jeff Johnson784efe22019-03-09 18:31:13 -08005509 hdd_set_def_rsne_override(roam_profile, rsn_auth_type);
Abhishek Singh3f13a812018-01-16 14:24:44 +05305510 return 0;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305511 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05305512 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513}
5514
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305515#ifdef WLAN_FEATURE_FILS_SK
5516/**
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305517 * hdd_check_fils_rsn_n_set_auth_type() - This API checks whether a give
5518 * auth type is fils if yes, sets it in profile.
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305519 * @rsn_auth_type: auth type
5520 *
5521 * Return: true if FILS auth else false
5522 */
Jeff Johnson61b5e982018-03-15 11:33:31 -07005523static
5524bool hdd_check_fils_rsn_n_set_auth_type(struct csr_roam_profile *roam_profile,
5525 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305526{
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305527 bool is_fils_rsn = false;
5528
5529 if (!roam_profile->fils_con_info)
5530 return false;
5531
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305532 if ((rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA256) ||
5533 (rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA384) ||
5534 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA256) ||
5535 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA384))
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305536 is_fils_rsn = true;
5537 if (is_fils_rsn)
5538 roam_profile->fils_con_info->akm_type = rsn_auth_type;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305539
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305540 return is_fils_rsn;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305541}
5542#else
Jeff Johnson61b5e982018-03-15 11:33:31 -07005543static
5544bool hdd_check_fils_rsn_n_set_auth_type(struct csr_roam_profile *roam_profile,
5545 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305546{
5547 return false;
5548}
5549#endif
5550
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551/**
5552 * hdd_set_csr_auth_type() - set csr auth type
Jeff Johnsonba388342017-10-02 13:31:01 -07005553 * @adapter: pointer to adapter
Jeff Johnson784efe22019-03-09 18:31:13 -08005554 * @rsn_auth_type: auth type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005555 *
5556 * Return: 0 on success, error number otherwise
5557 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005558int hdd_set_csr_auth_type(struct hdd_adapter *adapter,
Jeff Johnson784efe22019-03-09 18:31:13 -08005559 eCsrAuthType rsn_auth_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560{
Jeff Johnson844eec72018-03-13 11:48:18 -07005561 struct csr_roam_profile *roam_profile;
Jeff Johnsond377dce2017-10-04 10:32:42 -07005562 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07005563 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson37ecea42018-03-18 17:54:40 -07005564 enum hdd_auth_key_mgmt key_mgmt = sta_ctx->auth_key_mgmt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565
Jeff Johnson844eec72018-03-13 11:48:18 -07005566 roam_profile = hdd_roam_profile(adapter);
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005567 roam_profile->AuthType.numEntries = 1;
Jeff Johnson784efe22019-03-09 18:31:13 -08005568 hdd_debug("auth_type = %d rsn_auth_type %d wpa_versions %d",
5569 sta_ctx->conn_info.auth_type, rsn_auth_type,
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305570 sta_ctx->wpa_versions);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005571
Jeff Johnson96e33512019-02-27 15:10:21 -08005572 switch (sta_ctx->conn_info.auth_type) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005573 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumarbd41baa2018-10-12 17:46:04 +05305574 case eCSR_AUTH_TYPE_AUTOSWITCH:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005575#ifdef FEATURE_WLAN_ESE
5576 case eCSR_AUTH_TYPE_CCKM_WPA:
5577 case eCSR_AUTH_TYPE_CCKM_RSN:
5578#endif
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005579 if (!sta_ctx->wpa_versions) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005581 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005582 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005583 } else if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584
5585#ifdef FEATURE_WLAN_ESE
Jeff Johnson784efe22019-03-09 18:31:13 -08005586 if ((rsn_auth_type == eCSR_AUTH_TYPE_CCKM_WPA) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005587 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5588 == HDD_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005589 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005590 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005591 eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson784efe22019-03-09 18:31:13 -08005592 } else if (rsn_auth_type == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005593 hdd_debug("Last chance to set authType to CCKM WPA.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005594 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 eCSR_AUTH_TYPE_CCKM_WPA;
5596 } else
5597#endif
Jeff Johnson37ecea42018-03-18 17:54:40 -07005598 if ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5599 == HDD_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005600 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005601 eCSR_AUTH_TYPE_WPA;
5602 } else
Jeff Johnson37ecea42018-03-18 17:54:40 -07005603 if ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5604 == HDD_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005605 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005606 eCSR_AUTH_TYPE_WPA_PSK;
5607 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005608 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609 eCSR_AUTH_TYPE_WPA_NONE;
5610 }
5611 }
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005612 if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613#ifdef FEATURE_WLAN_ESE
Jeff Johnson784efe22019-03-09 18:31:13 -08005614 if ((rsn_auth_type == eCSR_AUTH_TYPE_CCKM_RSN) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005615 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5616 == HDD_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005617 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005618 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005620 } else if (rsn_auth_type == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005621 hdd_debug("Last chance to set authType to CCKM RSN.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005622 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005623 eCSR_AUTH_TYPE_CCKM_RSN;
5624 } else
5625#endif
Jeff Johnson784efe22019-03-09 18:31:13 -08005626 if (rsn_auth_type == eCSR_AUTH_TYPE_DPP_RSN) {
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305627 roam_profile->AuthType.authType[0] =
5628 eCSR_AUTH_TYPE_DPP_RSN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005629 } else if (rsn_auth_type == eCSR_AUTH_TYPE_OSEN) {
Srinivas Dasarib328f1a2018-12-18 17:45:06 +05305630 roam_profile->AuthType.authType[0] =
5631 eCSR_AUTH_TYPE_OSEN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005632 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_FT_RSN) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005633 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5634 == HDD_AUTH_KEY_MGMT_802_1X)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005635 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005637 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_FT_RSN_PSK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005639 ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5640 == HDD_AUTH_KEY_MGMT_PSK)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005641 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642 eCSR_AUTH_TYPE_FT_RSN_PSK;
5643 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644
5645#ifdef WLAN_FEATURE_11W
Jeff Johnson784efe22019-03-09 18:31:13 -08005646 if (rsn_auth_type == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005647 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
Jeff Johnson784efe22019-03-09 18:31:13 -08005649 } else if (rsn_auth_type ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005650 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005651 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5653 } else
5654#endif
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005655 if (hdd_check_fils_rsn_n_set_auth_type(roam_profile,
Jeff Johnson784efe22019-03-09 18:31:13 -08005656 rsn_auth_type)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005657 roam_profile->AuthType.authType[0] =
Jeff Johnson784efe22019-03-09 18:31:13 -08005658 rsn_auth_type;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05305659 hdd_debug("updated profile authtype as %d",
Jeff Johnson784efe22019-03-09 18:31:13 -08005660 rsn_auth_type);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305661
Jeff Johnson784efe22019-03-09 18:31:13 -08005662 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_OWE) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005663 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5664 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305665 /* OWE case */
5666 roam_profile->AuthType.authType[0] =
5667 eCSR_AUTH_TYPE_OWE;
Jeff Johnson784efe22019-03-09 18:31:13 -08005668 } else if ((rsn_auth_type ==
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305669 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005670 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5671 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305672 /* Suite B EAP SHA 256 */
5673 roam_profile->AuthType.authType[0] =
5674 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
Jeff Johnson784efe22019-03-09 18:31:13 -08005675 } else if ((rsn_auth_type ==
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305676 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005677 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5678 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305679 /* Suite B EAP SHA 384 */
5680 roam_profile->AuthType.authType[0] =
5681 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Jeff Johnson784efe22019-03-09 18:31:13 -08005682 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_FT_SAE) &&
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305683 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X) ==
5684 HDD_AUTH_KEY_MGMT_802_1X)) {
5685 roam_profile->AuthType.authType[0] =
5686 eCSR_AUTH_TYPE_FT_SAE;
Jeff Johnson784efe22019-03-09 18:31:13 -08005687 } else if ((rsn_auth_type ==
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305688 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384) &&
5689 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5690 == HDD_AUTH_KEY_MGMT_802_1X)) {
5691 /* FT Suite-B EAP SHA 384 */
5692 roam_profile->AuthType.authType[0] =
5693 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384;
5694
Jeff Johnson37ecea42018-03-18 17:54:40 -07005695 } else if ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305696 == HDD_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005697 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005698 eCSR_AUTH_TYPE_RSN;
5699 } else
Jeff Johnson37ecea42018-03-18 17:54:40 -07005700 if ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5701 == HDD_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005702 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703 eCSR_AUTH_TYPE_RSN_PSK;
5704 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005705 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706 eCSR_AUTH_TYPE_UNKNOWN;
5707 }
5708 }
5709 break;
5710
5711 case eCSR_AUTH_TYPE_SHARED_KEY:
5712
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005713 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305715
5716 case eCSR_AUTH_TYPE_SAE:
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305717
Jeff Johnson784efe22019-03-09 18:31:13 -08005718 if (rsn_auth_type == eCSR_AUTH_TYPE_FT_SAE)
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305719 roam_profile->AuthType.authType[0] =
5720 eCSR_AUTH_TYPE_FT_SAE;
5721 else
5722 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305723 break;
5724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 default:
5726
5727#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005728 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729#endif /* FEATURE_WLAN_ESE */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005730 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731 break;
5732 }
5733
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005734 hdd_debug("Set roam Authtype to %d",
Jeff Johnson844eec72018-03-13 11:48:18 -07005735 roam_profile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737 return 0;
5738}
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005739
5740#ifdef WLAN_FEATURE_FILS_SK
5741static void hdd_initialize_fils_info(struct hdd_adapter *adapter)
5742{
5743 struct csr_roam_profile *roam_profile;
5744
5745 roam_profile = hdd_roam_profile(adapter);
5746 roam_profile->fils_con_info = NULL;
5747 roam_profile->hlp_ie = NULL;
5748 roam_profile->hlp_ie_len = 0;
5749}
5750#else
5751static void hdd_initialize_fils_info(struct hdd_adapter *adapter)
5752{ }
5753#endif
5754
5755void hdd_roam_profile_init(struct hdd_adapter *adapter)
5756{
5757 struct csr_roam_profile *roam_profile;
5758 uint8_t *security_ie;
5759 tSirAddie *assoc_additional_ie;
5760 struct hdd_station_ctx *sta_ctx;
5761
5762 hdd_enter();
5763
5764 roam_profile = hdd_roam_profile(adapter);
5765 qdf_mem_zero(roam_profile, sizeof(*roam_profile));
5766
5767 security_ie = hdd_security_ie(adapter);
Srinivas Girigowdacf161402019-03-14 11:37:33 -07005768 qdf_mem_zero(security_ie, WLAN_MAX_IE_LEN);
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005769
5770 assoc_additional_ie = hdd_assoc_additional_ie(adapter);
5771 qdf_mem_zero(assoc_additional_ie, sizeof(*assoc_additional_ie));
5772
5773 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
5774
5775 /* Configure the roaming profile links to SSID and bssid. */
5776 roam_profile->SSIDs.numOfSSIDs = 0;
Jeff Johnson4aea1802019-02-27 10:21:33 -08005777 roam_profile->SSIDs.SSIDList = &sta_ctx->conn_info.ssid;
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005778
5779 roam_profile->BSSIDs.numOfBSSIDs = 0;
Jeff Johnsone04b6992019-02-27 14:06:55 -08005780 roam_profile->BSSIDs.bssid = &sta_ctx->conn_info.bssid;
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005781
5782 /* Set the numOfChannels to zero to scan all the channels */
5783 roam_profile->ChannelInfo.numOfChannels = 0;
5784 roam_profile->ChannelInfo.ChannelList = NULL;
5785
5786 roam_profile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
5787
5788 roam_profile->phyMode = eCSR_DOT11_MODE_AUTO;
5789 sta_ctx->wpa_versions = 0;
5790
5791 /* Set the default scan mode */
5792 adapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
5793
5794 hdd_clear_roam_profile_ie(adapter);
5795
5796 hdd_initialize_fils_info(adapter);
5797
5798 hdd_exit();
5799}