blob: 76cae0b6835f2e1d2ef3ba6d082d88c6d3780b25 [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"
Abhinav Kumar39222152019-05-13 23:53:40 +053066#include "wlan_hdd_bcn_recv.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080067
Alok Kumarb64650c2018-03-23 17:05:11 +053068#include "wlan_hdd_nud_tracking.h"
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -070069#include <wlan_cfg80211_crypto.h>
70#include <wlan_crypto_global_api.h>
gaurank kathpalia7ef72182019-05-29 19:41:25 +053071#include "wlan_blm_ucfg_api.h"
72
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080073/* These are needed to recognize WPA and RSN suite types */
74#define HDD_WPA_OUI_SIZE 4
75#define HDD_RSN_OUI_SIZE 4
76uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
77uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
78uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
79uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
80uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
81uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
82
83#ifdef FEATURE_WLAN_ESE
84/* CCKM */
85uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
86/* CCKM */
87uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
88#endif /* FEATURE_WLAN_ESE */
89
90/* group cipher */
91uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
92
93/* WEP-40 or RSN */
94uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
95
96/* TKIP or RSN-PSK */
97uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
98
99/* Reserved */
100uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
101
102/* AES-CCMP */
103uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
104
105/* WEP-104 */
106uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
107
108#ifdef WLAN_FEATURE_11W
109/* RSN-PSK-SHA256 */
110uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
111
112/* RSN-8021X-SHA256 */
113uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
114#endif
115
Mukul Sharma05504ac2017-06-08 12:35:53 +0530116/* AES-GCMP-128 */
117uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
118
119/* AES-GCMP-256 */
120uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +0530121#ifdef WLAN_FEATURE_FILS_SK
122uint8_t ccp_rsn_oui_0e[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0E};
123uint8_t ccp_rsn_oui_0f[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0F};
124uint8_t ccp_rsn_oui_10[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x10};
125uint8_t ccp_rsn_oui_11[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x11};
126#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +0530127uint8_t ccp_rsn_oui_12[HDD_RSN_OUI_SIZE] = {0x50, 0x6F, 0x9A, 0x02};
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +0530128uint8_t ccp_rsn_oui_0b[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0B};
129uint8_t ccp_rsn_oui_0c[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0C};
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +0530130/* FT-SUITE-B AKM */
131uint8_t ccp_rsn_oui_0d[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0D};
Mukul Sharma05504ac2017-06-08 12:35:53 +0530132
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +0530133/* OWE https://tools.ietf.org/html/rfc8110 */
134uint8_t ccp_rsn_oui_18[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x12};
135
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530136#ifdef WLAN_FEATURE_SAE
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +0530137/* SAE AKM */
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530138uint8_t ccp_rsn_oui_80[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x08};
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +0530139/* FT SAE AKM */
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530140uint8_t ccp_rsn_oui_90[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x09};
141#endif
Srinivas Dasarib328f1a2018-12-18 17:45:06 +0530142static const
143u8 ccp_rsn_oui_13[HDD_RSN_OUI_SIZE] = {0x50, 0x6F, 0x9A, 0x01};
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +0530144
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800145/* Offset where the EID-Len-IE, start. */
146#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
147#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149#define HDD_PEER_AUTHORIZE_WAIT 10
150
151/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700152 * beacon_filter_table - table of IEs used for beacon filtering
153 */
154static const int beacon_filter_table[] = {
Srinivas Girigowda61771262019-04-01 11:55:19 -0700155 WLAN_ELEMID_DSPARMS,
156 WLAN_ELEMID_ERP,
157 WLAN_ELEMID_EDCAPARMS,
158 WLAN_ELEMID_QOS_CAPABILITY,
159 WLAN_ELEMID_HTINFO_ANA,
160 WLAN_ELEMID_OP_MODE_NOTIFY,
161 WLAN_ELEMID_VHTOP,
Krunal Sonib7f20432017-04-27 13:01:02 -0700162#ifdef WLAN_FEATURE_11AX_BSS_COLOR
163 /*
164 * EID: 221 vendor IE is being used temporarily by 11AX
165 * bss-color-change IE till it gets any fixed number. This
166 * vendor EID needs to be replaced with bss-color-change IE
167 * number.
168 */
Srinivas Girigowda61771262019-04-01 11:55:19 -0700169 WLAN_ELEMID_VENDOR,
Krunal Sonib7f20432017-04-27 13:01:02 -0700170#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700171};
172
Padma, Santhosh Kumareb90a552018-01-16 19:41:58 +0530173#if defined(WLAN_FEATURE_SAE) && \
174 defined(CFG80211_EXTERNAL_AUTH_SUPPORT)
175/**
176 * wlan_hdd_sae_callback() - Sends SAE info to supplicant
177 * @adapter: pointer adapter context
178 * @roam_info: pointer to roam info
179 *
180 * This API is used to send required SAE info to trigger SAE in supplicant.
181 *
182 * Return: None
183 */
184static void wlan_hdd_sae_callback(struct hdd_adapter *adapter,
185 struct csr_roam_info *roam_info)
186{
187 struct hdd_context *hdd_ctx = adapter->hdd_ctx;
188 int flags;
189 struct sir_sae_info *sae_info = roam_info->sae_info;
190 struct cfg80211_external_auth_params params = {0};
191
192 if (wlan_hdd_validate_context(hdd_ctx))
193 return;
194
195 if (!sae_info) {
196 hdd_err("SAE info in NULL");
197 return;
198 }
199
200 flags = cds_get_gfp_flags();
201
202 params.key_mgmt_suite = 0x00;
203 params.key_mgmt_suite |= 0x0F << 8;
204 params.key_mgmt_suite |= 0xAC << 16;
205 params.key_mgmt_suite |= 0x8 << 24;
206
207 params.action = NL80211_EXTERNAL_AUTH_START;
208 qdf_mem_copy(params.bssid, sae_info->peer_mac_addr.bytes,
209 QDF_MAC_ADDR_SIZE);
210 qdf_mem_copy(params.ssid.ssid, sae_info->ssid.ssId,
211 sae_info->ssid.length);
212 params.ssid.ssid_len = sae_info->ssid.length;
213
214 cfg80211_external_auth_request(adapter->dev, &params, flags);
215 hdd_debug("SAE: sent cmd");
216}
217#else
218static inline void wlan_hdd_sae_callback(struct hdd_adapter *adapter,
219 struct csr_roam_info *roam_info)
220{ }
221#endif
222
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700223/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800224 * hdd_conn_set_authenticated() - set authentication state
Jeff Johnsonba388342017-10-02 13:31:01 -0700225 * @adapter: pointer to the adapter
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530226 * @auth_state: authentication state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800227 *
228 * This function updates the global HDD station context
229 * authentication state.
230 *
231 * Return: none
232 */
233static void
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530234hdd_conn_set_authenticated(struct hdd_adapter *adapter, uint8_t auth_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800235{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700236 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530237 char *auth_time;
238 uint32_t time_buffer_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800239
240 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700241 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Jeff Johnson457c2422019-02-27 13:56:04 -0800242 sta_ctx->conn_info.is_authenticated, auth_state);
243 sta_ctx->conn_info.is_authenticated = auth_state;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530244
245 auth_time = sta_ctx->conn_info.auth_time;
246 time_buffer_size = sizeof(sta_ctx->conn_info.auth_time);
247
248 if (auth_state)
249 qdf_get_time_of_the_day_in_hr_min_sec_usec(auth_time,
250 time_buffer_size);
251 else
hangtian127c9532019-01-12 13:29:07 +0800252 qdf_mem_zero(auth_time, time_buffer_size);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530253
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254}
255
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700256void hdd_conn_set_connection_state(struct hdd_adapter *adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700257 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700259 struct hdd_station_ctx *hdd_sta_ctx =
260 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530261 char *connect_time;
262 uint32_t time_buffer_size;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263
264 /* save the new connection state */
Jun Wang92cd8362018-07-27 16:52:47 +0800265 hdd_debug("Changed conn state from old:%d to new:%d for dev %s",
Jeff Johnsone7951512019-02-27 10:02:51 -0800266 hdd_sta_ctx->conn_info.conn_state, conn_state,
Jun Wang92cd8362018-07-27 16:52:47 +0800267 adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800268
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700269 hdd_tsf_notify_wlan_state_change(adapter,
Jeff Johnsone7951512019-02-27 10:02:51 -0800270 hdd_sta_ctx->conn_info.conn_state,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700271 conn_state);
Jeff Johnsone7951512019-02-27 10:02:51 -0800272 hdd_sta_ctx->conn_info.conn_state = conn_state;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530273
274 connect_time = hdd_sta_ctx->conn_info.connect_time;
275 time_buffer_size = sizeof(hdd_sta_ctx->conn_info.connect_time);
276 if (conn_state == eConnectionState_Associated)
277 qdf_get_time_of_the_day_in_hr_min_sec_usec(connect_time,
278 time_buffer_size);
279 else
hangtian127c9532019-01-12 13:29:07 +0800280 qdf_mem_zero(connect_time, time_buffer_size);
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +0530281
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282}
283
284/**
285 * hdd_conn_get_connection_state() - get connection state
Jeff Johnsonba388342017-10-02 13:31:01 -0700286 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 * @pConnState: pointer to connection state
288 *
289 * This function updates the global HDD station context connection state.
290 *
291 * Return: true if (Infra Associated or IBSS Connected)
292 * and sets output parameter pConnState;
293 * false otherwise
294 */
Jeff Johnson435e1b82017-10-07 14:13:10 -0700295static inline bool
296hdd_conn_get_connection_state(struct hdd_station_ctx *sta_ctx,
Dustin Brown0127a732018-07-19 14:06:34 -0700297 eConnectionState *out_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298{
Jeff Johnsone7951512019-02-27 10:02:51 -0800299 eConnectionState state = sta_ctx->conn_info.conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800300
Dustin Brown0127a732018-07-19 14:06:34 -0700301 if (out_state)
302 *out_state = state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800303
Dustin Brown0127a732018-07-19 14:06:34 -0700304 switch (state) {
305 case eConnectionState_Associated:
306 case eConnectionState_IbssConnected:
307 case eConnectionState_IbssDisconnected:
308 case eConnectionState_NdiConnected:
309 return true;
310 default:
311 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800312 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800313}
314
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700315bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800316{
Jeff Johnsone7951512019-02-27 10:02:51 -0800317 return hdd_sta_ctx->conn_info.conn_state ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800318 eConnectionState_Connecting;
319}
320
Jeff Johnsond377dce2017-10-04 10:32:42 -0700321bool hdd_conn_is_connected(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800322{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700323 return hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800324}
325
Dustin Brown0127a732018-07-19 14:06:34 -0700326bool hdd_adapter_is_connected_sta(struct hdd_adapter *adapter)
327{
328 switch (adapter->device_mode) {
329 case QDF_STA_MODE:
330 case QDF_P2P_CLIENT_MODE:
331 case QDF_NDI_MODE:
332 return hdd_conn_is_connected(&adapter->session.station);
333 default:
334 return false;
335 }
336}
337
Jeff Johnsond377dce2017-10-04 10:32:42 -0700338enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800339{
Jingxiang Gece7c5472019-07-23 16:19:23 +0800340 uint32_t sta_freq = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800341
Jeff Johnsone7951512019-02-27 10:02:51 -0800342 if (eConnectionState_Associated == sta_ctx->conn_info.conn_state)
Jingxiang Geae80dc62019-08-13 17:32:22 +0800343 sta_freq = sta_ctx->conn_info.chan_freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800344
Jingxiang Gece7c5472019-07-23 16:19:23 +0800345 if (wlan_reg_is_24ghz_ch_freq(sta_freq))
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700346 return BAND_2G;
Jingxiang Gece7c5472019-07-23 16:19:23 +0800347 else if (wlan_reg_is_5ghz_ch_freq(sta_freq))
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700348 return BAND_5G;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800349 else /* If station is not connected return as BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700350 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800351}
352
353/**
354 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
Jeff Johnsond377dce2017-10-04 10:32:42 -0700355 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800356 * @pConnectedCipherAlgo: pointer to connected cipher algo
357 *
358 * Return: false if any errors encountered, true otherwise
359 */
360static inline bool
Jeff Johnsond377dce2017-10-04 10:32:42 -0700361hdd_conn_get_connected_cipher_algo(struct hdd_station_ctx *sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800362 eCsrEncryptionType *pConnectedCipherAlgo)
363{
Jeff Johnson389e16b2018-05-05 23:32:55 -0700364 bool connected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800365
Jeff Johnson389e16b2018-05-05 23:32:55 -0700366 connected = hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800367
368 if (pConnectedCipherAlgo)
Jeff Johnsonb1959842019-02-27 13:04:04 -0800369 *pConnectedCipherAlgo = sta_ctx->conn_info.uc_encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800370
Jeff Johnson389e16b2018-05-05 23:32:55 -0700371 return connected;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800372}
373
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530374struct hdd_adapter *hdd_get_sta_connection_in_progress(
375 struct hdd_context *hdd_ctx)
376{
377 struct hdd_adapter *adapter = NULL;
378 struct hdd_station_ctx *hdd_sta_ctx;
379
380 if (!hdd_ctx) {
381 hdd_err("HDD context is NULL");
382 return NULL;
383 }
384
385 hdd_for_each_adapter(hdd_ctx, adapter) {
386 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
387 if ((QDF_STA_MODE == adapter->device_mode) ||
388 (QDF_P2P_CLIENT_MODE == adapter->device_mode) ||
389 (QDF_P2P_DEVICE_MODE == adapter->device_mode)) {
390 if (eConnectionState_Connecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -0800391 hdd_sta_ctx->conn_info.conn_state) {
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530392 hdd_debug("vdev_id %d: Connection is in progress",
Jeff Johnson1abc5662019-02-04 14:27:02 -0800393 adapter->vdev_id);
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530394 return adapter;
395 } else if ((eConnectionState_Associated ==
Jeff Johnsone7951512019-02-27 10:02:51 -0800396 hdd_sta_ctx->conn_info.conn_state) &&
Vignesh Viswanathan0a569292018-02-14 15:34:47 +0530397 sme_is_sta_key_exchange_in_progress(
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700398 hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -0800399 adapter->vdev_id)) {
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530400 hdd_debug("vdev_id %d: Key exchange is in progress",
Jeff Johnson1abc5662019-02-04 14:27:02 -0800401 adapter->vdev_id);
Himanshu Agarwal6c3607a2018-01-12 12:04:19 +0530402 return adapter;
403 }
404 }
405 }
406 return NULL;
407}
408
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530409void hdd_abort_ongoing_sta_connection(struct hdd_context *hdd_ctx)
410{
411 struct hdd_adapter *sta_adapter;
412 QDF_STATUS status;
413
414 sta_adapter = hdd_get_sta_connection_in_progress(hdd_ctx);
415 if (sta_adapter) {
416 hdd_debug("Disconnecting STA on vdev: %d",
Jeff Johnson1abc5662019-02-04 14:27:02 -0800417 sta_adapter->vdev_id);
Pragaspathi Thilagaraje6f37e02019-01-04 12:24:33 +0530418 status = wlan_hdd_disconnect(sta_adapter,
419 eCSR_DISCONNECT_REASON_DEAUTH);
420 if (QDF_IS_STATUS_ERROR(status)) {
421 hdd_err("wlan_hdd_disconnect failed, status: %d",
422 status);
423 }
424 }
425}
426
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700428 * hdd_remove_beacon_filter() - remove beacon filter
429 * @adapter: Pointer to the hdd adapter
430 *
431 * Return: 0 on success and errno on failure
432 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700433static int hdd_remove_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700434{
435 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700436 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700437
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700438 status = sme_remove_beacon_filter(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -0800439 adapter->vdev_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700440 if (!QDF_IS_STATUS_SUCCESS(status)) {
441 hdd_err("sme_remove_beacon_filter() failed");
442 return -EFAULT;
443 }
444
445 return 0;
446}
447
Abhinav Kumar39222152019-05-13 23:53:40 +0530448int hdd_add_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700449{
450 int i;
451 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
452 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700453 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700454
455 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530456 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700457 (unsigned long int *)ie_map);
458
Jeff Johnsonf7187f22018-06-13 22:02:19 -0700459 status = sme_add_beacon_filter(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -0800460 adapter->vdev_id, ie_map);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700461 if (!QDF_IS_STATUS_SUCCESS(status)) {
462 hdd_err("sme_add_beacon_filter() failed");
463 return -EFAULT;
464 }
465 return 0;
466}
467
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530468void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
469 tDot11fIEHTCaps *roam_ht_cap)
470
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530471{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530472 uint32_t i, temp_ht_cap;
473
474 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
475
476 if (roam_ht_cap->advCodingCap)
477 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
478 if (roam_ht_cap->supportedChannelWidthSet)
479 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
480 temp_ht_cap = roam_ht_cap->mimoPowerSave &
481 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
482 if (temp_ht_cap)
483 hdd_ht_cap->cap_info |=
484 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
485 if (roam_ht_cap->greenField)
486 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
487 if (roam_ht_cap->shortGI20MHz)
488 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
489 if (roam_ht_cap->shortGI40MHz)
490 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
491 if (roam_ht_cap->txSTBC)
492 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
493 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
494 IEEE80211_HT_CAP_RX_STBC_SHIFT);
495 if (temp_ht_cap)
496 hdd_ht_cap->cap_info |=
497 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
498 if (roam_ht_cap->delayedBA)
499 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
500 if (roam_ht_cap->maximalAMSDUsize)
501 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
502 if (roam_ht_cap->dsssCckMode40MHz)
503 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
504 if (roam_ht_cap->psmp)
505 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
506 if (roam_ht_cap->stbcControlFrame)
507 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
508 if (roam_ht_cap->lsigTXOPProtection)
509 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
510
511 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
512 if (roam_ht_cap->maxRxAMPDUFactor)
513 hdd_ht_cap->ampdu_params_info |=
514 IEEE80211_HT_AMPDU_PARM_FACTOR;
515 temp_ht_cap = roam_ht_cap->mpduDensity &
516 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
517 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
518 if (temp_ht_cap)
519 hdd_ht_cap->ampdu_params_info |=
520 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
521
522 /* 802.11n HT extended capabilities masks */
523 if (roam_ht_cap->pco)
524 hdd_ht_cap->extended_ht_cap_info |=
525 IEEE80211_HT_EXT_CAP_PCO;
526 temp_ht_cap = roam_ht_cap->transitionTime &
527 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
528 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
529 if (temp_ht_cap)
530 hdd_ht_cap->extended_ht_cap_info |=
531 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
532 temp_ht_cap = roam_ht_cap->mcsFeedback &
533 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
534 if (temp_ht_cap)
535 hdd_ht_cap->extended_ht_cap_info |=
536 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
537
538 /* tx_bf_cap_info capabilities */
539 if (roam_ht_cap->txBF)
540 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
541 if (roam_ht_cap->rxStaggeredSounding)
542 hdd_ht_cap->tx_BF_cap_info |=
543 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
544 if (roam_ht_cap->txStaggeredSounding)
545 hdd_ht_cap->tx_BF_cap_info |=
546 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
547 if (roam_ht_cap->rxZLF)
548 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
549 if (roam_ht_cap->txZLF)
550 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
551 if (roam_ht_cap->implicitTxBF)
552 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
553 temp_ht_cap = roam_ht_cap->calibration &
554 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
555 if (temp_ht_cap)
556 hdd_ht_cap->tx_BF_cap_info |=
557 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
558 if (roam_ht_cap->explicitCSITxBF)
559 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
560 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
561 hdd_ht_cap->tx_BF_cap_info |=
562 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
563 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
564 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
565 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
566 if (temp_ht_cap)
567 hdd_ht_cap->tx_BF_cap_info |=
568 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
569 temp_ht_cap =
570 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
571 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
572 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
573 if (temp_ht_cap)
574 hdd_ht_cap->tx_BF_cap_info |=
575 temp_ht_cap <<
576 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
577 temp_ht_cap =
578 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
579 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
580 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
581 if (temp_ht_cap)
582 hdd_ht_cap->tx_BF_cap_info |=
583 temp_ht_cap <<
584 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
585 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
586 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
587 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
588 if (temp_ht_cap)
589 hdd_ht_cap->tx_BF_cap_info |=
590 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
591 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
592 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
593 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
594 if (temp_ht_cap)
595 hdd_ht_cap->tx_BF_cap_info |=
596 temp_ht_cap <<
597 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
598 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
599 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
600 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
601 if (temp_ht_cap)
602 hdd_ht_cap->tx_BF_cap_info |=
603 temp_ht_cap <<
604 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
605
606 /* antenna selection */
607 if (roam_ht_cap->antennaSelection)
608 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
609 if (roam_ht_cap->explicitCSIFeedbackTx)
610 hdd_ht_cap->antenna_selection_info |=
611 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
612 if (roam_ht_cap->antennaIndicesFeedbackTx)
613 hdd_ht_cap->antenna_selection_info |=
614 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
615 if (roam_ht_cap->explicitCSIFeedback)
616 hdd_ht_cap->antenna_selection_info |=
617 ANTENNA_SEL_INFO_EXP_CSI_FB;
618 if (roam_ht_cap->antennaIndicesFeedback)
619 hdd_ht_cap->antenna_selection_info |=
620 ANTENNA_SEL_INFO_ANT_ID_FB;
621 if (roam_ht_cap->rxAS)
622 hdd_ht_cap->antenna_selection_info |=
623 ANTENNA_SEL_INFO_RX_AS;
624 if (roam_ht_cap->txSoundingPPDUs)
625 hdd_ht_cap->antenna_selection_info |=
626 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
627
628 /* mcs data rate */
629 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
630 hdd_ht_cap->mcs.rx_mask[i] =
631 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800632 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530633 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
634 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800635 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530636 roam_ht_cap->supportedMCSSet[12];
637}
638
639#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
640#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
641#define VHT_CAP_RXSTBC_MASK_SHIFT 8
642#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
643#define VHT_CAP_BEAMFORMEE_STS_MASK \
644 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
645#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
646#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
647 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
648#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
649#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
650 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
651#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
652
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530653void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
654 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530655{
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530656 uint32_t temp_vht_cap;
657
658 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
659
660 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
661 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
662 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
663 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
664 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800665 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530666 if (roam_vht_cap->supportedChannelWidthSet &
667 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
668 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
669 hdd_vht_cap->vht_cap_info |=
670 temp_vht_cap <<
671 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
672 if (roam_vht_cap->supportedChannelWidthSet &
673 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
674 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
675 hdd_vht_cap->vht_cap_info |=
676 temp_vht_cap <<
677 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800678 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530679 if (roam_vht_cap->ldpcCodingCap)
680 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
681 if (roam_vht_cap->shortGI80MHz)
682 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
683 if (roam_vht_cap->shortGI160and80plus80MHz)
684 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
685 if (roam_vht_cap->txSTBC)
686 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
687 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
688 VHT_CAP_RXSTBC_MASK_SHIFT);
689 if (temp_vht_cap)
690 hdd_vht_cap->vht_cap_info |=
691 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
692 if (roam_vht_cap->suBeamFormerCap)
693 hdd_vht_cap->vht_cap_info |=
694 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
695 if (roam_vht_cap->suBeamformeeCap)
696 hdd_vht_cap->vht_cap_info |=
697 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
698 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
699 (VHT_CAP_BEAMFORMEE_STS_MASK);
700 if (temp_vht_cap)
701 hdd_vht_cap->vht_cap_info |=
702 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
703 temp_vht_cap = roam_vht_cap->numSoundingDim &
704 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
705 if (temp_vht_cap)
706 hdd_vht_cap->vht_cap_info |=
707 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
708 if (roam_vht_cap->muBeamformerCap)
709 hdd_vht_cap->vht_cap_info |=
710 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
711 if (roam_vht_cap->muBeamformeeCap)
712 hdd_vht_cap->vht_cap_info |=
713 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
714 if (roam_vht_cap->vhtTXOPPS)
715 hdd_vht_cap->vht_cap_info |=
716 IEEE80211_VHT_CAP_VHT_TXOP_PS;
717 if (roam_vht_cap->htcVHTCap)
718 hdd_vht_cap->vht_cap_info |=
719 IEEE80211_VHT_CAP_HTC_VHT;
720 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
721 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
722 if (temp_vht_cap)
723 hdd_vht_cap->vht_cap_info |=
724 temp_vht_cap <<
725 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
726 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
727 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
728 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
729 if (temp_vht_cap)
730 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
731 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
732 if (roam_vht_cap->rxAntPattern)
733 hdd_vht_cap->vht_cap_info |=
734 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
735 if (roam_vht_cap->txAntPattern)
736 hdd_vht_cap->vht_cap_info |=
737 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
738 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
739 hdd_vht_cap->supp_mcs.rx_highest =
740 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
741 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
742 hdd_vht_cap->supp_mcs.tx_highest =
743 ((uint16_t)roam_vht_cap->txSupDataRate);
744}
745
746/* ht param */
747#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
748#define HT_PARAM_SERVICE_INT_GRAN 0xe0
749#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
750
751/* operatinon mode */
752#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
753
754/* stbc_param */
755#define HT_STBC_PARAM_MCS 0x007f
756
757/**
758 * hdd_copy_ht_operation()- copy HT operation element from roam info to
759 * hdd station context.
760 * @hdd_sta_ctx: pointer to hdd station context
761 * @roam_info: pointer to roam info
762 *
763 * Return: None
764 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700765static void hdd_copy_ht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800766 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530767{
768 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
769 struct ieee80211_ht_operation *hdd_ht_ops =
770 &hdd_sta_ctx->conn_info.ht_operation;
771 uint32_t i, temp_ht_ops;
772
773 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
774
775 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
776
777 /* HT_PARAMS */
778 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
779 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
780 if (temp_ht_ops)
781 hdd_ht_ops->ht_param |= temp_ht_ops;
782 else
783 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
784 if (roam_ht_ops->recommendedTxWidthSet)
785 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
786 if (roam_ht_ops->rifsMode)
787 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
788 if (roam_ht_ops->controlledAccessOnly)
789 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
790 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
791 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
792 if (temp_ht_ops)
793 hdd_ht_ops->ht_param |= temp_ht_ops <<
794 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
795
796 /* operation mode */
797 temp_ht_ops = roam_ht_ops->opMode &
798 IEEE80211_HT_OP_MODE_PROTECTION;
799 switch (temp_ht_ops) {
800 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
801 hdd_ht_ops->operation_mode |=
802 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
803 break;
804 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
805 hdd_ht_ops->operation_mode |=
806 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
807 break;
808 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
809 hdd_ht_ops->operation_mode |=
810 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
811 break;
812 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
813 default:
814 hdd_ht_ops->operation_mode |=
815 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
816 }
817 if (roam_ht_ops->nonGFDevicesPresent)
818 hdd_ht_ops->operation_mode |=
819 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
820 if (roam_ht_ops->transmitBurstLimit)
821 hdd_ht_ops->operation_mode |=
822 HT_OP_MODE_TX_BURST_LIMIT;
823 if (roam_ht_ops->obssNonHTStaPresent)
824 hdd_ht_ops->operation_mode |=
825 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
826
827 /* stbc_param */
828 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
829 HT_STBC_PARAM_MCS;
830 if (temp_ht_ops)
831 hdd_ht_ops->stbc_param |= temp_ht_ops;
832 if (roam_ht_ops->dualCTSProtection)
833 hdd_ht_ops->stbc_param |=
834 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
835 if (roam_ht_ops->secondaryBeacon)
836 hdd_ht_ops->stbc_param |=
837 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
838 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
839 hdd_ht_ops->stbc_param |=
840 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
841 if (roam_ht_ops->pcoActive)
842 hdd_ht_ops->stbc_param |=
843 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
844 if (roam_ht_ops->pcoPhase)
845 hdd_ht_ops->stbc_param |=
846 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
847
848 /* basic MCs set */
849 for (i = 0; i < 16; ++i)
850 hdd_ht_ops->basic_set[i] =
851 roam_ht_ops->basicMCSSet[i];
852}
853
Dustin Brown8aef46d2017-08-10 15:44:50 -0700854#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
855static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
856 tDot11fIEVHTOperation *roam_ops)
857{
858 ieee_ops->center_freq_seg0_idx = roam_ops->chanCenterFreqSeg1;
859 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg2;
860}
861#else
862static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
863 tDot11fIEVHTOperation *roam_ops)
864{
865 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg1;
866 ieee_ops->center_freq_seg2_idx = roam_ops->chanCenterFreqSeg2;
867}
868#endif /* KERNEL_VERSION(4, 12, 0) */
869
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530870/**
871 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
872 * hdd station context.
873 * @hdd_sta_ctx: pointer to hdd station context
874 * @roam_info: pointer to roam info
875 *
876 * Return: None
877 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700878static void hdd_copy_vht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800879 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530880{
881 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
882 struct ieee80211_vht_operation *hdd_vht_ops =
883 &hdd_sta_ctx->conn_info.vht_operation;
884
885 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
886
887 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
Dustin Brown8aef46d2017-08-10 15:44:50 -0700888 hdd_copy_vht_center_freq(hdd_vht_ops, roam_vht_ops);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530889 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
890}
891
892
893/**
894 * hdd_save_bss_info() - save connection info in hdd sta ctx
895 * @adapter: Pointer to adapter
896 * @roam_info: pointer to roam info
897 *
898 * Return: None
899 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700900static void hdd_save_bss_info(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -0800901 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530902{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700903 struct hdd_station_ctx *hdd_sta_ctx =
904 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530905
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530906 if (roam_info->vht_caps.present) {
907 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530908 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
909 &roam_info->vht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530910 } else {
911 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
912 }
913 if (roam_info->ht_caps.present) {
914 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Ashish Kumar Dhanotiya443d31f2017-10-13 12:41:19 +0530915 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps,
916 &roam_info->ht_caps);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530917 } else {
918 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
919 }
920 if (roam_info->reassoc)
921 hdd_sta_ctx->conn_info.roam_count++;
922 if (roam_info->hs20vendor_ie.present) {
923 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
924 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
925 &roam_info->hs20vendor_ie,
926 sizeof(roam_info->hs20vendor_ie));
927 } else {
928 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
929 }
930 if (roam_info->ht_operation.present) {
931 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
932 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
933 } else {
934 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
935 }
936 if (roam_info->vht_operation.present) {
937 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
938 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
939 } else {
940 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
941 }
Ashish Kumar Dhanotiya36d19b02018-02-22 00:59:49 +0530942 /* Cache last connection info */
943 qdf_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +0530944 sizeof(hdd_sta_ctx->cache_conn_info));
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530945}
946
947/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948 * hdd_conn_save_connect_info() - save current connection information
Jeff Johnsonba388342017-10-02 13:31:01 -0700949 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -0700950 * @roam_info: pointer to roam info
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800951 * @bss_type: bss type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952 *
953 * Return: none
954 */
955static void
Jeff Johnson172237b2017-11-07 15:32:59 -0800956hdd_conn_save_connect_info(struct hdd_adapter *adapter,
957 struct csr_roam_info *roam_info,
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800958 eCsrRoamBssType bss_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800959{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700960 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson1627e752019-03-23 12:33:37 -0700961 eCsrEncryptionType encrypt_type = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962
Jeff Johnsonfd060852017-10-04 10:50:51 -0700963 QDF_ASSERT(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964
Jeff Johnsonfd060852017-10-04 10:50:51 -0700965 if (roam_info) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 /* Save the BSSID for the connection */
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800967 if (eCSR_BSS_TYPE_INFRASTRUCTURE == bss_type) {
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +0530968 QDF_ASSERT(roam_info->bss_desc);
Jeff Johnsone04b6992019-02-27 14:06:55 -0800969 qdf_copy_macaddr(&sta_ctx->conn_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700970 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971
972 /*
973 * Save the Station ID for this station from
Jeff Johnson0a082d92019-03-04 12:25:49 -0800974 * the 'Roam Info'. For IBSS mode, sta_id is
975 * assigned in NEW_PEER_IND. For reassoc, the
976 * sta_id doesn't change and it may be invalid
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 * in this structure so no change here.
978 */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700979 if (!roam_info->fReassocReq) {
Jeff Johnson0a082d92019-03-04 12:25:49 -0800980 sta_ctx->conn_info.sta_id[0] =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700981 roam_info->staId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982 }
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800983 } else if (eCSR_BSS_TYPE_IBSS == bss_type) {
Jeff Johnsone04b6992019-02-27 14:06:55 -0800984 qdf_copy_macaddr(&sta_ctx->conn_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700985 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986 } else {
987 /*
988 * can't happen. We need a valid IBSS or Infra setting
989 * in the BSSDescription or we can't function.
990 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530991 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992 }
993
994 /* notify WMM */
Jeff Johnsonfdb993c2019-02-27 09:38:08 -0800995 hdd_wmm_connect(adapter, roam_info, bss_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800996
Jeff Johnsonfd060852017-10-04 10:50:51 -0700997 if (!roam_info->u.pConnectedProfile) {
998 QDF_ASSERT(roam_info->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 } else {
1000 /* Get Multicast Encryption Type */
Jeff Johnson1627e752019-03-23 12:33:37 -07001001 encrypt_type =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001002 roam_info->u.pConnectedProfile->mcEncryptionType;
Jeff Johnson1627e752019-03-23 12:33:37 -07001003 sta_ctx->conn_info.mc_encrypt_type = encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 /* Get Unicast Encryption Type */
Jeff Johnson1627e752019-03-23 12:33:37 -07001005 encrypt_type =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001006 roam_info->u.pConnectedProfile->EncryptionType;
Jeff Johnson1627e752019-03-23 12:33:37 -07001007 sta_ctx->conn_info.uc_encrypt_type = encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008
Jeff Johnson96e33512019-02-27 15:10:21 -08001009 sta_ctx->conn_info.auth_type =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001010 roam_info->u.pConnectedProfile->AuthType;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001011 sta_ctx->conn_info.last_auth_type =
Jeff Johnson96e33512019-02-27 15:10:21 -08001012 sta_ctx->conn_info.auth_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001013
Jingxiang Geae80dc62019-08-13 17:32:22 +08001014 sta_ctx->conn_info.chan_freq =
Jingxiang Gece7c5472019-07-23 16:19:23 +08001015 roam_info->u.pConnectedProfile->op_freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001016
1017 /* Save the ssid for the connection */
Jeff Johnson4aea1802019-02-27 10:21:33 -08001018 qdf_mem_copy(&sta_ctx->conn_info.ssid.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001019 &roam_info->u.pConnectedProfile->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020 sizeof(tSirMacSSid));
Jeff Johnsond377dce2017-10-04 10:32:42 -07001021 qdf_mem_copy(&sta_ctx->conn_info.last_ssid.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001022 &roam_info->u.pConnectedProfile->SSID,
Zhang Qian32fd43e2017-08-24 18:36:28 +08001023 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024
1025 /* Save dot11mode in which STA associated to AP */
Jeff Johnsonc52bc8b2019-02-27 17:49:33 -08001026 sta_ctx->conn_info.dot11mode =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001027 roam_info->u.pConnectedProfile->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001028
Jeff Johnsonac5170c2019-02-27 10:55:24 -08001029 sta_ctx->conn_info.proxy_arp_service =
1030 roam_info->u.pConnectedProfile->proxy_arp_service;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301031
Jeff Johnsonfd060852017-10-04 10:50:51 -07001032 sta_ctx->conn_info.nss = roam_info->chan_info.nss;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +05301033
Jeff Johnsond377dce2017-10-04 10:32:42 -07001034 sta_ctx->conn_info.rate_flags =
Jeff Johnsonfd060852017-10-04 10:50:51 -07001035 roam_info->chan_info.rate_flags;
Rajeev Kumar Sirasanagandla4c8edc02018-03-12 08:44:51 +05301036
1037 sta_ctx->conn_info.ch_width =
1038 roam_info->chan_info.ch_width;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001039 }
Jeff Johnsonfd060852017-10-04 10:50:51 -07001040 hdd_save_bss_info(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042}
1043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044/**
1045 * hdd_send_ft_assoc_response() - send fast transition assoc response
1046 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001047 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001048 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 *
1050 * Send the 11R key information to the supplicant. Only then can the supplicant
1051 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
1052 * for the same purpose.)
1053 *
1054 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
1055 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
1056 * This is the Assoc Response.
1057 *
1058 * Return: none
1059 */
1060static void
1061hdd_send_ft_assoc_response(struct net_device *dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07001062 struct hdd_adapter *adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001063 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001064{
1065 union iwreq_data wrqu;
1066 char *buff;
1067 unsigned int len = 0;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001068 u8 *assoc_rsp = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001069
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001070 if (roam_info->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001071 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 return;
1073 }
1074
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001075 assoc_rsp =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001076 (u8 *) (roam_info->pbFrames + roam_info->nBeaconLength +
1077 roam_info->nAssocReqLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001078 if (!assoc_rsp) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001079 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 return;
1081 }
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001082 /* assoc_rsp needs to point to the IEs */
1083 assoc_rsp += FT_ASSOC_RSP_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084
1085 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001086 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Min Liu74a1a502018-10-10 19:59:07 +08001087 if (!buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001088 return;
Min Liu74a1a502018-10-10 19:59:07 +08001089
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001091 len = roam_info->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 wrqu.data.length = len;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07001093 memcpy(buff, assoc_rsp, len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001094 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
1095
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001096 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001097}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001099/**
1100 * hdd_send_ft_event() - send fast transition event
Jeff Johnsonba388342017-10-02 13:31:01 -07001101 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001102 *
1103 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
1104 * FT events to the supplicant. At the reception of Auth2 we send the RIC
1105 * followed by the auth response IEs to the supplicant.
1106 * Once both are received in the supplicant, an FT event is generated
1107 * to the supplicant.
1108 *
1109 * Return: none
1110 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001111static void hdd_send_ft_event(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001112{
1113 uint16_t auth_resp_len = 0;
1114 uint32_t ric_ies_length = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001115 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001116 mac_handle_t mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001117
1118#if defined(KERNEL_SUPPORT_11R_CFG80211)
1119 struct cfg80211_ft_event_params ftEvent;
1120 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1121 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
Jeff Johnsonba388342017-10-02 13:31:01 -07001122 struct net_device *dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001123#else
1124 char *buff;
1125 union iwreq_data wrqu;
1126 uint16_t str_len;
1127#endif
1128
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001129 mac_handle = hdd_ctx->mac_handle;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001130#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301131 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1132 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133
Jeff Johnson1abc5662019-02-04 14:27:02 -08001134 sme_get_rici_es(mac_handle, adapter->vdev_id, (u8 *) ricIe,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001136 if (ric_ies_length == 0)
1137 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138
1139 ftEvent.ric_ies = ricIe;
1140 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001141 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001142
Jeff Johnson1abc5662019-02-04 14:27:02 -08001143 sme_get_ft_pre_auth_response(mac_handle, adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001144 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1145 &auth_resp_len);
1146
1147 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001148 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001149 return;
1150 }
1151
Jeff Johnson1abc5662019-02-04 14:27:02 -08001152 sme_set_ft_pre_auth_state(mac_handle, adapter->vdev_id, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153
1154 ftEvent.target_ap = ftIe;
1155
Anurag Chouhan6d760662016-02-20 16:05:43 +05301156 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1157 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001159 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1160 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1161 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 ftEvent.target_ap[0], ftEvent.target_ap[1],
1163 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1164 ftEvent.target_ap[5]);
1165
1166 (void)cfg80211_ft_event(dev, &ftEvent);
1167
1168#else
1169 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001170 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Min Liu74a1a502018-10-10 19:59:07 +08001171 if (!buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001172 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001173
1174 /* Sme needs to send the RIC IEs first */
1175 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Jeff Johnson1abc5662019-02-04 14:27:02 -08001176 sme_get_rici_es(mac_handle, adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1178 &ric_ies_length);
1179 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001180 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001181 } else {
1182 wrqu.data.length = str_len + ric_ies_length;
Jeff Johnsonba388342017-10-02 13:31:01 -07001183 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 }
1185
1186 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301187 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Jeff Johnson1abc5662019-02-04 14:27:02 -08001189 sme_get_ft_pre_auth_response(mac_handle, adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190 (u8 *) &buff[str_len],
1191 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1192
1193 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001194 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001195 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 return;
1197 }
1198
1199 wrqu.data.length = str_len + auth_resp_len;
Jeff Johnsonba388342017-10-02 13:31:01 -07001200 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001202 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203#endif
1204}
1205
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206#ifdef FEATURE_WLAN_ESE
1207/**
1208 * hdd_send_new_ap_channel_info() - send new ap channel info
1209 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001210 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001211 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 *
1213 * Send the ESE required "new AP Channel info" to the supplicant.
1214 * (This keeps the supplicant "up to date" on the current channel.)
1215 *
1216 * The current (new AP) channel information is passed in.
1217 *
1218 * Return: none
1219 */
1220static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07001221hdd_send_new_ap_channel_info(struct net_device *dev,
1222 struct hdd_adapter *adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001223 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001224{
1225 union iwreq_data wrqu;
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05301226 struct bss_description *descriptor = roam_info->bss_desc;
wadesong91a2c1b2019-07-12 12:18:06 +08001227 mac_handle_t mac_hdl;
1228 struct wlan_objmgr_pdev *pdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229
Jeff Johnsond36fa332019-03-18 13:42:25 -07001230 if (!descriptor) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001231 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 return;
1233 }
1234 /*
1235 * Send the Channel event, the supplicant needs this to generate
1236 * the Adjacent AP report.
1237 */
wadesong91a2c1b2019-07-12 12:18:06 +08001238 hdd_debug("Sending up an SIOCGIWFREQ, channel freq: %d",
1239 descriptor->chan_freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 memset(&wrqu, '\0', sizeof(wrqu));
wadesong91a2c1b2019-07-12 12:18:06 +08001241 mac_hdl = hdd_adapter_get_mac_handle(adapter);
1242 if (!mac_hdl) {
1243 hdd_err("MAC handle invalid, falling back!");
1244 return;
1245 }
1246 pdev = MAC_CONTEXT(mac_hdl)->pdev;
1247 if (!pdev) {
1248 hdd_err("pdev invalid in MAC context, falling back!");
1249 return;
1250 }
1251 wrqu.freq.m = wlan_reg_freq_to_chan(pdev, descriptor->chan_freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 wrqu.freq.e = 0;
1253 wrqu.freq.i = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001254 wireless_send_event(adapter->dev, SIOCGIWFREQ, &wrqu, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001255}
1256
1257#endif /* FEATURE_WLAN_ESE */
1258
1259/**
1260 * hdd_send_update_beacon_ies_event() - send update beacons ie event
Jeff Johnsonba388342017-10-02 13:31:01 -07001261 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001262 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001263 *
1264 * Return: none
1265 */
1266static void
Jeff Johnsonba388342017-10-02 13:31:01 -07001267hdd_send_update_beacon_ies_event(struct hdd_adapter *adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001268 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001269{
1270 union iwreq_data wrqu;
Jeff Johnson04e00082017-10-04 12:15:58 -07001271 u8 *beacon_ies;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272 u8 currentLen = 0;
1273 char *buff;
1274 int totalIeLen = 0, currentOffset = 0, strLen;
1275
1276 memset(&wrqu, '\0', sizeof(wrqu));
1277
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001278 if (0 == roam_info->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001279 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 return;
1281 }
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001282 beacon_ies = (u8 *) (roam_info->pbFrames + BEACON_FRAME_IES_OFFSET);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001283 if (!beacon_ies) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001284 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001285 return;
1286 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001287 /* beacon_ies needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001288 hdd_debug("Beacon IEs is now at %02x%02x",
Jeff Johnson04e00082017-10-04 12:15:58 -07001289 (unsigned int)beacon_ies[0],
1290 (unsigned int)beacon_ies[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001291 hdd_debug("Beacon IEs length = %d",
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001292 roam_info->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293
1294 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001295 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Min Liu74a1a502018-10-10 19:59:07 +08001296 if (!buff)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298
1299 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1300 currentLen = strLen + 1;
1301
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001302 totalIeLen = roam_info->nBeaconLength - BEACON_FRAME_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 do {
1304 /*
1305 * If the beacon size exceeds max CUSTOM event size, break it
1306 * into chunks of CUSTOM event max size and send it to
1307 * supplicant. Changes are done in supplicant to handle this.
1308 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301309 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301311 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Jeff Johnson04e00082017-10-04 12:15:58 -07001312 qdf_mem_copy(&buff[strLen + 1], beacon_ies + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001313 currentLen);
1314 currentOffset += currentLen;
1315 totalIeLen -= currentLen;
1316 wrqu.data.length = strLen + 1 + currentLen;
1317 if (totalIeLen)
1318 buff[strLen] = 1; /* more chunks pending */
1319 else
1320 buff[strLen] = 0; /* last chunk */
1321
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001322 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001323 currentLen);
Jeff Johnsonba388342017-10-02 13:31:01 -07001324 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325 } while (totalIeLen > 0);
1326
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001327 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001328}
1329
1330/**
1331 * hdd_send_association_event() - send association event
1332 * @dev: pointer to net device
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001333 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 *
1335 * Return: none
1336 */
1337static void hdd_send_association_event(struct net_device *dev,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001338 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339{
Rajeev Kumar78427682017-01-13 16:13:11 -08001340 int ret;
Jeff Johnsonba388342017-10-02 13:31:01 -07001341 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1342 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001343 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001344 union iwreq_data wrqu;
1345 int we_event;
1346 char *msg;
Jeff Johnson2d044612019-02-26 20:08:43 -08001347 struct qdf_mac_addr peer_macaddr;
Jeff Johnson844eec72018-03-13 11:48:18 -07001348 struct csr_roam_profile *roam_profile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349
Jeff Johnson844eec72018-03-13 11:48:18 -07001350 roam_profile = hdd_roam_profile(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001351 memset(&wrqu, '\0', sizeof(wrqu));
1352 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1353 we_event = SIOCGIWAP;
1354#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsond36fa332019-03-18 13:42:25 -07001355 if (roam_info)
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001356 if (roam_info->roamSynchInProgress) {
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301357 /* Update tdls module about the disconnection event */
Jeff Johnson1abc5662019-02-04 14:27:02 -08001358 hdd_notify_sta_disconnect(adapter->vdev_id,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001359 true, false,
Dustin Brown89fa06e2018-09-07 10:47:27 -07001360 adapter->vdev);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301361 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001362#endif
Jeff Johnsone7951512019-02-27 10:02:51 -08001363 if (eConnectionState_Associated == sta_ctx->conn_info.conn_state) {
Jeff Johnsona7d5b542019-02-03 10:15:46 -08001364 struct oem_channel_info chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301365
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05301366 if (!roam_info || !roam_info->bss_desc) {
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001367 hdd_warn("STA in associated state but roam_info is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368 return;
1369 }
1370
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001371 if (!hdd_is_roam_sync_in_progress(roam_info)) {
Dustin Brown76cd2932018-09-11 16:03:05 -07001372 policy_mgr_incr_active_session(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001373 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07001374 hdd_green_ap_start_state_mc(hdd_ctx,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05301375 adapter->device_mode, true);
1376 }
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05301377 memcpy(wrqu.ap_addr.sa_data, roam_info->bss_desc->bssId,
1378 sizeof(roam_info->bss_desc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001379
Dustin Brown89fa06e2018-09-07 10:47:27 -07001380 ucfg_p2p_status_connect(adapter->vdev);
Wu Gaoc02785d2017-09-07 18:17:13 +08001381
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001382 hdd_info("wlan: " QDF_MAC_ADDR_STR " connected to "
1383 QDF_MAC_ADDR_STR "\n",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001384 QDF_MAC_ADDR_ARRAY(adapter->mac_addr.bytes),
1385 QDF_MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001386 hdd_send_update_beacon_ies_event(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001387
1388 /*
1389 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1390 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001391 * fFTEnable is true.
1392 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001393 */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001394 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001395 eCSR_AUTH_TYPE_FT_RSN_PSK)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001396 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001397 eCSR_AUTH_TYPE_FT_RSN)
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05301398 || (roam_profile->AuthType.authType[0] ==
1399 eCSR_AUTH_TYPE_FT_SAE)
1400 || (roam_profile->AuthType.authType[0] ==
1401 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402#ifdef FEATURE_WLAN_ESE
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001403 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 eCSR_AUTH_TYPE_CCKM_RSN)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001405 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001406 eCSR_AUTH_TYPE_CCKM_WPA)
1407#endif
1408 ) {
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001409 hdd_send_ft_assoc_response(dev, adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 }
Jeff Johnson2d044612019-02-26 20:08:43 -08001411 qdf_copy_macaddr(&peer_macaddr,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001412 &sta_ctx->conn_info.bssid);
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001413 chan_info.chan_id = roam_info->chan_info.chan_id;
1414 chan_info.mhz = roam_info->chan_info.mhz;
1415 chan_info.info = roam_info->chan_info.info;
Abhishek Singh1c676222016-05-09 14:20:28 +05301416 chan_info.band_center_freq1 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001417 roam_info->chan_info.band_center_freq1;
Abhishek Singh1c676222016-05-09 14:20:28 +05301418 chan_info.band_center_freq2 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001419 roam_info->chan_info.band_center_freq2;
Abhishek Singh1c676222016-05-09 14:20:28 +05301420 chan_info.reg_info_1 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001421 roam_info->chan_info.reg_info_1;
Abhishek Singh1c676222016-05-09 14:20:28 +05301422 chan_info.reg_info_2 =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001423 roam_info->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301424
Dustin Brown89fa06e2018-09-07 10:47:27 -07001425 ret = hdd_objmgr_set_peer_mlme_state(adapter->vdev,
Dustin Brown7d043f62017-03-27 12:07:36 -07001426 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301427 if (ret)
1428 hdd_err("Peer object %pM fail to set associated state",
Jeff Johnson2d044612019-02-26 20:08:43 -08001429 peer_macaddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301430
Abhishek Singh1c676222016-05-09 14:20:28 +05301431 /* send peer status indication to oem app */
Jeff Johnson2d044612019-02-26 20:08:43 -08001432 hdd_send_peer_status_ind_to_app(&peer_macaddr,
Naveen Rawat910726a2017-03-06 11:42:51 -08001433 ePeerConnected,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001434 roam_info->timingMeasCap,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001435 adapter->vdev_id, &chan_info,
Jeff Johnsonba388342017-10-02 13:31:01 -07001436 adapter->device_mode);
jiad7b8a5e02018-11-26 16:37:57 +08001437
1438#ifdef FEATURE_WLAN_TDLS
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001439 /* Update tdls module about connection event */
Jeff Johnson1abc5662019-02-04 14:27:02 -08001440 hdd_notify_sta_connect(adapter->vdev_id,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001441 roam_info->tdls_chan_swit_prohibited,
1442 roam_info->tdls_prohibited,
Dustin Brown89fa06e2018-09-07 10:47:27 -07001443 adapter->vdev);
jiad7b8a5e02018-11-26 16:37:57 +08001444#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001445 /* start timer in sta/p2p_cli */
Sravan Kumar Kairam777a7dd2019-08-01 21:46:30 +05301446 hdd_bus_bw_compute_prev_txrx_stats(adapter);
Jeff Johnson8095a312017-09-03 09:13:24 -07001447 hdd_bus_bw_compute_timer_start(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001448 } else if (eConnectionState_IbssConnected == /* IBss Associated */
Jeff Johnsone7951512019-02-27 10:02:51 -08001449 sta_ctx->conn_info.conn_state) {
Dustin Brown76cd2932018-09-11 16:03:05 -07001450 policy_mgr_update_connection_info(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001451 adapter->vdev_id);
Jeff Johnsone04b6992019-02-27 14:06:55 -08001452 memcpy(wrqu.ap_addr.sa_data, sta_ctx->conn_info.bssid.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001453 ETH_ALEN);
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07001454 hdd_debug("wlan: new IBSS peer connection to BSSID " QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07001455 QDF_MAC_ADDR_ARRAY(sta_ctx->conn_info.bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001456 } else { /* Not Associated */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301457 hdd_debug("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Dustin Brown76cd2932018-09-11 16:03:05 -07001459 policy_mgr_decr_session_set_pcl(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001460 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07001461 hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05301462 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463
1464#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001465 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466#endif
1467
Jeff Johnsonba388342017-10-02 13:31:01 -07001468 if ((adapter->device_mode == QDF_STA_MODE) ||
Jeff Johnson844eec72018-03-13 11:48:18 -07001469 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Jeff Johnson2d044612019-02-26 20:08:43 -08001470 qdf_copy_macaddr(&peer_macaddr,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001471 &sta_ctx->conn_info.bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472
1473 /* send peer status indication to oem app */
Jeff Johnson2d044612019-02-26 20:08:43 -08001474 hdd_send_peer_status_ind_to_app(&peer_macaddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301475 ePeerDisconnected, 0,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001476 adapter->vdev_id,
Abhishek Singh1c676222016-05-09 14:20:28 +05301477 NULL,
Jeff Johnsonba388342017-10-02 13:31:01 -07001478 adapter->device_mode);
Abhishek Singh44725482017-11-02 16:53:23 +05301479 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301480
Jeff Johnsonba388342017-10-02 13:31:01 -07001481 hdd_lpass_notify_disconnect(adapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001482 /* Update tdls module about the disconnection event */
Jeff Johnson1abc5662019-02-04 14:27:02 -08001483 hdd_notify_sta_disconnect(adapter->vdev_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001484 false,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001485 false,
Dustin Brown89fa06e2018-09-07 10:47:27 -07001486 adapter->vdev);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001487
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001488 /* stop timer in sta/p2p_cli */
Sravan Kumar Kairam777a7dd2019-08-01 21:46:30 +05301489 hdd_bus_bw_compute_reset_prev_txrx_stats(adapter);
Jeff Johnson8095a312017-09-03 09:13:24 -07001490 hdd_bus_bw_compute_timer_try_stop(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001492 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001493
1494 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001495 /* During the WLAN uninitialization,supplicant is stopped before the
1496 * driver so not sending the status of the connection to supplicant
1497 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001498 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001499 wireless_send_event(dev, we_event, &wrqu, msg);
1500#ifdef FEATURE_WLAN_ESE
1501 if (eConnectionState_Associated ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001502 sta_ctx->conn_info.conn_state) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001503 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 eCSR_AUTH_TYPE_CCKM_RSN) ||
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001505 (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 eCSR_AUTH_TYPE_CCKM_WPA))
Jeff Johnsonba388342017-10-02 13:31:01 -07001507 hdd_send_new_ap_channel_info(dev, adapter,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001508 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001509 }
1510#endif
1511 }
1512}
1513
1514/**
1515 * hdd_conn_remove_connect_info() - remove connection info
Jeff Johnsond377dce2017-10-04 10:32:42 -07001516 * @sta_ctx: pointer to global HDD station context
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07001517 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001518 *
1519 * Return: none
1520 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001521static void hdd_conn_remove_connect_info(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522{
Jeff Johnson0a082d92019-03-04 12:25:49 -08001523 /* Remove sta_id, bssid and peer_macaddr */
1524 sta_ctx->conn_info.sta_id[0] = HDD_WLAN_INVALID_STA_ID;
Jeff Johnsone04b6992019-02-27 14:06:55 -08001525 qdf_mem_zero(&sta_ctx->conn_info.bssid, QDF_MAC_ADDR_SIZE);
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08001526 qdf_mem_zero(&sta_ctx->conn_info.peer_macaddr[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301527 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001528
1529 /* Clear all security settings */
Jeff Johnson96e33512019-02-27 15:10:21 -08001530 sta_ctx->conn_info.auth_type = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonb1959842019-02-27 13:04:04 -08001531 sta_ctx->conn_info.mc_encrypt_type = eCSR_ENCRYPT_TYPE_NONE;
1532 sta_ctx->conn_info.uc_encrypt_type = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533
Jeff Johnsond377dce2017-10-04 10:32:42 -07001534 qdf_mem_zero(&sta_ctx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535
Jeff Johnsonac5170c2019-02-27 10:55:24 -08001536 sta_ctx->conn_info.proxy_arp_service = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001537
Jeff Johnson4aea1802019-02-27 10:21:33 -08001538 qdf_mem_zero(&sta_ctx->conn_info.ssid, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539}
1540
1541/**
Jeff Johnson7f2c5912018-03-23 11:42:28 -07001542 * hdd_clear_roam_profile_ie() - Clear Roam Profile IEs
1543 * @adapter: adapter who's IEs are to be cleared
1544 *
1545 * Return: None
1546 */
1547static void hdd_clear_roam_profile_ie(struct hdd_adapter *adapter)
1548{
1549 struct hdd_station_ctx *sta_ctx;
1550 struct csr_roam_profile *roam_profile;
1551
1552 hdd_enter();
1553
1554 /* clear WPA/RSN/WSC IE information in the profile */
1555 roam_profile = hdd_roam_profile(adapter);
1556
1557 roam_profile->nWPAReqIELength = 0;
1558 roam_profile->pWPAReqIE = NULL;
1559 roam_profile->nRSNReqIELength = 0;
1560 roam_profile->pRSNReqIE = NULL;
1561
1562#ifdef FEATURE_WLAN_WAPI
1563 roam_profile->nWAPIReqIELength = 0;
1564 roam_profile->pWAPIReqIE = NULL;
1565#endif
1566
1567 roam_profile->bWPSAssociation = false;
1568 roam_profile->bOSENAssociation = false;
1569 roam_profile->pAddIEScan = NULL;
1570 roam_profile->nAddIEScanLength = 0;
1571 roam_profile->pAddIEAssoc = NULL;
1572 roam_profile->nAddIEAssocLength = 0;
1573
1574 roam_profile->EncryptionType.numEntries = 1;
1575 roam_profile->EncryptionType.encryptionType[0] =
1576 eCSR_ENCRYPT_TYPE_NONE;
1577
1578 roam_profile->mcEncryptionType.numEntries = 1;
1579 roam_profile->mcEncryptionType.encryptionType[0] =
1580 eCSR_ENCRYPT_TYPE_NONE;
1581
1582 roam_profile->AuthType.numEntries = 1;
1583 roam_profile->AuthType.authType[0] =
1584 eCSR_AUTH_TYPE_OPEN_SYSTEM;
1585
1586 qdf_mem_zero(roam_profile->bssid_hint.bytes, QDF_MAC_ADDR_SIZE);
1587
1588#ifdef WLAN_FEATURE_11W
1589 roam_profile->MFPEnabled = false;
1590 roam_profile->MFPRequired = 0;
1591 roam_profile->MFPCapable = 0;
1592#endif
1593
1594 qdf_mem_zero(roam_profile->Keys.KeyLength, CSR_MAX_NUM_KEY);
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +05301595 qdf_mem_zero(roam_profile->Keys.KeyMaterial,
1596 sizeof(roam_profile->Keys.KeyMaterial));
Jeff Johnson7f2c5912018-03-23 11:42:28 -07001597#ifdef FEATURE_WLAN_WAPI
1598 adapter->wapi_info.wapi_auth_mode = WAPI_AUTH_MODE_OPEN;
1599 adapter->wapi_info.wapi_mode = false;
1600#endif
1601
1602 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1603 sta_ctx->auth_key_mgmt = 0;
1604 qdf_zero_macaddr(&sta_ctx->requested_bssid);
Srinivas Dasarie3ef7c62018-12-28 13:16:09 +05301605 hdd_clear_fils_connection_info(adapter);
Jeff Johnson7f2c5912018-03-23 11:42:28 -07001606 hdd_exit();
1607}
1608
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05301609QDF_STATUS hdd_roam_deregister_sta(struct hdd_adapter *adapter,
1610 struct qdf_mac_addr mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301612 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001613
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001614 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001615 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05301616 mac_addr);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301617 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05301618 hdd_err("cdp_clear_peer() failed for sta mac: "
1619 QDF_MAC_ADDR_STR ". Status(%d) [0x%08X]",
1620 QDF_MAC_ADDR_ARRAY(mac_addr.bytes),
1621 qdf_status, qdf_status);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301622 }
1623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301624 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625}
1626
1627/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301628 * hdd_print_bss_info() - print bss info
1629 * @hdd_sta_ctx: pointer to hdd station context
1630 *
1631 * Return: None
1632 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001633static void hdd_print_bss_info(struct hdd_station_ctx *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301634{
1635 uint32_t *cap_info;
1636
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301637 hdd_debug("WIFI DATA LOGGER");
Jingxiang Geae80dc62019-08-13 17:32:22 +08001638 hdd_debug("chan_freq: %d",
1639 hdd_sta_ctx->conn_info.chan_freq);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301640 hdd_debug("dot11mode: %d",
Jeff Johnsonc52bc8b2019-02-27 17:49:33 -08001641 hdd_sta_ctx->conn_info.dot11mode);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301642 hdd_debug("AKM: %d",
1643 hdd_sta_ctx->conn_info.last_auth_type);
1644 hdd_debug("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001645 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1646 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301647 hdd_debug("roam count: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301648 hdd_sta_ctx->conn_info.roam_count);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301649 hdd_debug("ant_info: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301650 hdd_sta_ctx->conn_info.txrate.nss);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301651 hdd_debug("datarate legacy %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301652 hdd_sta_ctx->conn_info.txrate.legacy);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301653 hdd_debug("datarate mcs: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301654 hdd_sta_ctx->conn_info.txrate.mcs);
1655 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1656 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301657 hdd_debug("ht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301658 }
1659 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1660 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301661 hdd_debug("vht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301662 }
1663 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301664 hdd_debug("hs20 info: %x",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301665 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301666 hdd_debug("signal: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301667 hdd_sta_ctx->conn_info.signal);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301668 hdd_debug("noise: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301669 hdd_sta_ctx->conn_info.noise);
1670}
1671
1672/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 * hdd_dis_connect_handler() - disconnect event handler
Jeff Johnsonba388342017-10-02 13:31:01 -07001674 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07001675 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08001676 * @roam_id: roam identifier
1677 * @roam_status: roam status
1678 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 *
1680 * This function handles disconnect event:
1681 * 1. Disable transmit queues;
1682 * 2. Clean up internal connection states and data structures;
1683 * 3. Send disconnect indication to supplicant.
1684 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301685 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001687static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001688 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08001689 uint32_t roam_id,
1690 eRoamCmdStatus roam_status,
1691 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301693 QDF_STATUS status = QDF_STATUS_SUCCESS;
1694 QDF_STATUS vstatus;
Jeff Johnsonba388342017-10-02 13:31:01 -07001695 struct net_device *dev = adapter->dev;
1696 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001697 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 uint8_t sta_id;
1699 bool sendDisconInd = true;
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001700 mac_handle_t mac_handle;
Srinivas Dasarid4e87252019-07-01 15:35:52 +05301701 struct wlan_ies disconnect_ies = {0};
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001702
Jeff Johnsond36fa332019-03-18 13:42:25 -07001703 if (!dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001704 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301705 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 }
1707 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001708 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07001709 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301710 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1711 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001712
gaurank kathpalia63311d12018-04-12 14:34:26 +05301713 if (ucfg_ipa_is_enabled() &&
Jeff Johnson0a082d92019-03-04 12:25:49 -08001714 (sta_ctx->conn_info.sta_id[0] != HDD_WLAN_INVALID_STA_ID))
Dustin Brown07901ec2018-09-07 11:02:41 -07001715 ucfg_ipa_wlan_evt(hdd_ctx->pdev, adapter->dev,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05301716 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001717 adapter->vdev_id,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05301718 WLAN_IPA_STA_DISCONNECT,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001719 sta_ctx->conn_info.bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720
1721#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001722 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723#endif
1724
Nirav Shah1da77682016-05-03 20:16:39 +05301725 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001726 adapter->vdev_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001727 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301728 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001729
1730 /* HDD has initiated disconnect, do not send disconnect indication
1731 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301732 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001733 * to cfg80211_disconnected.
1734 */
1735 if ((eConnectionState_Disconnecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001736 sta_ctx->conn_info.conn_state) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 (eConnectionState_NotConnected ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001738 sta_ctx->conn_info.conn_state) ||
Abhinav Kumar74948192018-05-09 17:17:50 +05301739 (eConnectionState_Connecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -08001740 sta_ctx->conn_info.conn_state)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001741 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001742 sendDisconInd = false;
Abhinav Kumar74948192018-05-09 17:17:50 +05301743 } else {
Jeff Johnsonba388342017-10-02 13:31:01 -07001744 INIT_COMPLETION(adapter->disconnect_comp_var);
1745 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746 eConnectionState_Disconnecting);
1747 }
1748
Jeff Johnsonba388342017-10-02 13:31:01 -07001749 hdd_clear_roam_profile_ie(adapter);
1750 hdd_wmm_init(adapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001751 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301752 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753
1754 /* indicate 'disconnect' status to wpa_supplicant... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07001755 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 /* indicate disconnected event to nl80211 */
Jeff Johnson29c78672019-02-26 21:05:53 -08001757 if (roam_status != eCSR_ROAM_IBSS_LEAVE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 /*
1759 * Only send indication to kernel if not initiated
1760 * by kernel
1761 */
1762 if (sendDisconInd) {
Srinivas Dasarid4e87252019-07-01 15:35:52 +05301763 if (roam_info && roam_info->disconnect_ies) {
1764 disconnect_ies.data =
1765 roam_info->disconnect_ies->data;
1766 disconnect_ies.len =
1767 roam_info->disconnect_ies->len;
1768 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001769 /*
1770 * To avoid wpa_supplicant sending "HANGED" CMD
1771 * to ICS UI.
1772 */
Jeff Johnson29c78672019-02-26 21:05:53 -08001773 if (eCSR_ROAM_LOSTLINK == roam_status) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07001774 if (roam_info->reasonCode ==
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001775 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
Jeff Johnson435e1b82017-10-07 14:13:10 -07001776 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n",
1777 roam_info->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301778 wlan_hdd_cfg80211_indicate_disconnect(
1779 dev, false,
Srinivas Dasarid4e87252019-07-01 15:35:52 +05301780 roam_info->reasonCode,
1781 disconnect_ies.data,
1782 disconnect_ies.len);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001783 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301784 wlan_hdd_cfg80211_indicate_disconnect(
1785 dev, false,
Srinivas Dasarid4e87252019-07-01 15:35:52 +05301786 WLAN_REASON_UNSPECIFIED,
1787 disconnect_ies.data,
1788 disconnect_ies.len);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001789 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301791 hdd_debug("sent disconnected event to nl80211, reason code %d",
Jeff Johnson29c78672019-02-26 21:05:53 -08001792 (eCSR_ROAM_LOSTLINK == roam_status) ?
Jeff Johnsonfd060852017-10-04 10:50:51 -07001793 roam_info->reasonCode :
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301794 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796
Wu Gaoc02785d2017-09-07 18:17:13 +08001797 /* update P2P connection status */
Dustin Brown89fa06e2018-09-07 10:47:27 -07001798 ucfg_p2p_status_disconnect(adapter->vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 }
1800
gaurank kathpalia7ef72182019-05-29 19:41:25 +05301801 /* Inform BLM about the disconnection with the AP */
1802 if (adapter->device_mode == QDF_STA_MODE)
1803 ucfg_blm_update_bssid_connect_params(hdd_ctx->pdev,
1804 sta_ctx->conn_info.bssid,
1805 BLM_AP_DISCONNECTED);
1806
Jeff Johnsonba388342017-10-02 13:31:01 -07001807 hdd_wmm_adapter_clear(adapter);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001808 mac_handle = hdd_ctx->mac_handle;
Jeff Johnson1abc5662019-02-04 14:27:02 -08001809 sme_ft_reset(mac_handle, adapter->vdev_id);
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +05301810 sme_reset_key(mac_handle, adapter->vdev_id);
Abhinav Kumar39222152019-05-13 23:53:40 +05301811 if (!hdd_remove_beacon_filter(adapter)) {
1812 if (sme_is_beacon_report_started(mac_handle,
1813 adapter->vdev_id)) {
1814 hdd_beacon_recv_pause_indication((hdd_handle_t)hdd_ctx,
1815 adapter->vdev_id,
1816 SCAN_EVENT_TYPE_MAX,
1817 true);
1818 }
1819 }
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001820
Jeff Johnson29c78672019-02-26 21:05:53 -08001821 if (eCSR_ROAM_IBSS_LEAVE == roam_status) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301822 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001823
Jeff Johnson0a082d92019-03-04 12:25:49 -08001824 sta_id = sta_ctx->broadcast_sta_id;
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05301825 vstatus = hdd_roam_deregister_sta(adapter,
1826 sta_ctx->conn_info.bssid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301827 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001828 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301829 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301830 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001832 if (sta_id < HDD_MAX_ADAPTERS)
1833 hdd_ctx->sta_to_adapter[sta_id] = NULL;
1834 else
1835 hdd_debug("invalid sta id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301836 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001837 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001838 if (HDD_WLAN_INVALID_STA_ID ==
Jeff Johnson0a082d92019-03-04 12:25:49 -08001839 sta_ctx->conn_info.sta_id[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301840 continue;
Jeff Johnson0a082d92019-03-04 12:25:49 -08001841 sta_id = sta_ctx->conn_info.sta_id[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001842 hdd_debug("Deregister StaID %d", sta_id);
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05301843 vstatus = hdd_roam_deregister_sta(
1844 adapter,
1845 sta_ctx->conn_info.peer_macaddr[i]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301846 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001847 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301848 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301849 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301850 }
Jeff Johnson0a082d92019-03-04 12:25:49 -08001851 /* set the sta_id and peer mac as 0, all other
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301852 * reset are done in hdd_connRemoveConnectInfo.
1853 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08001854 sta_ctx->conn_info.sta_id[i] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301855 HDD_WLAN_INVALID_STA_ID;
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08001856 qdf_mem_zero(&sta_ctx->conn_info.peer_macaddr[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301857 sizeof(struct qdf_mac_addr));
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001858 if (sta_id < HDD_MAX_ADAPTERS)
Jeff Johnson8095a312017-09-03 09:13:24 -07001859 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001860 else
1861 hdd_debug("invalid sta_id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301862 }
1863 } else {
Jeff Johnson0a082d92019-03-04 12:25:49 -08001864 sta_id = sta_ctx->conn_info.sta_id[0];
Jeff Johnson29c78672019-02-26 21:05:53 -08001865 hdd_debug("roam_result: %d", roam_result);
Abhishek Singhc9941602016-08-09 16:06:22 +05301866
1867 /* clear scan cache for Link Lost */
Jeff Johnson29c78672019-02-26 21:05:53 -08001868 if (eCSR_ROAM_RESULT_DEAUTH_IND == roam_result ||
1869 eCSR_ROAM_RESULT_DISASSOC_IND == roam_result ||
1870 eCSR_ROAM_LOSTLINK == roam_status) {
Abhishek Singh85283ae2019-03-08 12:00:51 +05301871 wlan_hdd_cfg80211_unlink_bss(adapter,
Ashish Kumar Dhanotiya3d8b0ae2019-07-10 20:55:56 +05301872 sta_ctx->conn_info.bssid.bytes,
1873 sta_ctx->conn_info.ssid.SSID.ssId,
1874 sta_ctx->conn_info.ssid.SSID.length);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001875 sme_remove_bssid_from_scan_list(mac_handle,
Jeff Johnsone04b6992019-02-27 14:06:55 -08001876 sta_ctx->conn_info.bssid.bytes);
Abhishek Singhc9941602016-08-09 16:06:22 +05301877 }
Rajeev Kumar4bc998f2017-10-19 14:41:43 -07001878 if (sta_id < HDD_MAX_ADAPTERS)
1879 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001880 else
1881 hdd_debug("invalid sta_id %d", sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883 /* Clear saved connection information in HDD */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001884 hdd_conn_remove_connect_info(sta_ctx);
Abhinav Kumar74948192018-05-09 17:17:50 +05301885 /*
1886 * eConnectionState_Connecting state mean that connection is in
1887 * progress so no need to set state to eConnectionState_NotConnected
1888 */
Jeff Johnsone7951512019-02-27 10:02:51 -08001889 if ((eConnectionState_Connecting != sta_ctx->conn_info.conn_state)) {
Srinivas Girigowda683726a2018-09-07 15:10:40 -07001890 hdd_conn_set_connection_state(adapter,
Abhinav Kumar74948192018-05-09 17:17:50 +05301891 eConnectionState_NotConnected);
Dundi Raviteja04037a12018-08-31 18:41:44 +05301892 hdd_set_roaming_in_progress(false);
Abhinav Kumar74948192018-05-09 17:17:50 +05301893 }
Wu Gaod7dd6e42018-10-16 17:22:56 +08001894 ucfg_pmo_flush_gtk_offload_req(adapter->vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001895
Jeff Johnsonba388342017-10-02 13:31:01 -07001896 if ((QDF_STA_MODE == adapter->device_mode) ||
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001897 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
1898 sme_ps_disable_auto_ps_timer(mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08001899 adapter->vdev_id);
Yeshwanth Sriram Guntuka4fe30bd2018-06-13 11:41:42 +05301900 adapter->send_mode_change = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 }
Jeff Johnsonba388342017-10-02 13:31:01 -07001902 wlan_hdd_clear_link_layer_stats(adapter);
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301903
Bala Venkatesh9f958142018-06-27 12:36:08 +05301904 hdd_debug("check for SAP restart");
Dustin Brown76cd2932018-09-11 16:03:05 -07001905 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->psoc);
Jeff Johnson6ced42c2017-10-20 12:48:11 -07001906 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301907
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001908 /* Unblock anyone waiting for disconnect to complete */
Jeff Johnsonba388342017-10-02 13:31:01 -07001909 complete(&adapter->disconnect_comp_var);
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301910
Alok Kumarb64650c2018-03-23 17:05:11 +05301911 hdd_nud_reset_tracking(adapter);
1912
1913 hdd_set_disconnect_status(adapter, false);
1914
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301915 hdd_reset_limit_off_chan(adapter);
1916
Jeff Johnsond377dce2017-10-04 10:32:42 -07001917 hdd_print_bss_info(sta_ctx);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05301918
Dustin Brown76cd2932018-09-11 16:03:05 -07001919 if (policy_mgr_is_sta_active_connection_exists(hdd_ctx->psoc))
Jeff Johnsonf7187f22018-06-13 22:02:19 -07001920 sme_enable_roaming_on_connected_sta(mac_handle);
Abhishek Singh1f217ec2017-12-22 11:48:27 +05301921
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 return status;
1923}
1924
1925/**
1926 * hdd_set_peer_authorized_event() - set peer_authorized_event
1927 * @vdev_id: vdevid
1928 *
1929 * Return: None
1930 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001931static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001932{
Jeff Johnson49432062017-08-28 12:08:45 -07001933 struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001934 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935
Ashish Kumar Dhanotiyaab2a9292018-06-16 15:11:27 +05301936 if (!hdd_ctx) {
1937 hdd_err("Invalid hdd context");
1938 return;
1939 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001940 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001941 if (!adapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001942 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001943 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 }
1945 complete(&adapter->sta_authorized_event);
1946}
1947
1948/**
1949 * hdd_change_peer_state() - change peer state
Jeff Johnsonba388342017-10-02 13:31:01 -07001950 * @adapter: HDD adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001951 * @sta_state: peer state
1952 * @roam_synch_in_progress: roam synch in progress
1953 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301954 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001956QDF_STATUS hdd_change_peer_state(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 uint8_t sta_id,
1958 enum ol_txrx_peer_state sta_state,
1959 bool roam_synch_in_progress)
1960{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301961 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001962 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001963 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1964 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1965 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001966
1967 if (!pdev) {
1968 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301969 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001970 }
1971
1972 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001973 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301974 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 }
1976
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001977 peer = cdp_peer_find_by_local_id(soc,
1978 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001979 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301980 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001981
Leo Changfdb45c32016-10-28 11:09:23 -07001982 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Jeff Johnsond36fa332019-03-18 13:42:25 -07001983 if (!peer_mac_addr) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001984 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001985 return QDF_STATUS_E_FAULT;
1986 }
1987
Leo Changfdb45c32016-10-28 11:09:23 -07001988 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301989 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001990 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301991 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992 }
1993#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1994 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301995 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996#endif
1997
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001998 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Abhinav Kumar2b431b62019-03-18 20:23:58 +05301999 /* Reset scan reject params on successful set key */
2000 hdd_debug("Reset scan reject params");
2001 hdd_init_scan_reject_params(adapter->hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
2003 /* make sure event is reset */
Jeff Johnsonba388342017-10-02 13:31:01 -07002004 INIT_COMPLETION(adapter->sta_authorized_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005#endif
2006
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07002007 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 hdd_set_peer_authorized_event,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002009 adapter->vdev_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302010 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002011 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302012 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 }
2014
Jeff Johnsonba388342017-10-02 13:31:01 -07002015 if (adapter->device_mode == QDF_STA_MODE ||
2016 adapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07002018 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 unsigned long rc;
2020
2021 /* wait for event from firmware to set the event */
2022 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07002023 &adapter->sta_authorized_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002025 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002026 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002027
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002028 vdev = (void *)cdp_peer_get_vdev(soc, peer);
2029 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07002030 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031#endif
2032 }
2033 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302034 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002035}
2036
Kabilan Kannan256e3182017-05-02 16:02:37 -07002037QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
Sourav Mohapatraa93de1c2019-08-01 14:48:10 +05302038 struct qdf_mac_addr *mac_addr,
Kabilan Kannan256e3182017-05-02 16:02:37 -07002039 uint32_t vdev_param,
2040 bool is_link_up)
2041{
2042 struct cdp_vdev *data_vdev;
2043 QDF_STATUS status = QDF_STATUS_SUCCESS;
2044 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Jeff Johnson49432062017-08-28 12:08:45 -07002045 struct hdd_context *hdd_ctx;
Yun Park0dad1002017-07-14 14:57:01 -07002046 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Kabilan Kannan256e3182017-05-02 16:02:37 -07002047 struct wlan_objmgr_psoc **psoc;
2048
2049 if (!cbk_data)
2050 return status;
2051
2052 psoc = cbk_data;
Kabilan Kannan256e3182017-05-02 16:02:37 -07002053
Kabilan Kannanc0e3d582017-09-13 00:26:33 -07002054 hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Sourav Mohapatra5febc932018-01-08 14:38:30 +05302055 if (!hdd_ctx) {
2056 hdd_err("Invalid HDD Context");
2057 return QDF_STATUS_E_INVAL;
2058 }
2059
Kabilan Kannan256e3182017-05-02 16:02:37 -07002060 if (!hdd_ctx->tdls_nap_active)
2061 return status;
2062
Sourav Mohapatraa93de1c2019-08-01 14:48:10 +05302063 data_vdev = cdp_peer_get_vdev_by_peer_addr(soc, pdev, *mac_addr);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002064 if (!data_vdev) {
Kabilan Kannan256e3182017-05-02 16:02:37 -07002065 status = QDF_STATUS_E_FAILURE;
2066 return status;
2067 }
2068
2069 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
2070
2071 return status;
2072}
2073
2074/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002075 * hdd_roam_register_sta() - register station
Jeff Johnsonba388342017-10-02 13:31:01 -07002076 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002077 * @roam_info: pointer to roam info
Jeff Johnson0a082d92019-03-04 12:25:49 -08002078 * @sta_id: station identifier
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05302079 * @bss_desc: pointer to BSS description
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002080 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302081 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002082 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002083QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002084 struct csr_roam_info *roam_info,
Jeff Johnson0a082d92019-03-04 12:25:49 -08002085 uint8_t sta_id,
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05302086 struct bss_description *bss_desc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302088 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Sourav Mohapatra3646a852019-07-29 09:08:40 +05302089 struct ol_txrx_desc_type txrx_desc = {0};
Jeff Johnsond377dce2017-10-04 10:32:42 -07002090 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08002091 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07002092 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
2093 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05302095 if (!bss_desc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302096 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097
2098 /* Get the Station ID from the one saved during the association */
Jeff Johnsonc419c172019-03-05 10:59:32 -08002099 txrx_desc.sta_id = sta_id;
Sourav Mohapatra3646a852019-07-29 09:08:40 +05302100 WLAN_ADDR_COPY(txrx_desc.peer_addr.bytes, roam_info->bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002101
2102 /* set the QoS field appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07002103 if (hdd_wmm_is_active(adapter))
Jeff Johnsonc419c172019-03-05 10:59:32 -08002104 txrx_desc.is_qos_enabled = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002105 else
Jeff Johnsonc419c172019-03-05 10:59:32 -08002106 txrx_desc.is_qos_enabled = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002107
2108#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07002109 hdd_debug("WAPI STA Registered: %d",
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002110 adapter->wapi_info.is_wapi_sta);
2111 if (adapter->wapi_info.is_wapi_sta)
Jeff Johnsonc419c172019-03-05 10:59:32 -08002112 txrx_desc.is_wapi_supported = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002113 else
Jeff Johnsonc419c172019-03-05 10:59:32 -08002114 txrx_desc.is_wapi_supported = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115#endif /* FEATURE_WLAN_WAPI */
2116
Dhanashri Atre50141c52016-04-07 13:15:29 -07002117 /* Register the vdev transmit and receive functions */
2118 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
Mohit Khanna70322002018-05-15 19:21:32 -07002119
2120 if (adapter->hdd_ctx->enable_dp_rx_threads) {
2121 txrx_ops.rx.rx = hdd_rx_pkt_thread_enqueue_cbk;
2122 txrx_ops.rx.rx_stack = hdd_rx_packet_cbk;
Mohit Khannaf0620ce2019-07-28 21:31:05 -07002123 txrx_ops.rx.rx_gro_flush = hdd_rx_thread_gro_flush_ind_cbk;
Mohit Khanna70322002018-05-15 19:21:32 -07002124 } else {
2125 txrx_ops.rx.rx = hdd_rx_packet_cbk;
2126 txrx_ops.rx.rx_stack = NULL;
2127 }
2128
Poddar, Siddarth31797fa2018-01-22 17:24:15 +05302129 txrx_ops.rx.stats_rx = hdd_tx_rx_collect_connectivity_stats_info;
Leo Changfdb45c32016-10-28 11:09:23 -07002130
hqu28f68df2019-07-02 23:10:08 +08002131 adapter->txrx_vdev = cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002132 (struct cdp_pdev *)pdev,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002133 adapter->vdev_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07002134 if (!adapter->txrx_vdev) {
Leo Changfdb45c32016-10-28 11:09:23 -07002135 return QDF_STATUS_E_FAILURE;
2136 }
2137
2138 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002139 cdp_vdev_register(soc,
hqu28f68df2019-07-02 23:10:08 +08002140 adapter->txrx_vdev, adapter,
Dustin Brown89fa06e2018-09-07 10:47:27 -07002141 (struct cdp_ctrl_objmgr_vdev *)adapter->vdev, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07002142 if (!txrx_ops.tx.tx) {
2143 hdd_err("%s vdev register fail", __func__);
2144 return QDF_STATUS_E_FAILURE;
2145 }
2146
Jeff Johnsonba388342017-10-02 13:31:01 -07002147 adapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08002148 qdf_status = cdp_peer_register(soc,
Jeff Johnsonc419c172019-03-05 10:59:32 -08002149 (struct cdp_pdev *)pdev, &txrx_desc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302150 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002151 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002152 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302153 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 }
2155
Jeff Johnsonfd060852017-10-04 10:50:51 -07002156 if (!roam_info->fAuthRequired) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157 /*
2158 * Connections that do not need Upper layer auth, transition
2159 * TLSHIM directly to 'Authenticated' state
2160 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302161 qdf_status =
Jeff Johnsonc419c172019-03-05 10:59:32 -08002162 hdd_change_peer_state(adapter, txrx_desc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002163 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002165 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166#else
2167 false
2168#endif
2169 );
2170
Jeff Johnsonba388342017-10-02 13:31:01 -07002171 hdd_conn_set_authenticated(adapter, true);
Dustin Brown89fa06e2018-09-07 10:47:27 -07002172 hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002174 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnson0a082d92019-03-04 12:25:49 -08002175 sta_ctx->conn_info.sta_id[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302176 qdf_status =
Jeff Johnsonc419c172019-03-05 10:59:32 -08002177 hdd_change_peer_state(adapter, txrx_desc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002178 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002180 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002181#else
2182 false
2183#endif
2184 );
Jeff Johnsonba388342017-10-02 13:31:01 -07002185 hdd_conn_set_authenticated(adapter, false);
Dustin Brown89fa06e2018-09-07 10:47:27 -07002186 hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002187 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302188 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002189}
2190
2191/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302192 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2193 * @dev: network device
2194 * @bss: cfg80211 roamed bss pointer
2195 * @req_ie: IEs used in reassociation request
2196 * @req_ie_len: Length of the @req_ie
2197 * @resp_ie: IEs received in successful reassociation response
2198 * @resp_ie_len: Length of @resp_ie
2199 *
2200 * Return: none
2201 */
2202#if defined CFG80211_ROAMED_API_UNIFIED || \
2203 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2204static void hdd_send_roamed_ind(struct net_device *dev,
2205 struct cfg80211_bss *bss, const uint8_t *req_ie,
2206 size_t req_ie_len, const uint8_t *resp_ie,
2207 size_t resp_ie_len)
2208{
2209 struct cfg80211_roam_info info = {0};
2210
2211 info.bss = bss;
2212 info.req_ie = req_ie;
2213 info.req_ie_len = req_ie_len;
2214 info.resp_ie = resp_ie;
2215 info.resp_ie_len = resp_ie_len;
2216 cfg80211_roamed(dev, &info, GFP_KERNEL);
2217}
2218#else
2219static inline void hdd_send_roamed_ind(struct net_device *dev,
2220 struct cfg80211_bss *bss,
2221 const uint8_t *req_ie, size_t req_ie_len,
2222 const uint8_t *resp_ie,
2223 size_t resp_ie_len)
2224{
2225 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2226 GFP_KERNEL);
2227}
2228#endif
2229
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302230#if defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302231#if defined(WLAN_FEATURE_FILS_SK)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302232void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002233 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302234{
2235 uint8_t *kek;
2236 uint32_t kek_len;
2237
2238 if (is_reassoc) {
2239 kek = csr_roam_info->kek;
2240 kek_len = csr_roam_info->kek_len;
2241 } else {
2242 /*
2243 * This should come for FILS case only.
2244 * Caller should make sure fils_join_rsp is
2245 * not NULL, if there is need to use else where.
2246 */
2247 kek = csr_roam_info->fils_join_rsp->kek;
2248 kek_len = csr_roam_info->fils_join_rsp->kek_len;
2249 }
2250
Pragaspathi Thilagarajeb367282019-02-19 00:42:28 +05302251 wlan_hdd_save_gtk_offload_params(adapter, NULL, 0, kek, kek_len,
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302252 csr_roam_info->replay_ctr, true);
2253
2254 hdd_debug("Kek len %d", kek_len);
2255}
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302256#else
2257void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002258 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302259{
2260 uint8_t *kek;
2261 uint32_t kek_len;
2262
2263 /*
2264 * is_reassoc is set to true always for Legacy GTK offload
2265 * case, It is false only for FILS case
2266 */
2267 kek = csr_roam_info->kek;
2268 kek_len = csr_roam_info->kek_len;
2269
Pragaspathi Thilagarajeb367282019-02-19 00:42:28 +05302270 wlan_hdd_save_gtk_offload_params(adapter, NULL, 0, kek, kek_len,
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302271 csr_roam_info->replay_ctr, true);
2272
2273 hdd_debug("Kek len %d", kek_len);
2274}
2275#endif
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302276#endif
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302277/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278 * hdd_send_re_assoc_event() - send reassoc event
2279 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07002280 * @adapter: pointer to adapter
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002281 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002282 * @reqRsnIe: pointer to RSN Information element
2283 * @reqRsnLength: length of RSN IE
2284 *
2285 * Return: none
2286 */
2287static void hdd_send_re_assoc_event(struct net_device *dev,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002288 struct hdd_adapter *adapter, struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002289 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2290{
2291 unsigned int len = 0;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002292 u8 *assoc_rsp = NULL;
Jeff Johnson48b56b12019-03-09 19:51:48 -08002293 uint8_t *rsp_rsn_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002294 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002295 uint32_t rsp_rsn_lemgth = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002296 struct ieee80211_channel *chan;
Srinivas Girigowdab8fdc642019-03-19 15:33:03 -07002297 uint8_t buf_ssid_ie[2 + WLAN_SSID_MAX_LEN]; /* 2 bytes-EID and len */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 uint8_t *buf_ptr, ssid_ie_len;
2299 struct cfg80211_bss *bss = NULL;
2300 uint8_t *final_req_ie = NULL;
2301 tCsrRoamConnectedProfile roam_profile;
Jeff Johnsonba388342017-10-02 13:31:01 -07002302 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002304 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2305
Jeff Johnson48b56b12019-03-09 19:51:48 -08002306 if (!rsp_rsn_ie) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002307 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002308 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002309 }
2310
Naveen Rawat14298b92015-11-25 16:27:41 -08002311 if (!assoc_req_ies) {
2312 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002313 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002314 }
Rajeev Kumar Sirasanagandlae5582aa2018-05-02 18:20:20 +05302315
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05302316 if (!roam_info || !roam_info->bss_desc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002317 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 goto done;
2319 }
2320
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002321 if (roam_info->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002322 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002323 goto done;
2324 }
2325
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002326 assoc_rsp =
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002327 (u8 *) (roam_info->pbFrames + roam_info->nBeaconLength +
2328 roam_info->nAssocReqLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002329 if (!assoc_rsp)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002330 goto done;
2331
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002332 /* assoc_rsp needs to point to the IEs */
2333 assoc_rsp += FT_ASSOC_RSP_IES_OFFSET;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002334
2335 /*
2336 * Active session count is decremented upon disconnection, but during
2337 * roaming, there is no disconnect indication and hence active session
2338 * count is not decremented.
2339 * After roaming is completed, active session count is incremented
2340 * as a part of connect indication but effectively after roaming the
2341 * active session count should still be the same and hence upon
2342 * successful reassoc decrement the active session count here.
2343 */
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002344 if (!hdd_is_roam_sync_in_progress(roam_info)) {
Dustin Brown76cd2932018-09-11 16:03:05 -07002345 policy_mgr_decr_session_set_pcl(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002346 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07002347 hdd_green_ap_start_state_mc(hdd_ctx, adapter->device_mode,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05302348 false);
2349 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350
2351 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002352 len = roam_info->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002353 rsp_rsn_lemgth = len;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002354 qdf_mem_copy(rsp_rsn_ie, assoc_rsp, len);
Jeff Johnson48b56b12019-03-09 19:51:48 -08002355 qdf_mem_zero(rsp_rsn_ie + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002356
Will Huang65d64252019-07-16 17:57:42 +08002357 chan = ieee80211_get_channel(adapter->wdev.wiphy,
2358 roam_info->bss_desc->chan_freq);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302359
Jeff Johnson1abc5662019-02-04 14:27:02 -08002360 sme_roam_get_connect_profile(hdd_ctx->mac_handle, adapter->vdev_id,
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002361 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302362
Abhishek Singh59cdca12019-03-08 13:48:20 +05302363 bss = wlan_cfg80211_get_bss(adapter->wdev.wiphy,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002364 chan, roam_info->bssid.bytes,
Abhishek Singh59cdca12019-03-08 13:48:20 +05302365 &roam_profile.SSID.ssId[0],
2366 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002367
Jeff Johnsond36fa332019-03-18 13:42:25 -07002368 if (!bss)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002369 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002370 buf_ptr = buf_ssid_ie;
Srinivas Girigowda61771262019-04-01 11:55:19 -07002371 *buf_ptr = WLAN_ELEMID_SSID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 buf_ptr++;
2373 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2374 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302375 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 roam_profile.SSID.length);
2377 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002378 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302379 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002380 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002381 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002382 if (!final_req_ie) {
Kapil Gupta8731e812017-07-11 18:42:39 +05302383 if (bss)
Jeff Johnsonba388342017-10-02 13:31:01 -07002384 cfg80211_put_bss(adapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002385 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302386 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002387 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302388 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302390 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002391 qdf_mem_copy(rsp_rsn_ie, assoc_rsp, len);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302392 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002393 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002394 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302395 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002396 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302397 hdd_send_roamed_ind(dev, bss, final_req_ie,
Jeff Johnson48b56b12019-03-09 19:51:48 -08002398 (ssid_ie_len + reqRsnLength), rsp_rsn_ie,
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002399 rsp_rsn_lemgth);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302401 qdf_mem_copy(assoc_req_ies,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002402 (u8 *)roam_info->pbFrames + roam_info->nBeaconLength,
2403 roam_info->nAssocReqLength);
Naveen Rawat14298b92015-11-25 16:27:41 -08002404
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002405 hdd_save_gtk_params(adapter, roam_info, true);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302406
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002407 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302408 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002409 assoc_req_ies, roam_info->nAssocReqLength);
Naveen Rawat14298b92015-11-25 16:27:41 -08002410
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002411 wlan_hdd_send_roam_auth_event(adapter, roam_info->bssid.bytes,
2412 assoc_req_ies, roam_info->nAssocReqLength,
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002413 rsp_rsn_ie, rsp_rsn_lemgth,
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002414 roam_info);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302415
Jeff Johnson5fc4aaa2019-03-10 15:03:18 -07002416 hdd_update_hlp_info(dev, roam_info);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302417
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002419 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002421 qdf_mem_free(final_req_ie);
Jeff Johnson48b56b12019-03-09 19:51:48 -08002422 qdf_mem_free(rsp_rsn_ie);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002423 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424}
2425
2426/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302427 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002428 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302429 *
2430 * Return: roam sync status if roaming offloaded else false
2431 */
2432#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson172237b2017-11-07 15:32:59 -08002433bool hdd_is_roam_sync_in_progress(struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302434{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002435 if (roaminfo)
2436 return roaminfo->roamSynchInProgress;
2437 else
2438 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302439}
2440#endif
2441
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002442/**
Jeff Johnson0a082d92019-03-04 12:25:49 -08002443 * hdd_get_ibss_peer_sta_id() - get sta id for IBSS peer
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002444 * @hddstactx: pointer to HDD sta context
2445 * @roaminfo: pointer to roaminfo structure
2446 *
Jeff Johnson0a082d92019-03-04 12:25:49 -08002447 * This function returns sta_id for IBSS peer. If peer is broadcast
2448 * MAC address return self sta_id(0) else find the peer sta id of
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002449 * the peer.
2450 *
2451 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2452 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08002453static uint8_t hdd_get_ibss_peer_sta_id(struct hdd_station_ctx *hddstactx,
2454 struct csr_roam_info *roaminfo)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002455{
Jeff Johnson0a082d92019-03-04 12:25:49 -08002456 uint8_t sta_id = HDD_WLAN_INVALID_STA_ID;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002457 QDF_STATUS status;
2458
2459 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08002460 sta_id = 0;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002461 } else {
2462 status = hdd_get_peer_sta_id(hddstactx,
Jeff Johnson0a082d92019-03-04 12:25:49 -08002463 &roaminfo->peerMac, &sta_id);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002464 if (status != QDF_STATUS_SUCCESS) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08002465 hdd_err("Unable to find station ID for "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002466 QDF_MAC_ADDR_STR,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002467 QDF_MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002468 }
2469 }
2470
Jeff Johnson0a082d92019-03-04 12:25:49 -08002471 return sta_id;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002472}
Govind Singhedc5cda2015-10-23 17:11:35 +05302473
2474/**
2475 * hdd_change_sta_state_authenticated()-
2476 * This function changes STA state to authenticated
2477 * @adapter: pointer to the adapter structure.
2478 * @roaminfo: pointer to the RoamInfo structure.
2479 *
2480 * This is called from hdd_RoamSetKeyCompleteHandler
2481 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2482 *
2483 * Return: 0 on success and errno on failure
2484 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002485static int hdd_change_sta_state_authenticated(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002486 struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302487{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002488 QDF_STATUS status;
Pragaspathi Thilagaraj784c4922018-12-02 22:47:29 +05302489 uint32_t timeout, auto_bmps_timer_val;
Jeff Johnson0a082d92019-03-04 12:25:49 -08002490 uint8_t sta_id = HDD_WLAN_INVALID_STA_ID;
Jeff Johnson435e1b82017-10-07 14:13:10 -07002491 struct hdd_station_ctx *hddstactx =
2492 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson49432062017-08-28 12:08:45 -07002493 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302494
Pragaspathi Thilagaraj784c4922018-12-02 22:47:29 +05302495 ucfg_mlme_get_auto_bmps_timer_value(hdd_ctx->psoc,
2496 &auto_bmps_timer_val);
Jeff Johnson690fe952017-10-25 11:48:39 -07002497 timeout = hddstactx->hdd_reassoc_scenario ?
Dustin Brownf660fb42016-09-09 12:04:00 -07002498 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Pragaspathi Thilagaraj784c4922018-12-02 22:47:29 +05302499 (auto_bmps_timer_val * 1000);
Dustin Brownf660fb42016-09-09 12:04:00 -07002500
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002501 if (QDF_IBSS_MODE == adapter->device_mode)
Jeff Johnson0a082d92019-03-04 12:25:49 -08002502 sta_id = hdd_get_ibss_peer_sta_id(hddstactx, roaminfo);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002503 else
Jeff Johnson0a082d92019-03-04 12:25:49 -08002504 sta_id = hddstactx->conn_info.sta_id[0];
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002505
Jeff Johnson0a082d92019-03-04 12:25:49 -08002506 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d",
2507 sta_id);
Govind Singhedc5cda2015-10-23 17:11:35 +05302508
2509 /* Connections that do not need Upper layer authentication,
2510 * transition TL to 'Authenticated' state after the keys are set
2511 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08002512 status = hdd_change_peer_state(adapter, sta_id, OL_TXRX_PEER_STATE_AUTH,
2513 hdd_is_roam_sync_in_progress(roaminfo));
Govind Singhedc5cda2015-10-23 17:11:35 +05302514 hdd_conn_set_authenticated(adapter, true);
Dustin Brown89fa06e2018-09-07 10:47:27 -07002515 hdd_objmgr_set_peer_mlme_auth_state(adapter->vdev, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002516
Krunal Sonibe766b02016-03-10 13:00:44 -08002517 if ((QDF_STA_MODE == adapter->device_mode) ||
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002518 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
2519 sme_ps_enable_auto_ps_timer(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002520 adapter->vdev_id,
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002521 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302522 }
2523
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002524 return qdf_status_to_os_return(status);
2525}
2526
2527/**
2528 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2529 * if key installation is required
2530 * @encr_type: encryption type
2531 *
2532 * Return: true if key installation is required and false otherwise.
2533 */
2534static inline bool hdd_is_key_install_required_for_ibss(
2535 eCsrEncryptionType encr_type)
2536{
2537 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2538 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2539 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302540 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2541 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002542 eCSR_ENCRYPT_TYPE_AES == encr_type)
2543 return true;
2544 else
2545 return false;
2546}
2547
2548/**
2549 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2550 * complete
2551 * @adapter: pointer to HDD adapter
2552 * @roaminfo: pointer to roam info
2553 * @roam_result: roam result
2554 *
2555 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2556 * This function checks for the successful set key completion and update
2557 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2558 *
2559 * Return: None
2560 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002561static void hdd_change_peer_state_after_set_key(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002562 struct csr_roam_info *roaminfo,
2563 eCsrRoamResult roam_result)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002564{
Jeff Johnson435e1b82017-10-07 14:13:10 -07002565 struct hdd_station_ctx *hdd_sta_ctx =
2566 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonb1959842019-02-27 13:04:04 -08002567 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.uc_encrypt_type;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002568
2569 /*
2570 * If the security mode is one of the following, IBSS peer will be
2571 * waiting in CONN state and we will move the peer state to AUTH
2572 * here. For non-secure connection, no need to wait for set-key complete
2573 * peer will be moved to AUTH in hdd_roam_register_sta.
2574 */
2575 if (QDF_IBSS_MODE == adapter->device_mode) {
2576 if (hdd_is_key_install_required_for_ibss(encr_type))
2577 hdd_change_sta_state_authenticated(adapter, roaminfo);
2578
2579 return;
2580 }
2581
2582 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2583 hdd_sta_ctx->conn_info.gtk_installed = true;
2584 /*
2585 * PTK exchange happens in preauthentication itself if key_mgmt
2586 * is FT-PSK, ptk_installed was false as there is no set PTK
2587 * after roaming. STA TL state moves to authenticated only if
2588 * ptk_installed is true. So, make ptk_installed to true in
2589 * case of 11R roaming.
2590 */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002591 if (sme_neighbor_roam_is11r_assoc(adapter->hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002592 adapter->vdev_id))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002593 hdd_sta_ctx->conn_info.ptk_installed = true;
2594 } else {
2595 hdd_sta_ctx->conn_info.ptk_installed = true;
2596 }
2597
2598 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2599 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2600 * unicast key and it was resulting in sending few un-encrypted packet.
2601 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2602 * set the unicast and broadcast key.
2603 */
2604 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2605 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2606 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2607 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2608 if (hdd_sta_ctx->conn_info.gtk_installed &&
2609 hdd_sta_ctx->conn_info.ptk_installed)
2610 hdd_change_sta_state_authenticated(adapter, roaminfo);
2611 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2612 hdd_change_sta_state_authenticated(adapter, roaminfo);
2613 }
2614
2615 if (hdd_sta_ctx->conn_info.gtk_installed &&
2616 hdd_sta_ctx->conn_info.ptk_installed) {
2617 hdd_sta_ctx->conn_info.gtk_installed = false;
2618 hdd_sta_ctx->conn_info.ptk_installed = false;
2619 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302620}
2621
2622/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 * hdd_roam_set_key_complete_handler() - Update the security parameters
Jeff Johnsonba388342017-10-02 13:31:01 -07002624 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002625 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08002626 * @roam_id: roam id
2627 * @roam_status: roam status
2628 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302630 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 */
Jeff Johnson172237b2017-11-07 15:32:59 -08002632static QDF_STATUS
2633hdd_roam_set_key_complete_handler(struct hdd_adapter *adapter,
2634 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08002635 uint32_t roam_id,
2636 eRoamCmdStatus roam_status,
2637 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002638{
Jeff Johnsone16f0822019-03-10 18:27:30 -07002639 eCsrEncryptionType algorithm;
Jeff Johnson389e16b2018-05-05 23:32:55 -07002640 bool connected = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002641 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302642
Dustin Brown491d54b2018-03-14 12:39:11 -07002643 hdd_enter();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002644
Jeff Johnsond36fa332019-03-18 13:42:25 -07002645 if (!roam_info) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002646 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302647 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 }
2649 /*
2650 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2651 * then go to 'authenticated'. For all other authentication types
2652 * (those that do not require upper layer authentication) we can put TL
2653 * directly into 'authenticated' state.
2654 */
Jeff Johnson29c78672019-02-26 21:05:53 -08002655 hdd_debug("Set Key completion roam_status =%d roam_result=%d "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07002656 QDF_MAC_ADDR_STR, roam_status, roam_result,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07002657 QDF_MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002658
Jeff Johnson389e16b2018-05-05 23:32:55 -07002659 connected = hdd_conn_get_connected_cipher_algo(sta_ctx,
Jeff Johnsone16f0822019-03-10 18:27:30 -07002660 &algorithm);
Jeff Johnson389e16b2018-05-05 23:32:55 -07002661 if (connected) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002662 hdd_change_peer_state_after_set_key(adapter, roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08002663 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 }
2665
Jianmin Zhu4bcf8372018-12-27 19:38:55 +08002666 if (!adapter->hdd_ctx || !adapter->hdd_ctx->psoc) {
2667 hdd_err("hdd_ctx or psoc is NULL");
2668 return QDF_STATUS_E_FAILURE;
2669 }
2670 policy_mgr_restart_opportunistic_timer(adapter->hdd_ctx->psoc, false);
2671
Dustin Browne74003f2018-03-14 12:51:58 -07002672 hdd_exit();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302673 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674}
2675
2676/**
2677 * hdd_perform_roam_set_key_complete() - perform set key complete
Jeff Johnsonba388342017-10-02 13:31:01 -07002678 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 *
2680 * Return: none
2681 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002682void hdd_perform_roam_set_key_complete(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002683{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302684 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002685 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Min Liu3621ede2018-11-07 18:36:00 +08002686 struct csr_roam_info *roam_info;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002687
Min Liu3621ede2018-11-07 18:36:00 +08002688 roam_info = qdf_mem_malloc(sizeof(*roam_info));
2689 if (!roam_info)
2690 return;
2691 roam_info->fAuthRequired = false;
2692 qdf_mem_copy(roam_info->bssid.bytes,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002693 sta_ctx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Min Liu3621ede2018-11-07 18:36:00 +08002694 qdf_mem_copy(roam_info->peerMac.bytes,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002695 sta_ctx->roam_info.peer_mac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302697 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002698 hdd_roam_set_key_complete_handler(adapter,
Min Liu3621ede2018-11-07 18:36:00 +08002699 roam_info,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002700 sta_ctx->roam_info.roam_id,
2701 sta_ctx->roam_info.roam_status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302703 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002704 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002706 sta_ctx->roam_info.defer_key_complete = false;
Min Liu3621ede2018-11-07 18:36:00 +08002707 qdf_mem_free(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708}
2709
Vignesh Viswanathan3fa1d382017-08-02 19:36:43 +05302710#if defined(WLAN_FEATURE_FILS_SK) && \
2711 (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \
2712 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)))
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002713void hdd_clear_fils_connection_info(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302714{
Jeff Johnson844eec72018-03-13 11:48:18 -07002715 struct csr_roam_profile *roam_profile;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302716
2717 if ((adapter->device_mode == QDF_SAP_MODE) ||
2718 (adapter->device_mode == QDF_P2P_GO_MODE))
2719 return;
2720
Jeff Johnson844eec72018-03-13 11:48:18 -07002721 roam_profile = hdd_roam_profile(adapter);
2722 if (roam_profile->fils_con_info) {
2723 qdf_mem_free(roam_profile->fils_con_info);
2724 roam_profile->fils_con_info = NULL;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302725 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302726
Jeff Johnson844eec72018-03-13 11:48:18 -07002727 if (roam_profile->hlp_ie) {
2728 qdf_mem_free(roam_profile->hlp_ie);
2729 roam_profile->hlp_ie = NULL;
2730 roam_profile->hlp_ie_len = 0;
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302731 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302732}
2733#endif
2734
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002735/**
2736 * hdd_association_completion_handler() - association completion handler
Jeff Johnsonba388342017-10-02 13:31:01 -07002737 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002738 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08002739 * @roam_id: roam id
2740 * @roam_status: roam status
2741 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302743 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744 */
Jeff Johnson435e1b82017-10-07 14:13:10 -07002745static QDF_STATUS
2746hdd_association_completion_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002747 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08002748 uint32_t roam_id,
2749 eRoamCmdStatus roam_status,
2750 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751{
Jeff Johnsonba388342017-10-02 13:31:01 -07002752 struct net_device *dev = adapter->dev;
2753 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002754 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302755 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002757 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 bool hddDisconInProgress = false;
2760 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302761 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302762 bool ok;
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002763 mac_handle_t mac_handle;
Jingxiang Gece7c5472019-07-23 16:19:23 +08002764 uint8_t conn_info_channel;
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05302765 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766
Jeff Johnson8095a312017-09-03 09:13:24 -07002767 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302769 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002770 }
2771
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302772 /* validate config */
Jeff Johnson8095a312017-09-03 09:13:24 -07002773 if (!hdd_ctx->config) {
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302774 hdd_err("config is NULL");
2775 return QDF_STATUS_E_NULL_VALUE;
2776 }
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05302777
2778 /*
Paul Zhangcb573e02018-11-06 10:37:16 +08002779 * reset scan reject params if connection is success or we received
2780 * final failure from CSR after trying with all APs.
2781 */
Jeff Johnson29c78672019-02-26 21:05:53 -08002782 hdd_reset_scan_reject_params(hdd_ctx, roam_status, roam_result);
Paul Zhangcb573e02018-11-06 10:37:16 +08002783
2784 /*
Padma, Santhosh Kumar86747ec2018-05-29 18:28:29 +05302785 * Enable roaming on other STA iface except this one.
2786 * Firmware dosent support connection on one STA iface while
2787 * roaming on other STA iface
2788 */
2789 wlan_hdd_enable_roaming(adapter);
2790
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002791 /* HDD has initiated disconnect, do not send connect result indication
2792 * to kernel as it will be handled by __cfg80211_disconnect.
2793 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302794 if (((eConnectionState_Disconnecting ==
Jeff Johnsone7951512019-02-27 10:02:51 -08002795 sta_ctx->conn_info.conn_state) ||
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302796 (eConnectionState_NotConnected ==
Jeff Johnsone7951512019-02-27 10:02:51 -08002797 sta_ctx->conn_info.conn_state)) &&
Jeff Johnson29c78672019-02-26 21:05:53 -08002798 ((eCSR_ROAM_RESULT_ASSOCIATED == roam_result) ||
2799 (eCSR_ROAM_ASSOCIATION_FAILURE == roam_status))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002800 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
Jeff Johnsone7951512019-02-27 10:02:51 -08002801 sta_ctx->conn_info.conn_state,
Jeff Johnson29c78672019-02-26 21:05:53 -08002802 roam_result, roam_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 hddDisconInProgress = true;
2804 }
2805
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002806 mac_handle = hdd_ctx->mac_handle;
2807
Jeff Johnson29c78672019-02-26 21:05:53 -08002808 if (eCSR_ROAM_RESULT_ASSOCIATED == roam_result) {
Jeff Johnsond36fa332019-03-18 13:42:25 -07002809 if (!roam_info) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002810 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302811 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 }
2813 if (!hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07002814 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002815 eConnectionState_Associated);
2816 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302817
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002818 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002819 hdd_conn_save_connect_info(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002821
Jeff Johnsonba388342017-10-02 13:31:01 -07002822 if (hdd_add_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002823 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002824#ifdef FEATURE_WLAN_WAPI
Jeff Johnsonfd060852017-10-04 10:50:51 -07002825 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
Jeff Johnsonfd060852017-10-04 10:50:51 -07002827 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002829 adapter->wapi_info.is_wapi_sta = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 } else {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002831 adapter->wapi_info.is_wapi_sta = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002832 }
2833#endif /* FEATURE_WLAN_WAPI */
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05302834 hdd_debug("bss_descr[%d] devicemode[%d]", !!roam_info->bss_desc,
2835 adapter->device_mode);
Jeff Johnsonba388342017-10-02 13:31:01 -07002836 if ((QDF_STA_MODE == adapter->device_mode) &&
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05302837 roam_info->bss_desc) {
2838 ie_len = GET_IE_LEN_IN_BSS(roam_info->bss_desc->length);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002839 sta_ctx->ap_supports_immediate_power_save =
Krunal Soni364e0872017-05-10 21:24:34 -07002840 wlan_hdd_is_ap_supports_immediate_power_save(
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05302841 (uint8_t *)roam_info->bss_desc->ieFields,
Krunal Soni364e0872017-05-10 21:24:34 -07002842 ie_len);
2843 hdd_debug("ap_supports_immediate_power_save flag [%d]",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002844 sta_ctx->ap_supports_immediate_power_save);
Krunal Soni364e0872017-05-10 21:24:34 -07002845 }
2846
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002847 /* Indicate 'connect' status to user space */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002848 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849
Dustin Brown76cd2932018-09-11 16:03:05 -07002850 if (policy_mgr_is_mcc_in_24G(hdd_ctx->psoc)) {
Jeff Johnson8095a312017-09-03 09:13:24 -07002851 if (hdd_ctx->miracast_value)
Jeff Johnsonba388342017-10-02 13:31:01 -07002852 wlan_hdd_set_mas(adapter,
Jeff Johnson8095a312017-09-03 09:13:24 -07002853 hdd_ctx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002854 }
2855
2856 /* Initialize the Linkup event completion variable */
Jeff Johnsonba388342017-10-02 13:31:01 -07002857 INIT_COMPLETION(adapter->linkup_event_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002858
2859 /*
2860 * Sometimes Switching ON the Carrier is taking time to activate
2861 * the device properly. Before allowing any packet to go up to
2862 * the application, device activation has to be ensured for
2863 * proper queue mapping by the kernel. we have registered net
2864 * device notifier for device change notification. With this we
2865 * will come to know that the device is getting
2866 * activated properly.
2867 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07002868 if (sta_ctx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002869 /*
2870 * Enable Linkup Event Servicing which allows the net
2871 * device notifier to set the linkup event variable.
2872 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002873 adapter->is_link_up_service_needed = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002875 /* Switch on the Carrier to activate the device */
Jeff Johnsonba388342017-10-02 13:31:01 -07002876 wlan_hdd_netif_queue_control(adapter,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002877 WLAN_NETIF_CARRIER_ON,
2878 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002880 /*
2881 * Wait for the Link to up to ensure all the queues
2882 * are set properly by the kernel.
2883 */
2884 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07002885 &adapter->linkup_event_var,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002886 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2887 );
2888 if (!rc)
2889 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002891 /*
2892 * Disable Linkup Event Servicing - no more service
2893 * required from the net device notifier call.
2894 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002895 adapter->is_link_up_service_needed = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002896 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07002897 sta_ctx->ft_carrier_on = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002898 ft_carrier_on = true;
2899 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07002900 if (roam_info->staId < HDD_MAX_ADAPTERS)
Jeff Johnsonfd060852017-10-04 10:50:51 -07002901 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002902 else
Jeff Johnsonfd060852017-10-04 10:50:51 -07002903 hdd_err("Wrong Staid: %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05302905 if (ucfg_ipa_is_enabled())
Dustin Brown07901ec2018-09-07 11:02:41 -07002906 ucfg_ipa_wlan_evt(hdd_ctx->pdev, adapter->dev,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05302907 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002908 adapter->vdev_id,
Sravan Kumar Kairam5214f652018-03-13 09:52:31 +05302909 WLAN_IPA_STA_CONNECT,
2910 roam_info->bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911
2912#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07002913 wlan_hdd_auto_shutdown_enable(hdd_ctx, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914#endif
2915
Jingxiang Gece7c5472019-07-23 16:19:23 +08002916 conn_info_channel =
2917 wlan_reg_freq_to_chan(hdd_ctx->pdev,
Jingxiang Geae80dc62019-08-13 17:32:22 +08002918 sta_ctx->conn_info.chan_freq);
Jingxiang Gece7c5472019-07-23 16:19:23 +08002919
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302920 hdd_debug("check if STA chan ok for DNBS");
Dustin Brown76cd2932018-09-11 16:03:05 -07002921 if (policy_mgr_is_chan_ok_for_dnbs(hdd_ctx->psoc,
Jingxiang Gece7c5472019-07-23 16:19:23 +08002922 conn_info_channel,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302923 &ok)) {
Jingxiang Gece7c5472019-07-23 16:19:23 +08002924 hdd_err("Unable to check DNBS eligibility for chan(freq):%u",
Jingxiang Geae80dc62019-08-13 17:32:22 +08002925 sta_ctx->conn_info.chan_freq);
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302926 return QDF_STATUS_E_FAILURE;
2927 }
2928
2929 if (!ok) {
Jingxiang Gece7c5472019-07-23 16:19:23 +08002930 hdd_err("Chan(freq):%u not suitable for DNBS",
Jingxiang Geae80dc62019-08-13 17:32:22 +08002931 sta_ctx->conn_info.chan_freq);
Jeff Johnsonba388342017-10-02 13:31:01 -07002932 wlan_hdd_netif_queue_control(adapter,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302933 WLAN_NETIF_CARRIER_OFF,
2934 WLAN_CONTROL_PATH);
2935 if (!hddDisconInProgress) {
2936 hdd_err("Disconnecting...");
2937 sme_roam_disconnect(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002938 mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002939 adapter->vdev_id,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302940 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2941 }
2942 return QDF_STATUS_E_FAILURE;
2943 }
2944
Nirav Shah1da77682016-05-03 20:16:39 +05302945 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002946 adapter->vdev_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002947 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302948 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950 /*
2951 * For reassoc, the station is already registered, all we need
2952 * is to change the state of the STA in TL.
2953 * If authentication is required (WPA/WPA2/DWEP), change TL to
2954 * CONNECTED instead of AUTHENTICATED.
2955 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002956 if (!roam_info->fReassocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002957 struct cfg80211_bss *bss;
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002958 u8 *assoc_rsp = NULL;
2959 unsigned int assoc_rsp_len = 0;
Jeff Johnson8152d892019-03-10 18:37:50 -07002960 u8 *assoc_req = NULL;
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07002961 unsigned int assoc_req_len = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962 struct ieee80211_channel *chan;
Jeff Johnson48b56b12019-03-09 19:51:48 -08002963 uint8_t rsp_rsn_ie[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08002964 uint32_t rsp_rsn_lemgth = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965
2966 /* add bss_id to cfg80211 data base */
2967 bss =
Jeff Johnsonba388342017-10-02 13:31:01 -07002968 wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002969 roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07002970 if (!bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302971 hdd_err("wlan: Not able to create BSS entry");
Jeff Johnsonba388342017-10-02 13:31:01 -07002972 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002973 WLAN_NETIF_CARRIER_OFF,
2974 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302975 if (!hddDisconInProgress) {
2976 /*
2977 * Here driver was not able to add bss
2978 * in cfg80211 database this can happen
2979 * if connected channel is not valid,
2980 * i.e reg domain was changed during
2981 * connection. Queue disconnect for the
2982 * session if disconnect is not in
2983 * progress.
2984 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002985 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302986 sme_roam_disconnect(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07002987 mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08002988 adapter->vdev_id,
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302989 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2990 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302991 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 }
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302993
Jeff Johnsonc66d3102018-02-28 11:58:26 -08002994 cfg80211_put_bss(hdd_ctx->wiphy, bss);
2995
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302996 /* Association Response */
Jeff Johnsone2b360b2019-03-10 18:39:39 -07002997 assoc_rsp =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302998 (u8 *) (roam_info->pbFrames +
2999 roam_info->nBeaconLength +
3000 roam_info->nAssocReqLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003001 if (assoc_rsp) {
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303002 /*
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003003 * assoc_rsp needs to point to the IEs
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303004 */
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003005 assoc_rsp += FT_ASSOC_RSP_IES_OFFSET;
3006 assoc_rsp_len =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303007 roam_info->nAssocRspLength -
3008 FT_ASSOC_RSP_IES_OFFSET;
3009
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003010 hdd_debug("assoc_rsp_len %d", assoc_rsp_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303011 hdd_debug("Assoc Rsp IE dump");
3012 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
3013 QDF_TRACE_LEVEL_DEBUG,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003014 assoc_rsp,
3015 assoc_rsp_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303016 } else {
3017 hdd_debug("AssocRsp is NULL");
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003018 assoc_rsp_len = 0;
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303019 }
3020
3021 /* Association Request */
Jeff Johnson8152d892019-03-10 18:37:50 -07003022 assoc_req = (u8 *) (roam_info->pbFrames +
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303023 roam_info->nBeaconLength);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003024 if (assoc_req) {
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303025 if (!ft_carrier_on) {
3026 /*
Jeff Johnson8152d892019-03-10 18:37:50 -07003027 * assoc_req needs to point to
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303028 * the IEs
3029 */
Jeff Johnson8152d892019-03-10 18:37:50 -07003030 assoc_req +=
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303031 FT_ASSOC_REQ_IES_OFFSET;
Jeff Johnson8152d892019-03-10 18:37:50 -07003032 hdd_debug("assoc_req is now at %02x%02x",
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303033 (unsigned int)
Jeff Johnson8152d892019-03-10 18:37:50 -07003034 assoc_req[0],
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303035 (unsigned int)
Jeff Johnson8152d892019-03-10 18:37:50 -07003036 assoc_req[1]);
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003037 assoc_req_len =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303038 roam_info->nAssocReqLength -
3039 FT_ASSOC_REQ_IES_OFFSET;
3040 } else {
3041 /*
3042 * This should contain only the
3043 * FTIEs
3044 */
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003045 assoc_req_len =
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303046 roam_info->nAssocReqLength;
3047 }
3048
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003049 hdd_debug("assoc_req_len %d", assoc_req_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303050 hdd_debug("Assoc/Reassoc Req IE dump");
3051 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
3052 QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson8152d892019-03-10 18:37:50 -07003053 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003054 assoc_req_len);
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303055 } else {
3056 hdd_debug("AssocReq is NULL");
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003057 assoc_req_len = 0;
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303058 }
3059
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05303060 if ((roam_info->u.pConnectedProfile->AuthType ==
3061 eCSR_AUTH_TYPE_FT_RSN) ||
3062 (roam_info->u.pConnectedProfile->AuthType ==
3063 eCSR_AUTH_TYPE_FT_RSN_PSK) ||
3064 (roam_info->u.pConnectedProfile->AuthType ==
3065 eCSR_AUTH_TYPE_FT_SAE) ||
3066 (roam_info->u.pConnectedProfile->AuthType ==
3067 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003068 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08003069 if (!hddDisconInProgress &&
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05303070 roam_info->bss_desc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05303071 struct cfg80211_bss *roam_bss;
3072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 /*
3074 * After roaming is completed,
3075 * active session count is
3076 * incremented as a part of
3077 * connect indication but
3078 * effectively the active
3079 * session count should still
3080 * be the same and hence upon
3081 * successful reassoc
3082 * decrement the active session
3083 * count here.
3084 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08003085 if (!hdd_is_roam_sync_in_progress
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303086 (roam_info)) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003087 policy_mgr_decr_session_set_pcl(
Dustin Brown76cd2932018-09-11 16:03:05 -07003088 hdd_ctx->psoc,
Jeff Johnsonba388342017-10-02 13:31:01 -07003089 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003090 adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07003091 hdd_green_ap_start_state_mc(
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303092 hdd_ctx,
3093 adapter->device_mode,
3094 false);
3095 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003096 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003097 ft_carrier_on);
Will Huang65d64252019-07-16 17:57:42 +08003098 chan = ieee80211_get_channel(
3099 adapter->wdev.wiphy,
3100 roam_info->bss_desc->chan_freq);
Naveen Rawat14298b92015-11-25 16:27:41 -08003101
Abhishek Singh533c9da2017-05-04 10:23:34 +05303102 roam_bss =
Abhishek Singh59cdca12019-03-08 13:48:20 +05303103 wlan_cfg80211_get_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003104 adapter->wdev.wiphy,
Abhishek Singh533c9da2017-05-04 10:23:34 +05303105 chan,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003106 roam_info->bssid.bytes,
3107 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05303108 pConnectedProfile->SSID.ssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003109 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05303110 pConnectedProfile->SSID.length);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303111
3112 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003113 adapter->vdev_id,
Jingxiang Gece7c5472019-07-23 16:19:23 +08003114 conn_info_channel);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303115
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05303116 hdd_send_roamed_ind(
3117 dev,
3118 roam_bss,
Jeff Johnson8152d892019-03-10 18:37:50 -07003119 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003120 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003121 assoc_rsp,
3122 assoc_rsp_len);
Abhishek Singh533c9da2017-05-04 10:23:34 +05303123 wlan_hdd_send_roam_auth_event(
Jeff Johnsonba388342017-10-02 13:31:01 -07003124 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003125 roam_info->bssid.bytes,
Jeff Johnson8152d892019-03-10 18:37:50 -07003126 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003127 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003128 assoc_rsp,
3129 assoc_rsp_len,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003130 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131 }
3132 if (sme_get_ftptk_state
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003133 (mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003134 adapter->vdev_id)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 sme_set_ftptk_state
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003136 (mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003137 adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 false);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003139 roam_info->fAuthRequired =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 false;
3141
Jeff Johnsond377dce2017-10-04 10:32:42 -07003142 qdf_mem_copy(sta_ctx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 roam_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003144 roam_info->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303145 QDF_MAC_ADDR_SIZE);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003146 qdf_mem_copy(sta_ctx->
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003147 roam_info.peer_mac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003148 roam_info->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303149 QDF_MAC_ADDR_SIZE);
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003150 sta_ctx->roam_info.roam_id =
Jeff Johnson29c78672019-02-26 21:05:53 -08003151 roam_id;
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003152 sta_ctx->roam_info.roam_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08003153 roam_status;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003154 sta_ctx->roam_info.
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07003155 defer_key_complete = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 }
3157 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003158 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003159 ft_carrier_on);
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303160 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003161 adapter->vdev_id,
Jingxiang Gece7c5472019-07-23 16:19:23 +08003162 conn_info_channel);
Anurag Chouhanc4092922016-09-08 15:56:11 +05303163 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003164 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303165 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003166 roam_info,
Jeff Johnson8152d892019-03-10 18:37:50 -07003167 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003168 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003169 assoc_rsp,
3170 assoc_rsp_len,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303171 WLAN_STATUS_SUCCESS,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303172 GFP_KERNEL, false,
3173 roam_info->status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003174 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08003175 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 /*
3177 * wpa supplicant expecting WPA/RSN IE in
3178 * connect result.
3179 */
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003180 sme_roam_get_wpa_rsn_req_ie(mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003181 adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003182 &reqRsnLength,
3183 reqRsnIe);
3184
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003185 sme_roam_get_wpa_rsn_rsp_ie(mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003186 adapter->vdev_id,
Jeff Johnson7f8d2c32019-03-09 19:53:42 -08003187 &rsp_rsn_lemgth,
Jeff Johnson48b56b12019-03-09 19:51:48 -08003188 rsp_rsn_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003189 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 if (ft_carrier_on)
3191 hdd_send_re_assoc_event(dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07003192 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003193 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 reqRsnIe,
3195 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07003196 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003197 hdd_debug("sending connect indication to nl80211:for bssid "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003198 QDF_MAC_ADDR_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003199 " result:%d and Status:%d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003200 QDF_MAC_ADDR_ARRAY
Jeff Johnsonfd060852017-10-04 10:50:51 -07003201 (roam_info->bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003202 roam_result, roam_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003203
3204 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05303205 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003206 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303207 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003208 roam_info,
Jeff Johnson8152d892019-03-10 18:37:50 -07003209 assoc_req,
Jeff Johnsonf40f95c2019-03-10 18:43:39 -07003210 assoc_req_len,
Jeff Johnsone2b360b2019-03-10 18:39:39 -07003211 assoc_rsp,
3212 assoc_rsp_len,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303213 WLAN_STATUS_SUCCESS,
3214 GFP_KERNEL,
3215 false,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303216 roam_info->status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 }
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303218 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003219 adapter->vdev_id,
Jingxiang Gece7c5472019-07-23 16:19:23 +08003220 conn_info_channel);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221 }
3222 }
3223 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 /*
3225 * Perform any WMM-related association
3226 * processing.
3227 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003228 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003229 eCSR_BSS_TYPE_INFRASTRUCTURE);
3230
3231 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08003232 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003234 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003235 roam_info,
Jeff Johnson0a082d92019-03-04 12:25:49 -08003236 sta_ctx->conn_info.sta_id[0],
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05303237 roam_info->bss_desc);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303238 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003239 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 WLAN_WAKE_ALL_NETIF_QUEUE,
3241 WLAN_CONTROL_PATH);
3242
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 }
3244 } else {
3245 /*
3246 * wpa supplicant expecting WPA/RSN IE in connect result
3247 * in case of reassociation also need to indicate it to
3248 * supplicant.
3249 */
Jeff Johnson0a078b52018-06-01 16:15:54 -07003250 sme_roam_get_wpa_rsn_req_ie(
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003251 mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003252 adapter->vdev_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 &reqRsnLength, reqRsnIe);
3254
Ajit Pal Singhd6c08f22018-04-25 16:55:26 +05303255 cdp_hl_fc_set_td_limit(soc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003256 adapter->vdev_id,
Jingxiang Gece7c5472019-07-23 16:19:23 +08003257 conn_info_channel);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003258 hdd_send_re_assoc_event(dev, adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003259 reqRsnIe, reqRsnLength);
3260 /* Reassoc successfully */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003261 if (roam_info->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303262 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003263 hdd_change_peer_state(adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08003264 sta_ctx->conn_info.sta_id[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003265 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003267 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268#else
3269 false
3270#endif
3271 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003272 hdd_conn_set_authenticated(adapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003273 hdd_objmgr_set_peer_mlme_auth_state(
Dustin Brown89fa06e2018-09-07 10:47:27 -07003274 adapter->vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003275 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003276 } else {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003277 hdd_debug("sta_id: %d Changing TL state to AUTHENTICATED",
3278 sta_ctx->conn_info.sta_id[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303279 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003280 hdd_change_peer_state(adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08003281 sta_ctx->conn_info.sta_id[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003282 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003283#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003284 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285#else
3286 false
3287#endif
3288 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003289 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003290 hdd_objmgr_set_peer_mlme_auth_state(
Dustin Brown89fa06e2018-09-07 10:47:27 -07003291 adapter->vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003292 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 }
3294
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303295 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 /*
3297 * Perform any WMM-related association
3298 * processing
3299 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003300 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 eCSR_BSS_TYPE_INFRASTRUCTURE);
3302 }
3303
3304 /* Start the tx queues */
3305#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003306 if (roam_info->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003307 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308#endif
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303309 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003310 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 WLAN_WAKE_ALL_NETIF_QUEUE,
3312 WLAN_CONTROL_PATH);
3313 }
3314
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303315 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003316 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303317 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 }
3319#ifdef WLAN_FEATURE_11W
Jeff Johnsondc179f42017-10-21 11:27:26 -07003320 qdf_mem_zero(&adapter->hdd_stats.hdd_pmf_stats,
3321 sizeof(adapter->hdd_stats.hdd_pmf_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003322#endif
gaurank kathpalia7ef72182019-05-29 19:41:25 +05303323 if (adapter->device_mode == QDF_STA_MODE)
3324 ucfg_blm_update_bssid_connect_params(hdd_ctx->pdev,
3325 roam_info->bssid,
3326 BLM_AP_CONNECTED);
3327
Abhishek Singhbfaebe32019-03-19 13:37:55 +05303328 policy_mgr_check_n_start_opportunistic_timer(hdd_ctx->psoc);
Frank Liu064ebd42018-05-03 14:22:39 +08003329 hdd_debug("check for SAP restart");
3330 policy_mgr_check_concurrent_intf_and_restart_sap(
Dustin Brown76cd2932018-09-11 16:03:05 -07003331 hdd_ctx->psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303333 bool connect_timeout = false;
Tushnim Bhattacharyya3f780532018-08-01 19:11:40 -07003334 /* do we need to change the HW mode */
Dustin Brown76cd2932018-09-11 16:03:05 -07003335 policy_mgr_check_n_start_opportunistic_timer(hdd_ctx->psoc);
Vignesh Viswanathan014096a2017-12-07 01:24:44 +05303336 if (roam_info && roam_info->is_fils_connection &&
Jeff Johnson29c78672019-02-26 21:05:53 -08003337 eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roam_result)
Vignesh Viswanathan014096a2017-12-07 01:24:44 +05303338 qdf_copy_macaddr(&roam_info->bssid,
3339 &sta_ctx->requested_bssid);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003340 if (roam_info)
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003341 hdd_err("wlan: connection failed with " QDF_MAC_ADDR_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003342 " result: %d and Status: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003343 QDF_MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003344 roam_result, roam_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003345 else
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003346 hdd_err("wlan: connection failed with " QDF_MAC_ADDR_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003347 " result: %d and Status: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003348 QDF_MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003349 roam_result, roam_status);
Abhishek Singhc9941602016-08-09 16:06:22 +05303350
Jeff Johnson29c78672019-02-26 21:05:53 -08003351 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roam_result) ||
Jeff Johnsonfd060852017-10-04 10:50:51 -07003352 (roam_info &&
Abhishek Singhc9941602016-08-09 16:06:22 +05303353 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303354 roam_info->status_code) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303355 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303356 roam_info->status_code) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303357 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303358 roam_info->status_code)))) {
Ashish Kumar Dhanotiya3d8b0ae2019-07-10 20:55:56 +05303359 uint8_t *ssid;
3360 uint8_t ssid_len;
3361
3362 if (roam_info && roam_info->pProfile &&
3363 roam_info->pProfile->SSIDs.SSIDList) {
3364 ssid_len =
3365 roam_info->pProfile->SSIDs.
3366 SSIDList[0].SSID.length;
3367 ssid = roam_info->pProfile->SSIDs.
3368 SSIDList[0].SSID.ssId;
3369 } else {
3370 ssid_len = sta_ctx->conn_info.ssid.SSID.length;
3371 ssid = sta_ctx->conn_info.ssid.SSID.ssId;
3372 }
Abhishek Singh85283ae2019-03-08 12:00:51 +05303373 wlan_hdd_cfg80211_unlink_bss(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003374 roam_info ?
3375 roam_info->bssid.bytes :
Ashish Kumar Dhanotiya3d8b0ae2019-07-10 20:55:56 +05303376 sta_ctx->requested_bssid.bytes, ssid, ssid_len);
Jeff Johnsonf7187f22018-06-13 22:02:19 -07003377 sme_remove_bssid_from_scan_list(mac_handle,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003378 roam_info ?
3379 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003380 sta_ctx->requested_bssid.bytes);
Jeff Johnson29c78672019-02-26 21:05:53 -08003381 if (roam_result !=
Arun Kumar Khandavalli34f69cf2019-02-25 16:46:52 +05303382 eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE)
3383 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303384 }
3385
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 /*
3387 * CR465478: Only send up a connection failure result when CSR
3388 * has completed operation - with a ASSOCIATION_FAILURE status.
3389 */
Jeff Johnson29c78672019-02-26 21:05:53 -08003390 if (eCSR_ROAM_ASSOCIATION_FAILURE == roam_status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 && !hddDisconInProgress) {
gaurank kathpaliaefb20a82019-04-18 19:17:23 +05303392 u8 *assoc_rsp = NULL;
3393 u8 *assoc_req = NULL;
3394
Jeff Johnsonfd060852017-10-04 10:50:51 -07003395 if (roam_info) {
gaurank kathpaliaefb20a82019-04-18 19:17:23 +05303396 if (roam_info->pbFrames) {
3397 /* Association Request */
3398 assoc_req =
3399 (u8 *)(roam_info->pbFrames +
3400 roam_info->nBeaconLength);
3401 /* Association Response */
3402 assoc_rsp =
3403 (u8 *)(roam_info->pbFrames +
3404 roam_info->nBeaconLength +
3405 roam_info->nAssocReqLength);
3406 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003407 hdd_err("send connect failure to nl80211: for bssid "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003408 QDF_MAC_ADDR_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003409 " result: %d and Status: %d reasoncode: %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003410 QDF_MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003411 roam_result, roam_status,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003412 roam_info->reasonCode);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003413 sta_ctx->conn_info.assoc_status_code =
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303414 roam_info->status_code;
Jeff Johnson03294f12016-12-09 17:10:24 -08003415 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003416 hdd_err("connect failed: for bssid "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003417 QDF_MAC_ADDR_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003418 " result: %d and status: %d ",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003419 QDF_MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Jeff Johnson29c78672019-02-26 21:05:53 -08003420 roam_result, roam_status);
Jeff Johnson03294f12016-12-09 17:10:24 -08003421 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003422 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303423 wlan_deregister_txrx_packetdump();
3424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425 /* inform association failure event to nl80211 */
3426 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
Jeff Johnson29c78672019-02-26 21:05:53 -08003427 roam_result) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003428 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303429 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003430 roam_info->bssid.bytes,
gaurank kathpaliaefb20a82019-04-18 19:17:23 +05303431 roam_info, assoc_req,
3432 roam_info->nAssocReqLength,
3433 assoc_rsp,
3434 roam_info->nAssocRspLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003435 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303436 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303437 connect_timeout,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303438 roam_info->status_code);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303440 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003441 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303442 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303444 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303445 connect_timeout,
3446 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003448 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303449 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003450 roam_info->bssid.bytes,
gaurank kathpaliaefb20a82019-04-18 19:17:23 +05303451 roam_info, assoc_req,
3452 roam_info->nAssocReqLength,
3453 assoc_rsp,
3454 roam_info->nAssocRspLength,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003455 roam_info->reasonCode ?
3456 roam_info->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003457 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303458 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303459 connect_timeout,
Pragaspathi Thilagarajd48e6cd2019-05-30 00:52:43 +05303460 roam_info->status_code);
Wu Gao77d28352016-11-23 17:50:56 +08003461 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303462 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003463 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303464 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303466 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303467 connect_timeout,
3468 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003470 hdd_clear_roam_profile_ie(adapter);
Ashish Kumar Dhanotiya02137932019-02-26 21:43:32 +05303471 sme_reset_key(hdd_ctx->mac_handle,
3472 adapter->vdev_id);
Jeff Johnson29c78672019-02-26 21:05:53 -08003473 } else if ((eCSR_ROAM_CANCELLED == roam_status
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003474 && !hddDisconInProgress)) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003475 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003476 sta_ctx->requested_bssid.bytes,
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003477 NULL, NULL, 0, NULL, 0,
3478 WLAN_STATUS_UNSPECIFIED_FAILURE,
3479 GFP_KERNEL,
3480 connect_timeout,
3481 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003482 }
3483
Bala Venkatesh444588c2019-05-06 15:29:35 +05303484 /* Check to change TDLS state in FW
3485 * as connection failed.
3486 */
3487 if (roam_status == eCSR_ROAM_ASSOCIATION_FAILURE ||
3488 roam_status == eCSR_ROAM_CANCELLED) {
3489 ucfg_tdls_notify_connect_failure(hdd_ctx->psoc);
3490 }
3491
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 /*
3493 * Set connection state to eConnectionState_NotConnected only
3494 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003495 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 */
Jeff Johnson29c78672019-02-26 21:05:53 -08003497 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roam_status) ||
3498 (eCSR_ROAM_CANCELLED == roam_status))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 && !hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003500 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 eConnectionState_NotConnected);
3502 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003503 hdd_wmm_init(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303505 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003506 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303507 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 WLAN_CONTROL_PATH);
Abhishek Singh0edeba02018-06-05 10:04:08 +05303509 /*
Jeff Johnson29c78672019-02-26 21:05:53 -08003510 * if hddDisconInProgress is set and roam_result is
Abhishek Singh0edeba02018-06-05 10:04:08 +05303511 * eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE that mean HDD is
3512 * waiting on disconnect_comp_var so unblock anyone waiting for
3513 * disconnect to complete.
3514 */
Jeff Johnson29c78672019-02-26 21:05:53 -08003515 if ((roam_result == eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE) &&
Abhishek Singh0edeba02018-06-05 10:04:08 +05303516 hddDisconInProgress)
3517 complete(&adapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 }
3519
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303520 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521}
3522
3523/**
3524 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
Jeff Johnsonba388342017-10-02 13:31:01 -07003525 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003526 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08003527 * @roam_id: roam id
3528 * @roam_status: roam status
3529 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530 *
3531 * Here we update the status of the Ibss when we receive information that we
3532 * have started/joined an ibss session.
3533 *
3534 * Return: none
3535 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003536static void hdd_roam_ibss_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003537 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08003538 uint32_t roam_id,
3539 eRoamCmdStatus roam_status,
3540 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003541{
Jeff Johnsonba388342017-10-02 13:31:01 -07003542 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003543
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003544 hdd_debug("%s: id %d, status %d, result %d",
Jeff Johnson29c78672019-02-26 21:05:53 -08003545 adapter->dev->name, roam_id,
3546 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547
Jeff Johnson29c78672019-02-26 21:05:53 -08003548 switch (roam_result) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 /* both IBSS Started and IBSS Join should come in here. */
3550 case eCSR_ROAM_RESULT_IBSS_STARTED:
3551 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3552 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3553 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003554 struct hdd_station_ctx *hdd_sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003555 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556
Jeff Johnsond36fa332019-03-18 13:42:25 -07003557 if (!roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303558 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003559 return;
3560 }
3561
3562 /* When IBSS Started comes from CSR, we need to move
3563 * connection state to IBSS Disconnected (meaning no peers
3564 * are in the IBSS).
3565 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003566 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003567 eConnectionState_IbssDisconnected);
3568 /* notify wmm */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003569 hdd_wmm_connect(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303571
Jeff Johnson0a082d92019-03-04 12:25:49 -08003572 hdd_sta_ctx->broadcast_sta_id = roam_info->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303573
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003574 if (roam_info->staId < HDD_MAX_ADAPTERS)
3575 hdd_ctx->sta_to_adapter[roam_info->staId] =
3576 adapter;
3577 else
3578 hdd_debug("invalid sta id %d", roam_info->staId);
Abhishek Singh44725482017-11-02 16:53:23 +05303579
Jeff Johnsonfd060852017-10-04 10:50:51 -07003580 hdd_roam_register_sta(adapter, roam_info,
3581 roam_info->staId,
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05303582 roam_info->bss_desc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003583
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05303584 if (roam_info->bss_desc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003585 struct cfg80211_bss *bss;
3586#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3587 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588#endif
3589 /* we created the IBSS, notify supplicant */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003590 hdd_debug("%s: created ibss " QDF_MAC_ADDR_STR,
Jeff Johnsonba388342017-10-02 13:31:01 -07003591 adapter->dev->name,
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003592 QDF_MAC_ADDR_ARRAY(
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05303593 roam_info->bss_desc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594
3595 /* we must first give cfg80211 the BSS information */
Jeff Johnsonba388342017-10-02 13:31:01 -07003596 bss = wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003597 roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003598 if (!bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003599 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003600 adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 return;
3602 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303603 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003604 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3606 WLAN_CONTROL_PATH);
3607
3608#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
Will Huang65d64252019-07-16 17:57:42 +08003609 chan = ieee80211_get_channel(
3610 adapter->wdev.wiphy,
3611 roam_info->bss_desc->chan_freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612
3613 if (chan)
Jeff Johnsonba388342017-10-02 13:31:01 -07003614 cfg80211_ibss_joined(adapter->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 bss->bssid, chan,
3616 GFP_KERNEL);
3617 else
Will Huang65d64252019-07-16 17:57:42 +08003618 hdd_warn("%s: freq: %d, can't find channel",
3619 adapter->dev->name,
3620 roam_info->bss_desc->chan_freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003621#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003622 cfg80211_ibss_joined(adapter->dev, bss->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003623 GFP_KERNEL);
3624#endif
3625 cfg80211_put_bss(
Jeff Johnson8095a312017-09-03 09:13:24 -07003626 hdd_ctx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627 bss);
3628 }
Jeff Johnson29c78672019-02-26 21:05:53 -08003629 if (eCSR_ROAM_RESULT_IBSS_STARTED == roam_result) {
Dustin Brown76cd2932018-09-11 16:03:05 -07003630 policy_mgr_incr_active_session(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003631 adapter->device_mode, adapter->vdev_id);
Jeff Johnsone8846ab2018-03-31 11:54:45 -07003632 hdd_green_ap_start_state_mc(hdd_ctx,
Himanshu Agarwal813b2bf2018-01-22 16:32:15 +05303633 adapter->device_mode, true);
Jeff Johnson29c78672019-02-26 21:05:53 -08003634 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roam_result ||
3635 eCSR_ROAM_RESULT_IBSS_COALESCED == roam_result) {
Dustin Brown76cd2932018-09-11 16:03:05 -07003636 policy_mgr_update_connection_info(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003637 adapter->vdev_id);
Krunal Soni2c68f232015-10-26 20:52:51 -07003638 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 break;
3640 }
3641
3642 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3643 {
Jeff Johnsonba388342017-10-02 13:31:01 -07003644 hdd_err("%s: unable to create IBSS", adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 break;
3646 }
3647
3648 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003649 hdd_err("%s: unexpected result %d",
Jeff Johnson29c78672019-02-26 21:05:53 -08003650 adapter->dev->name, (int)roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 break;
3652 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653}
3654
3655/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003656 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3657 * @sta_ctx: pointer to hdd station context
3658 * @sta_id: station ID
3659 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003660 *
3661 * This information is passed to iwconfig later. The peer that joined
3662 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003663
3664 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003666bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003667 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003669 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003671 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003672 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.sta_id[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003673 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003674 peer_mac_addr, sta_id, idx);
Jeff Johnson0a082d92019-03-04 12:25:49 -08003675 sta_ctx->conn_info.sta_id[idx] = sta_id;
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003676 qdf_copy_macaddr(
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003677 &sta_ctx->conn_info.peer_macaddr[idx],
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003678 peer_mac_addr);
3679 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680 }
3681 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003682 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683}
3684
3685/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003686 * hdd_delete_peer() - removes peer from hdd station context peer table
3687 * @sta_ctx: pointer to hdd station context
3688 * @sta_id: station ID
3689 *
3690 * Return: None
3691 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003692void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id)
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003693{
3694 int i;
3695
3696 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003697 if (sta_id == sta_ctx->conn_info.sta_id[i]) {
3698 sta_ctx->conn_info.sta_id[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003699 return;
3700 }
3701 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003702}
3703
3704/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
Jeff Johnsonba388342017-10-02 13:31:01 -07003706 * @adapter: pointer to adapter
Jeff Johnson0a082d92019-03-04 12:25:49 -08003707 * @sta_id: station id
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 *
3709 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003710 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 * false otherwise.
3712 */
Jeff Johnson0a082d92019-03-04 12:25:49 -08003713static bool roam_remove_ibss_station(struct hdd_adapter *adapter,
3714 uint8_t sta_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715{
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003716 bool successful = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003717 int idx = 0;
3718 uint8_t valid_idx = 0;
3719 uint8_t del_idx = 0;
3720 uint8_t empty_slots = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003721 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722
Naveen Rawatc45d1622016-07-05 12:20:09 -07003723 for (idx = 0; idx < MAX_PEERS; idx++) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003724 if (sta_id == sta_ctx->conn_info.sta_id[idx]) {
3725 sta_ctx->conn_info.sta_id[idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303726 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727
Jeff Johnsond377dce2017-10-04 10:32:42 -07003728 qdf_zero_macaddr(&sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003729 peer_macaddr[idx]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003731 successful = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732
3733 /*
3734 * Note the deleted Index, if its 0 we need special
3735 * handling.
3736 */
3737 del_idx = idx;
3738
3739 empty_slots++;
3740 } else {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003741 if (sta_ctx->conn_info.sta_id[idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003742 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 valid_idx = idx;
3744 } else {
3745 /* Found an empty slot */
3746 empty_slots++;
3747 }
3748 }
3749 }
3750
Naveen Rawatc45d1622016-07-05 12:20:09 -07003751 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752 /* Last peer departed, set the IBSS state appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07003753 hdd_conn_set_connection_state(adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003754 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003755 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003756 }
Jeff Johnson0a082d92019-03-04 12:25:49 -08003757 /* Find next active sta_id, to have a valid sta trigger for TL. */
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003758 if (successful) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003759 if (del_idx == 0) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003760 if (sta_ctx->conn_info.sta_id[valid_idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003761 HDD_WLAN_INVALID_STA_ID) {
Jeff Johnson0a082d92019-03-04 12:25:49 -08003762 sta_ctx->conn_info.sta_id[0] =
3763 sta_ctx->conn_info.sta_id[valid_idx];
Jeff Johnsond377dce2017-10-04 10:32:42 -07003764 qdf_copy_macaddr(&sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003765 peer_macaddr[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07003766 &sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003767 peer_macaddr[valid_idx]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003768
Jeff Johnson0a082d92019-03-04 12:25:49 -08003769 sta_ctx->conn_info.sta_id[valid_idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303770 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003771 qdf_zero_macaddr(&sta_ctx->conn_info.
Jeff Johnson5ec1abf2019-02-27 14:48:24 -08003772 peer_macaddr[valid_idx]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003773 }
3774 }
3775 }
Jeff Johnson24c26fd2019-03-10 00:29:29 -08003776 return successful;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777}
3778
3779/**
3780 * roam_ibss_connect_handler() - IBSS connection handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003781 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003782 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003783 *
3784 * We update the status of the IBSS to connected in this function.
3785 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303786 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003788static QDF_STATUS roam_ibss_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003789 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790{
3791 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003792 /*
3793 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3794 * a partner stations).
3795 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003796 hdd_conn_set_connection_state(adapter, eConnectionState_IbssConnected);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797
3798 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003799 hdd_conn_save_connect_info(adapter, roam_info, eCSR_BSS_TYPE_IBSS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003800
3801 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003802 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003803 /* add bss_id to cfg80211 data base */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003804 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07003805 if (!bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003806 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003807 adapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303808 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 }
3810 cfg80211_put_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003811 WLAN_HDD_GET_CTX(adapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 bss);
3813
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303814 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815}
3816
3817/**
3818 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003819 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003820 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08003821 * @roam_id: roam id
3822 * @roam_status: roam status
3823 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003824 *
3825 * This function indicates the Mic failure to the supplicant
3826 *
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003827 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003828 */
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003829static void
Jeff Johnsonba388342017-10-02 13:31:01 -07003830hdd_roam_mic_error_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003831 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003832{
Jeff Johnsond377dce2017-10-04 10:32:42 -07003833 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003834 tSirMicFailureInfo *mic_failure_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835
Jeff Johnsone7951512019-02-27 10:02:51 -08003836 if (eConnectionState_Associated != sta_ctx->conn_info.conn_state)
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003837 return;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003838
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003839 mic_failure_info = roam_info->u.pMICFailureInfo;
3840 cfg80211_michael_mic_failure(adapter->dev,
3841 mic_failure_info->taMacAddr,
3842 mic_failure_info->multicast ?
3843 NL80211_KEYTYPE_GROUP :
3844 NL80211_KEYTYPE_PAIRWISE,
3845 mic_failure_info->keyId,
3846 mic_failure_info->TSC,
3847 GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848}
3849
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003850#ifdef CRYPTO_SET_KEY_CONVERGED
3851static QDF_STATUS wlan_hdd_set_key_helper(struct hdd_adapter *adapter,
3852 uint32_t *roam_id)
3853{
3854 int ret;
3855 struct wlan_objmgr_vdev *vdev;
3856
3857 vdev = hdd_objmgr_get_vdev(adapter);
3858 if (!vdev)
3859 return QDF_STATUS_E_FAILURE;
Kiran Kumar Lokere47d0dac2019-01-24 18:38:33 -08003860 ret = wlan_cfg80211_crypto_add_key(vdev,
3861 WLAN_CRYPTO_KEY_TYPE_UNICAST, 0);
Rajeev Kumar Sirasanagandla25bdfad2019-02-15 19:15:49 +05303862 hdd_objmgr_put_vdev(vdev);
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003863 if (ret != 0) {
3864 hdd_err("crypto add key fail, status: %d", ret);
3865 return QDF_STATUS_E_FAILURE;
3866 }
3867
3868 return QDF_STATUS_SUCCESS;
3869}
3870#else
3871static QDF_STATUS wlan_hdd_set_key_helper(struct hdd_adapter *adapter,
3872 uint32_t *roam_id)
3873{
3874 struct hdd_station_ctx *sta_ctx =
3875 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
3876 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3877
3878 return sme_roam_set_key(hdd_ctx->mac_handle,
Jeff Johnson1abc5662019-02-04 14:27:02 -08003879 adapter->vdev_id,
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003880 &sta_ctx->ibss_enc_key,
3881 roam_id);
3882}
3883#endif
3884
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003885/**
3886 * roam_roam_connect_status_update_handler() - IBSS connect status update
Jeff Johnsonba388342017-10-02 13:31:01 -07003887 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003888 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08003889 * @roam_id: roam id
3890 * @roam_status: roam status
3891 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003892 *
3893 * The Ibss connection status is updated regularly here in this function.
3894 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303895 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003896 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303897static QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07003898roam_roam_connect_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003899 struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08003900 uint32_t roam_id,
3901 eRoamCmdStatus roam_status,
3902 eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903{
Jeff Johnsonba388342017-10-02 13:31:01 -07003904 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003905 struct wlan_objmgr_vdev *vdev;
Rajeev Kumardfa37072017-01-13 16:27:22 -08003906 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303907
Jeff Johnson29c78672019-02-26 21:05:53 -08003908 switch (roam_result) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003909 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3910 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003911 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003912 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003913 struct station_info *stainfo;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003914 eCsrEncryptionType encr_type = sta_ctx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003915
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303916 hdd_debug("IBSS New Peer indication from SME "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07003917 "with peerMac " QDF_MAC_ADDR_STR " BSSID: "
3918 QDF_MAC_ADDR_STR " and stationID= %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07003919 QDF_MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3920 QDF_MAC_ADDR_ARRAY(sta_ctx->conn_info.bssid.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003921 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003922
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003923 if (!hdd_save_peer
Jeff Johnsonba388342017-10-02 13:31:01 -07003924 (WLAN_HDD_GET_STATION_CTX_PTR(adapter),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003925 roam_info->staId,
3926 &roam_info->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003927 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928 break;
3929 }
3930
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003931 if (roam_info->staId < HDD_MAX_ADAPTERS)
3932 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
3933 else
3934 hdd_debug("invalid sta id %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003935
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003936 if (hdd_is_key_install_required_for_ibss(encr_type))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003937 roam_info->fAuthRequired = true;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003938
Jeff Johnson71a1d5c2018-12-30 11:31:04 -08003939 /* Register the Station with datapath for the new peer. */
Jeff Johnsonba388342017-10-02 13:31:01 -07003940 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003941 roam_info,
3942 roam_info->staId,
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05303943 roam_info->bss_desc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303944 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Jeff Johnson71a1d5c2018-12-30 11:31:04 -08003945 hdd_err("Cannot register STA for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303946 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 }
Jeff Johnsond377dce2017-10-04 10:32:42 -07003948 sta_ctx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003949 stainfo = qdf_mem_malloc(sizeof(*stainfo));
Min Liu74a1a502018-10-10 19:59:07 +08003950 if (!stainfo)
Kai Liu7400c5b2016-09-29 15:28:36 +08003951 return QDF_STATUS_E_NOMEM;
Min Liu74a1a502018-10-10 19:59:07 +08003952
Kai Liu7400c5b2016-09-29 15:28:36 +08003953 stainfo->filled = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003954 stainfo->generation = sta_ctx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955
Jeff Johnsonba388342017-10-02 13:31:01 -07003956 cfg80211_new_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003957 (const u8 *)roam_info->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003958 stainfo, GFP_KERNEL);
3959 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003961 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003962 sta_ctx->ibss_enc_key.keyDirection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963 eSIR_TX_RX;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003964 qdf_copy_macaddr(&sta_ctx->ibss_enc_key.peerMac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003965 &roam_info->peerMac);
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003966 vdev = hdd_objmgr_get_vdev(adapter);
3967 if (!vdev)
3968 return QDF_STATUS_E_FAILURE;
3969 wlan_crypto_update_set_key_peer(vdev, true, 0,
3970 &roam_info->peerMac);
Rajeev Kumar Sirasanagandla25bdfad2019-02-15 19:15:49 +05303971 hdd_objmgr_put_vdev(vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003972
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303973 hdd_debug("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003974 encr_type);
Jeff Johnson29c78672019-02-26 21:05:53 -08003975 qdf_status = wlan_hdd_set_key_helper(adapter, &roam_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303976 if (QDF_STATUS_SUCCESS != qdf_status) {
Kiran Kumar Lokere7d6e4c92018-09-19 13:45:47 -07003977 hdd_err("sme set_key fail status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003978 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303979 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003980 }
3981 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303982 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003983 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003984 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3985 WLAN_CONTROL_PATH);
3986 break;
3987 }
3988
3989 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3990 {
3991
Jeff Johnsonfd060852017-10-04 10:50:51 -07003992 roam_ibss_connect_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993
3994 break;
3995 }
3996 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3997 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003998 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003999 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004000
Jeff Johnsonfd060852017-10-04 10:50:51 -07004001 if (!roam_remove_ibss_station(adapter, roam_info->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004002 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304004 hdd_debug("IBSS Peer Departed from SME "
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07004005 "with peerMac " QDF_MAC_ADDR_STR " BSSID: "
4006 QDF_MAC_ADDR_STR " and stationID= %d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004007 QDF_MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
4008 QDF_MAC_ADDR_ARRAY(sta_ctx->conn_info.bssid.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07004009 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004010
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05304011 hdd_roam_deregister_sta(adapter, roam_info->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004012
Rajeev Kumar7774cc82017-10-20 15:16:47 -07004013 if (roam_info->staId < HDD_MAX_ADAPTERS)
4014 hdd_ctx->sta_to_adapter[roam_info->staId] = NULL;
4015 else
4016 hdd_debug("invalid sta id %d", roam_info->staId);
4017
Jeff Johnsond377dce2017-10-04 10:32:42 -07004018 sta_ctx->ibss_sta_generation++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019
Jeff Johnsonba388342017-10-02 13:31:01 -07004020 cfg80211_del_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004021 (const u8 *)&roam_info->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 GFP_KERNEL);
4023 break;
4024 }
4025 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
4026 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004027 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 /* Stop only when we are inactive */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304029 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004030 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304031 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07004033 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 eConnectionState_NotConnected);
4035
4036 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07004037 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 break;
4039 }
4040 default:
4041 break;
4042
4043 }
4044
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304045 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004046}
4047
4048#ifdef FEATURE_WLAN_TDLS
Jeff Johnsonba388342017-10-02 13:31:01 -07004049QDF_STATUS hdd_roam_register_tdlssta(struct hdd_adapter *adapter,
Jeff Johnson0a082d92019-03-04 12:25:49 -08004050 const uint8_t *peerMac, uint16_t sta_id,
Jeff Johnsona8ce1272018-03-01 14:39:10 -08004051 uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304053 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Jeff Johnsonc419c172019-03-05 10:59:32 -08004054 struct ol_txrx_desc_type txrx_desc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08004055 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07004056 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
4057 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Mohit Khannae1b86022019-04-12 10:04:57 -07004058 struct cdp_vdev *txrx_vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004059
4060 /*
4061 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
4062 * be peer MAC, here we are working on direct Link
4063 */
Sourav Mohapatra3646a852019-07-29 09:08:40 +05304064 WLAN_ADDR_COPY(txrx_desc.peer_addr.bytes, peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004065
4066 /* set the QoS field appropriately .. */
Jeff Johnsonc419c172019-03-05 10:59:32 -08004067 txrx_desc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068
Dhanashri Atre50141c52016-04-07 13:15:29 -07004069 /* Register the vdev transmit and receive functions */
4070 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
Jinwei Chene6143972019-03-25 19:38:05 +08004071 if (adapter->hdd_ctx->enable_dp_rx_threads) {
4072 txrx_ops.rx.rx = hdd_rx_pkt_thread_enqueue_cbk;
4073 txrx_ops.rx.rx_stack = hdd_rx_packet_cbk;
Mohit Khannaf0620ce2019-07-28 21:31:05 -07004074 txrx_ops.rx.rx_gro_flush = hdd_rx_thread_gro_flush_ind_cbk;
Jinwei Chene6143972019-03-25 19:38:05 +08004075 } else {
4076 txrx_ops.rx.rx = hdd_rx_packet_cbk;
4077 txrx_ops.rx.rx_stack = NULL;
4078 }
Mohit Khannae1b86022019-04-12 10:04:57 -07004079 txrx_vdev = cdp_get_vdev_from_vdev_id(soc,
4080 (struct cdp_pdev *)pdev,
4081 adapter->vdev_id);
4082 if (!txrx_vdev)
4083 return QDF_STATUS_E_FAILURE;
Jinwei Chene6143972019-03-25 19:38:05 +08004084
Mohit Khannae1b86022019-04-12 10:04:57 -07004085 cdp_vdev_register(soc, txrx_vdev,
4086 adapter,
4087 (struct cdp_ctrl_objmgr_vdev *)adapter->vdev,
4088 &txrx_ops);
Jeff Johnsonba388342017-10-02 13:31:01 -07004089 adapter->tx_fn = txrx_ops.tx.tx;
Poddar, Siddarth31797fa2018-01-22 17:24:15 +05304090 txrx_ops.rx.stats_rx = hdd_tx_rx_collect_connectivity_stats_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091
4092 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004093 qdf_status = cdp_peer_register(soc,
Jeff Johnsonc419c172019-03-05 10:59:32 -08004094 (struct cdp_pdev *)pdev, &txrx_desc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304095 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004096 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304097 qdf_status, qdf_status);
4098 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 }
4100
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304101 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004102}
4103
Jeff Johnson53367842017-10-03 11:10:34 -07004104QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05304105 struct qdf_mac_addr *peer_mac)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304107 QDF_STATUS qdf_status;
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07004108
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08004109 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08004110 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05304111 *peer_mac);
Kabilan Kannanb4e01372018-01-15 13:33:10 -08004112
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304113 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115#endif
4116
4117#ifdef WLAN_FEATURE_11W
Jeff Johnson72afbf82019-03-10 11:32:52 -07004118
4119#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4120
4121static void hdd_rx_unprot_disassoc(struct net_device *dev,
4122 const u8 *buf, size_t len)
4123{
4124 cfg80211_rx_unprot_mlme_mgmt(dev, buf, len);
4125}
4126
4127static void hdd_rx_unprot_deauth(struct net_device *dev,
4128 const u8 *buf, size_t len)
4129{
4130 cfg80211_rx_unprot_mlme_mgmt(dev, buf, len);
4131}
4132
4133#else
4134
4135static void hdd_rx_unprot_disassoc(struct net_device *dev,
4136 const u8 *buf, size_t len)
4137{
4138 cfg80211_send_unprot_disassoc(dev, buf, len);
4139}
4140
4141static void hdd_rx_unprot_deauth(struct net_device *dev,
4142 const u8 *buf, size_t len)
4143{
4144 cfg80211_send_unprot_deauth(dev, buf, len);
4145}
4146
4147#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0)) */
4148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149/**
4150 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
Jeff Johnson72afbf82019-03-10 11:32:52 -07004151 * @adapter: pointer to the adapter
4152 * @frame_length: Length of the unprotected frame being passed
4153 * @frame: Pointer to the frame buffer
4154 * @frame_type: 802.11 frame type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 *
4156 * This function forwards the unprotected management frame to the supplicant.
4157 *
4158 * Return: nothing
4159 */
4160static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07004161hdd_indicate_unprot_mgmt_frame(struct hdd_adapter *adapter,
Jeff Johnson72afbf82019-03-10 11:32:52 -07004162 uint32_t frame_length,
4163 uint8_t *frame, uint8_t frame_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004164{
Jeff Johnson72afbf82019-03-10 11:32:52 -07004165 uint8_t type, subtype;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004167 hdd_debug("Frame Type = %d Frame Length = %d",
Jeff Johnson72afbf82019-03-10 11:32:52 -07004168 frame_type, frame_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169
Jeff Johnson72afbf82019-03-10 11:32:52 -07004170 if (hdd_validate_adapter(adapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172
Jeff Johnson72afbf82019-03-10 11:32:52 -07004173 if (!frame_length) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004174 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004175 return;
4176 }
4177
Jeff Johnson72afbf82019-03-10 11:32:52 -07004178 if (!frame) {
4179 hdd_err("frame is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180 return;
4181 }
4182
Jeff Johnson72afbf82019-03-10 11:32:52 -07004183 type = WLAN_HDD_GET_TYPE_FRM_FC(frame[0]);
4184 if (type != SIR_MAC_MGMT_FRAME) {
4185 hdd_warn("Unexpected frame type %d", type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 return;
4187 }
Jeff Johnson72afbf82019-03-10 11:32:52 -07004188
4189 subtype = WLAN_HDD_GET_SUBTYPE_FRM_FC(frame[0]);
4190 switch (subtype) {
4191 case SIR_MAC_MGMT_DISASSOC:
4192 hdd_rx_unprot_disassoc(adapter->dev, frame, frame_length);
4193 adapter->hdd_stats.hdd_pmf_stats.num_unprot_disassoc_rx++;
4194 break;
4195 case SIR_MAC_MGMT_DEAUTH:
4196 hdd_rx_unprot_deauth(adapter->dev, frame, frame_length);
4197 adapter->hdd_stats.hdd_pmf_stats.num_unprot_deauth_rx++;
4198 break;
4199 default:
4200 hdd_warn("Unexpected frame subtype %d", subtype);
4201 break;
4202 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203}
Jeff Johnson72afbf82019-03-10 11:32:52 -07004204#endif /* WLAN_FEATURE_11W */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004205
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004206#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207/**
4208 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
Jeff Johnsonba388342017-10-02 13:31:01 -07004209 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004210 * @tid: traffic identifier
4211 * @state: state
4212 * @measInterval: measurement interval
4213 *
4214 * This function sends traffic stream metrics IE information to
4215 * the supplicant via wireless event.
4216 *
4217 * Return: none
4218 */
4219static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004220hdd_indicate_tsm_ie(struct hdd_adapter *adapter, uint8_t tid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004221 uint8_t state, uint16_t measInterval)
4222{
4223 union iwreq_data wrqu;
4224 char buf[IW_CUSTOM_MAX + 1];
4225 int nBytes = 0;
4226
Jeff Johnsond36fa332019-03-18 13:42:25 -07004227 if (!adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228 return;
4229
4230 /* create the event */
4231 memset(&wrqu, '\0', sizeof(wrqu));
4232 memset(buf, '\0', sizeof(buf));
4233
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004234 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004235 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004236
4237 nBytes =
4238 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4239 measInterval);
4240
4241 wrqu.data.pointer = buf;
4242 wrqu.data.length = nBytes;
4243 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004244 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004245}
4246
4247/**
4248 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004249 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004250 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 *
4252 * This function sends cckm preauth indication to the supplicant
4253 * via wireless custom event.
4254 *
4255 * Return: none
4256 */
4257static void
Jeff Johnson172237b2017-11-07 15:32:59 -08004258hdd_indicate_cckm_pre_auth(struct hdd_adapter *adapter,
4259 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004260{
4261 union iwreq_data wrqu;
4262 char buf[IW_CUSTOM_MAX + 1];
4263 char *pos = buf;
4264 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4265
Jeff Johnsond36fa332019-03-18 13:42:25 -07004266 if ((!adapter) || (!roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 return;
4268
4269 /* create the event */
4270 memset(&wrqu, '\0', sizeof(wrqu));
4271 memset(buf, '\0', sizeof(buf));
4272
4273 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowdacb7b8b82019-04-10 14:27:47 -07004274 hdd_debug("CCXPREAUTHNOTIFY=" QDF_MAC_ADDR_STR " %d:%d",
Srinivas Girigowda34fbba02019-04-08 12:07:44 -07004275 QDF_MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07004276 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277
4278 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4279 pos += nBytes;
4280 freeBytes -= nBytes;
4281
Jeff Johnsonfd060852017-10-04 10:50:51 -07004282 qdf_mem_copy(pos, roam_info->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304283 pos += QDF_MAC_ADDR_SIZE;
4284 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004285
4286 nBytes = snprintf(pos, freeBytes, " %u:%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004287 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288 freeBytes -= nBytes;
4289
4290 wrqu.data.pointer = buf;
4291 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4292
4293 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004294 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004295}
4296
4297/**
4298 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004299 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004300 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004301 *
4302 * Return: none
4303 */
4304static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004305hdd_indicate_ese_adj_ap_rep_ind(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004306 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004307{
4308 union iwreq_data wrqu;
4309 char buf[IW_CUSTOM_MAX + 1];
4310 int nBytes = 0;
4311
Jeff Johnsond36fa332019-03-18 13:42:25 -07004312 if ((!adapter) || (!roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004313 return;
4314
4315 /* create the event */
4316 memset(&wrqu, '\0', sizeof(wrqu));
4317 memset(buf, '\0', sizeof(buf));
4318
Jeff Johnsonfd060852017-10-04 10:50:51 -07004319 hdd_debug("CCXADJAPREP=%u", roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004320
4321 nBytes =
4322 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004323 roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004324
4325 wrqu.data.pointer = buf;
4326 wrqu.data.length = nBytes;
4327
4328 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004329 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004330}
4331
4332/**
4333 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
Jeff Johnsonba388342017-10-02 13:31:01 -07004334 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 * @measurementToken: measurement token
4336 * @flag: flag
4337 * @numBss: number of bss
4338 *
4339 * If the measurement is none and no scan results found,
4340 * indicate the supplicant about measurement done.
4341 *
4342 * Return: none
4343 */
4344void
Jeff Johnsonba388342017-10-02 13:31:01 -07004345hdd_indicate_ese_bcn_report_no_results(const struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346 const uint16_t measurementToken,
4347 const bool flag, const uint8_t numBss)
4348{
4349 union iwreq_data wrqu;
4350 char buf[IW_CUSTOM_MAX];
4351 char *pos = buf;
4352 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4353
4354 memset(&wrqu, '\0', sizeof(wrqu));
4355 memset(buf, '\0', sizeof(buf));
4356
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004357 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004358 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359
4360 nBytes =
4361 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4362 flag, numBss);
4363
4364 wrqu.data.pointer = buf;
4365 wrqu.data.length = nBytes;
4366 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004367 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004368}
4369
4370/**
4371 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004372 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004373 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004374 *
4375 * If the measurement is none and no scan results found,
4376 * indicate the supplicant about measurement done.
4377 *
4378 * Return: none
4379 */
4380static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004381hdd_indicate_ese_bcn_report_ind(const struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004382 const struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004383{
4384 union iwreq_data wrqu;
4385 char buf[IW_CUSTOM_MAX];
4386 char *pos = buf;
4387 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4388 uint8_t i = 0, len = 0;
4389 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4390 uint8_t lastSent = 0, sendBss = 0;
4391 int bcnRepFieldSize =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004392 sizeof(roam_info->pEseBcnReportRsp->bcnRepBssInfo[0].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 bcnReportFields);
4394 uint8_t ieLenByte = 1;
4395 /*
4396 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4397 */
4398#define ESEBCNREPHEADER_LEN (18)
4399
Jeff Johnsond36fa332019-03-18 13:42:25 -07004400 if ((!adapter) || (!roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401 return;
4402
4403 /*
4404 * Custom event can pass maximum of 256 bytes of data,
4405 * based on the IE len we need to identify how many BSS info can
4406 * be filled in to custom event data.
4407 */
4408 /*
4409 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4410 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4411 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4412 */
4413
Jeff Johnsonfd060852017-10-04 10:50:51 -07004414 if ((roam_info->pEseBcnReportRsp->flag >> 1)
4415 && (!roam_info->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004416 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004418 * indicate the supplicant about measurement done
4419 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004420 hdd_indicate_ese_bcn_report_no_results(
Jeff Johnsonba388342017-10-02 13:31:01 -07004421 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004422 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004423 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004424 roam_info->pEseBcnReportRsp->flag,
4425 roam_info->pEseBcnReportRsp->numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004427 while (lastSent < roam_info->pEseBcnReportRsp->numBss) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004428 memset(&wrqu, '\0', sizeof(wrqu));
4429 memset(buf, '\0', sizeof(buf));
4430 tot_bcn_ieLen = 0;
4431 sendBss = 0;
4432 pos = buf;
4433 freeBytes = IW_CUSTOM_MAX;
4434
4435 for (i = lastSent;
Jeff Johnsonfd060852017-10-04 10:50:51 -07004436 i < roam_info->pEseBcnReportRsp->numBss; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 len =
4438 bcnRepFieldSize + ieLenByte +
Jeff Johnsonfd060852017-10-04 10:50:51 -07004439 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004440 bcnRepBssInfo[i].ieLen;
4441 if ((len + tot_bcn_ieLen) >
4442 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4443 break;
4444 }
4445 tot_bcn_ieLen += len;
4446 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004447 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004448 i, bcnRepFieldSize, 1,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004449 roam_info->pEseBcnReportRsp->
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004450 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004451 }
4452
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004453 hdd_debug("Sending %d BSS Info", sendBss);
4454 hdd_debug("CCXBCNREP=%d %d %d %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004455 roam_info->pEseBcnReportRsp->measurementToken,
4456 roam_info->pEseBcnReportRsp->flag, sendBss,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004457 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004458
4459 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004460 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004462 roam_info->pEseBcnReportRsp->flag,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004463 sendBss);
4464 pos += nBytes;
4465 freeBytes -= nBytes;
4466
4467 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304468 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004469 sizeof(tot_bcn_ieLen));
4470 pos += sizeof(tot_bcn_ieLen);
4471 freeBytes -= sizeof(tot_bcn_ieLen);
4472
4473 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004474 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4476 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4477 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004478 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004479 bcnRepBssInfo[i +
4480 lastSent].bcnReportFields.
4481 ChanNum,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004482 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004483 bcnRepBssInfo[i +
4484 lastSent].bcnReportFields.
4485 Spare,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004486 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004487 bcnRepBssInfo[i +
4488 lastSent].bcnReportFields.
4489 MeasDuration,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004490 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004491 bcnRepBssInfo[i +
4492 lastSent].bcnReportFields.
4493 PhyType,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004494 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495 bcnRepBssInfo[i +
4496 lastSent].bcnReportFields.
4497 RecvSigPower,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004498 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 bcnRepBssInfo[i +
4500 lastSent].bcnReportFields.
4501 ParentTsf,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004502 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004503 bcnRepBssInfo[i +
4504 lastSent].bcnReportFields.
4505 TargetTsf[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004506 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 bcnRepBssInfo[i +
4508 lastSent].bcnReportFields.
4509 TargetTsf[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004510 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004511 bcnRepBssInfo[i +
4512 lastSent].bcnReportFields.
4513 BcnInterval,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004514 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004515 bcnRepBssInfo[i +
4516 lastSent].bcnReportFields.
4517 CapabilityInfo,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004518 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 bcnRepBssInfo[i +
4520 lastSent].bcnReportFields.
4521 Bssid[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004522 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004523 bcnRepBssInfo[i +
4524 lastSent].bcnReportFields.
4525 Bssid[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004526 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 bcnRepBssInfo[i +
4528 lastSent].bcnReportFields.
4529 Bssid[2],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004530 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004531 bcnRepBssInfo[i +
4532 lastSent].bcnReportFields.
4533 Bssid[3],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004534 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535 bcnRepBssInfo[i +
4536 lastSent].bcnReportFields.
4537 Bssid[4],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004538 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539 bcnRepBssInfo[i +
4540 lastSent].bcnReportFields.
4541 Bssid[5]);
4542
4543 /* bcn report fields are copied */
4544 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004545 sizeof(roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004546 bcnRepBssInfo[i +
4547 lastSent].
4548 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304549 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004550 (char *)&roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004551 pEseBcnReportRsp->bcnRepBssInfo[i +
4552 lastSent].
4553 bcnReportFields, len);
4554 pos += len;
4555 freeBytes -= len;
4556
4557 /* Add 1 byte of ie len */
4558 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004559 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304561 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 pos += sizeof(len);
4563 freeBytes -= sizeof(len);
4564
4565 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304566 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004567 (char *)roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004568 pEseBcnReportRsp->bcnRepBssInfo[i +
4569 lastSent].
4570 pBuf, len);
4571 pos += len;
4572 freeBytes -= len;
4573 }
4574
4575 wrqu.data.pointer = buf;
4576 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4577
4578 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004579 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 buf);
4581 lastSent += sendBss;
4582 }
4583 }
4584}
4585
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004586#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004587
4588/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304589 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
Jeff Johnsond377dce2017-10-04 10:32:42 -07004590 * @sta_ctx: Station Context
Komal Seelam98760ba2015-12-15 11:05:18 +05304591 *
4592 * API to check if the connection authentication type is 8021x_sha256.
4593 *
4594 * Return: bool
4595 */
4596#ifdef WLAN_FEATURE_11W
Jeff Johnson435e1b82017-10-07 14:13:10 -07004597static inline bool
4598hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304599{
4600 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
Jeff Johnson96e33512019-02-27 15:10:21 -08004601 sta_ctx->conn_info.auth_type;
Komal Seelam98760ba2015-12-15 11:05:18 +05304602}
4603#else
Jeff Johnson435e1b82017-10-07 14:13:10 -07004604static inline bool
4605hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304606{
4607 return false;
4608}
4609#endif
4610
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304611/*
4612 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4613 * @adapter: Pointer to adapter context
4614 * @roam_info: Pointer to roam info
4615 *
4616 * Return: None
4617 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004618static void hdd_roam_channel_switch_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004619 struct csr_roam_info *roam_info)
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304620{
4621 struct hdd_chan_change_params chan_change;
4622 struct cfg80211_bss *bss;
4623 struct net_device *dev = adapter->dev;
4624 struct wireless_dev *wdev = dev->ieee80211_ptr;
4625 struct wiphy *wiphy = wdev->wiphy;
4626 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -07004627 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304628 mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304629
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004630 hdd_debug("channel switch for session:%d to channel:%d",
Jeff Johnson1abc5662019-02-04 14:27:02 -08004631 adapter->vdev_id, roam_info->chan_info.chan_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304632
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304633 /* Enable Roaming on STA interface which was disabled before CSA */
4634 if (adapter->device_mode == QDF_STA_MODE)
Jeff Johnson1abc5662019-02-04 14:27:02 -08004635 sme_start_roaming(mac_handle, adapter->vdev_id,
Vignesh Viswanathan3d478032018-08-02 20:18:53 +05304636 REASON_DRIVER_ENABLED);
4637
Paul Zhang427962d2019-07-25 15:22:55 +08004638 chan_change.chan_freq =
4639 wlan_reg_chan_to_freq(hdd_ctx->pdev,
4640 roam_info->chan_info.chan_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304641 chan_change.chan_params.ch_width =
4642 roam_info->chan_info.ch_width;
4643 chan_change.chan_params.sec_ch_offset =
4644 roam_info->chan_info.sec_ch_offset;
4645 chan_change.chan_params.center_freq_seg0 =
4646 roam_info->chan_info.band_center_freq1;
4647 chan_change.chan_params.center_freq_seg1 =
4648 roam_info->chan_info.band_center_freq2;
4649
4650 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
Jeff Johnsond36fa332019-03-18 13:42:25 -07004651 if (!bss)
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304652 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4653 else
4654 cfg80211_put_bss(wiphy, bss);
4655
bings58ce8622017-07-10 15:55:36 +08004656 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4657 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304658 if (QDF_IS_STATUS_ERROR(status))
4659 hdd_err("channel change notification failed");
4660
Dustin Brown76cd2932018-09-11 16:03:05 -07004661 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->psoc,
Jeff Johnson1abc5662019-02-04 14:27:02 -08004662 adapter->vdev_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304663 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004664 hdd_debug("set hw mode change not done");
Abhishek Singhbfaebe32019-03-19 13:37:55 +05304665
4666 hdd_debug("check for SAP restart");
4667 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->psoc);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304668}
4669
Komal Seelam98760ba2015-12-15 11:05:18 +05304670/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004671 * hdd_sme_roam_callback() - hdd sme roam callback
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004672 * @context: pointer to adapter context
Jeff Johnsonfd060852017-10-04 10:50:51 -07004673 * @roam_info: pointer to roam info
Jeff Johnson29c78672019-02-26 21:05:53 -08004674 * @roam_id: roam id
4675 * @roam_status: roam status
4676 * @roam_result: roam result
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304678 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004679 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304680QDF_STATUS
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004681hdd_sme_roam_callback(void *context, struct csr_roam_info *roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004682 uint32_t roam_id,
4683 eRoamCmdStatus roam_status, eCsrRoamResult roam_result)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304685 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004686 struct hdd_adapter *adapter = context;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004687 struct hdd_station_ctx *sta_ctx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304688 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304689 struct cfg80211_bss *bss_status;
Jeff Johnson49432062017-08-28 12:08:45 -07004690 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691
Jeff Johnson8d4621b2019-03-08 15:45:38 -08004692 hdd_debug("CSR Callback: status=%d result=%d roamID=%d",
4693 roam_status, roam_result, roam_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004694
4695 /* Sanity check */
Jeff Johnsond36fa332019-03-18 13:42:25 -07004696 if ((!adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004697 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304698 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 }
4700
Jeff Johnsond377dce2017-10-04 10:32:42 -07004701 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonba388342017-10-02 13:31:01 -07004702 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703
Abhishek Singhf723e3d2018-02-20 18:02:37 +05304704 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Jeff Johnson29c78672019-02-26 21:05:53 -08004705 adapter->vdev_id, roam_status));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304706
Jeff Johnson29c78672019-02-26 21:05:53 -08004707 switch (roam_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 /*
4709 * We did pre-auth,then we attempted a 11r or ese reassoc.
4710 * reassoc failed due to failure, timeout, reject from ap
4711 * in any case tell the OS, our carrier is off and mark
4712 * interface down.
4713 */
4714 case eCSR_ROAM_FT_REASSOC_FAILED:
Jeff Johnson29c78672019-02-26 21:05:53 -08004715 hdd_err("Reassoc Failed with roam_status: %d roam_result: %d SessionID: %d",
4716 roam_status, roam_result, adapter->vdev_id);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304717 qdf_ret_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08004718 hdd_dis_connect_handler(adapter, roam_info, roam_id,
4719 roam_status, roam_result);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004720 sta_ctx->ft_carrier_on = false;
Jeff Johnson690fe952017-10-25 11:48:39 -07004721 sta_ctx->hdd_reassoc_scenario = false;
4722 hdd_debug("hdd_reassoc_scenario set to: %d, ReAssoc Failed, session: %d",
Jeff Johnson1abc5662019-02-04 14:27:02 -08004723 sta_ctx->hdd_reassoc_scenario, adapter->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 break;
4725
4726 case eCSR_ROAM_FT_START:
4727 /*
4728 * When we roam for ESE and 11r, we dont want the OS to be
4729 * informed that the link is down. So mark the link ready for
4730 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4731 * be received. Where in we will not mark the link down
4732 * Also we want to stop tx at this point when we will be
4733 * doing disassoc at this time. This saves 30-60 msec
4734 * after reassoc.
4735 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304736 hdd_debug("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004737 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004738 hdd_napi_serialize(1);
Jeff Johnsonba388342017-10-02 13:31:01 -07004739 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304740 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004741 WLAN_CONTROL_PATH);
Sourav Mohapatraffbd0272019-07-31 14:18:25 +05304742 status = hdd_roam_deregister_sta(
4743 adapter,
4744 sta_ctx->conn_info.peer_macaddr[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304745 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304746 qdf_ret_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004747 sta_ctx->ft_carrier_on = true;
Jeff Johnson690fe952017-10-25 11:48:39 -07004748 sta_ctx->hdd_reassoc_scenario = true;
4749 hdd_debug("hdd_reassoc_scenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
Jeff Johnson1abc5662019-02-04 14:27:02 -08004750 sta_ctx->hdd_reassoc_scenario, adapter->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004752 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004753 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004754 hdd_napi_serialize(0);
Jeff Johnson29c78672019-02-26 21:05:53 -08004755 if (roam_result == eCSR_ROAM_RESULT_FAILURE) {
Jeff Johnsonba388342017-10-02 13:31:01 -07004756 adapter->roam_ho_fail = true;
Pragaspathi Thilagaraj8ea625d2019-02-14 16:11:45 +05304757 hdd_set_roaming_in_progress(false);
4758 } else {
Jeff Johnsonba388342017-10-02 13:31:01 -07004759 adapter->roam_ho_fail = false;
Pragaspathi Thilagaraj8ea625d2019-02-14 16:11:45 +05304760 }
Jeff Johnsonba388342017-10-02 13:31:01 -07004761 complete(&adapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004762 break;
Pragaspathi Thilagaraj8ea625d2019-02-14 16:11:45 +05304763 case eCSR_ROAM_SYNCH_COMPLETE:
4764 hdd_debug("LFR3: Roam synch complete");
4765 hdd_set_roaming_in_progress(false);
4766 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004767 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004768 /* notify apps that we can't pass traffic anymore */
Dustin Browna7bb6ae2018-08-16 16:51:50 -07004769 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004770 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304771 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004772 WLAN_CONTROL_PATH);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004773 if (sta_ctx->ft_carrier_on == false) {
Jeff Johnsonba388342017-10-02 13:31:01 -07004774 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 WLAN_NETIF_CARRIER_OFF,
4776 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004777 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004778 break;
4779 case eCSR_ROAM_LOSTLINK:
Jeff Johnson29c78672019-02-26 21:05:53 -08004780 if (roam_result == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004781 hdd_debug("Roaming started due to connection lost");
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304782 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004783 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304784 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 WLAN_CONTROL_PATH);
4786 break;
4787 }
4788 case eCSR_ROAM_DISASSOCIATED:
4789 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004790 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304791 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004792 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304793 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004794 adapter->roam_ho_fail = false;
4795 complete(&adapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304796
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797 /* Call to clear any MC Addr List filter applied after
4798 * successful connection.
4799 */
Jeff Johnsonba388342017-10-02 13:31:01 -07004800 hdd_disable_and_flush_mc_addr_list(adapter,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304801 pmo_peer_disconnect);
4802 qdf_ret_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08004803 hdd_dis_connect_handler(adapter, roam_info, roam_id,
4804 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004805 }
4806 break;
4807 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004808 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304809 qdf_ret_status =
Jeff Johnson29c78672019-02-26 21:05:53 -08004810 hdd_dis_connect_handler(adapter, roam_info, roam_id,
4811 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812 break;
4813 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004814 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 /*
4816 * To Do - address probable memory leak with WEP encryption upon
4817 * successful association.
4818 */
Jeff Johnson29c78672019-02-26 21:05:53 -08004819 if (eCSR_ROAM_RESULT_ASSOCIATED != roam_result) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 /* Clear saved connection information in HDD */
4821 hdd_conn_remove_connect_info(
Jeff Johnsonba388342017-10-02 13:31:01 -07004822 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004823 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304824 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004825 hdd_association_completion_handler(adapter, roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004826 roam_id, roam_status,
4827 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004829 if (roam_info)
4830 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004831#endif
4832 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004833 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004834 hdd_debug("****eCSR_ROAM_CANCELLED****");
Jeff Johnson48c05c72018-04-29 19:47:12 -07004835 /* fallthrough */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836 case eCSR_ROAM_ASSOCIATION_FAILURE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004837 qdf_ret_status = hdd_association_completion_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004838 roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004839 roam_id,
4840 roam_status,
4841 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842 break;
4843 case eCSR_ROAM_IBSS_IND:
Jeff Johnson29c78672019-02-26 21:05:53 -08004844 hdd_roam_ibss_indication_handler(adapter, roam_info, roam_id,
4845 roam_status, roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 break;
4847
4848 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304849 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07004850 roam_roam_connect_status_update_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004851 roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004852 roam_id,
4853 roam_status,
4854 roam_result);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 break;
4856
4857 case eCSR_ROAM_MIC_ERROR_IND:
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07004858 hdd_roam_mic_error_indication_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 break;
4860
4861 case eCSR_ROAM_SET_KEY_COMPLETE:
4862 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304863 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004864 hdd_roam_set_key_complete_handler(adapter, roam_info,
Jeff Johnson29c78672019-02-26 21:05:53 -08004865 roam_id, roam_status,
4866 roam_result);
4867 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
Jeff Johnson690fe952017-10-25 11:48:39 -07004868 sta_ctx->hdd_reassoc_scenario = false;
4869 hdd_debug("hdd_reassoc_scenario set to: %d, set key complete, session: %d",
4870 sta_ctx->hdd_reassoc_scenario,
Jeff Johnson1abc5662019-02-04 14:27:02 -08004871 adapter->vdev_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 }
4873 }
4874#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsond36fa332019-03-18 13:42:25 -07004875 if (roam_info)
Jeff Johnsonfd060852017-10-04 10:50:51 -07004876 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877#endif
4878 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004879
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 case eCSR_ROAM_FT_RESPONSE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004881 hdd_send_ft_event(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004882 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004883
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnson96e33512019-02-27 15:10:21 -08004885 if (eCSR_AUTH_TYPE_RSN == sta_ctx->conn_info.auth_type
Jeff Johnsond377dce2017-10-04 10:32:42 -07004886 || hdd_is_8021x_sha256_auth_type(sta_ctx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004887 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304888 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 wlan_hdd_cfg80211_pmksa_candidate_notify(
Jeff Johnsonfd060852017-10-04 10:50:51 -07004890 adapter, roam_info, 1, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 }
4892 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893
4894#ifdef FEATURE_WLAN_LFR_METRICS
4895 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4896 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304897 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004898 wlan_hdd_cfg80211_roam_metrics_preauth(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004899 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304900 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901 }
4902 break;
4903 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4904 /*
4905 * This event will notify pre-auth completion in case of success
4906 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304907 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004908 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004909 roam_info, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304910 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004911 }
4912 break;
4913 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4914 /*
4915 * This event will notify pre-auth completion incase of failure.
4916 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304917 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004918 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004919 roam_info, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304920 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 }
4922 break;
4923 case eCSR_ROAM_HANDOVER_SUCCESS:
4924 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004925 * It will be only invoked on success
4926 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304927 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004928 wlan_hdd_cfg80211_roam_metrics_handover(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004929 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304930 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 }
4932 break;
4933#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004934#ifdef WLAN_FEATURE_11W
4935 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
gaurank kathpaliaea6b5e62018-07-05 20:41:28 +05304936 if (roam_info)
4937 hdd_indicate_unprot_mgmt_frame(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004938 roam_info->nFrameLength,
4939 roam_info->pbFrames,
4940 roam_info->frameType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 break;
4942#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004943#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 case eCSR_ROAM_TSM_IE_IND:
gaurank kathpaliaea6b5e62018-07-05 20:41:28 +05304945 if (roam_info)
Jeff Johnson85ddb772019-02-02 19:01:52 -08004946 hdd_indicate_tsm_ie(adapter, roam_info->tsm_ie.tsid,
4947 roam_info->tsm_ie.state,
4948 roam_info->tsm_ie.msmt_interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 break;
4950
4951 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4952 {
4953 if (eCSR_AUTH_TYPE_CCKM_WPA ==
Jeff Johnson96e33512019-02-27 15:10:21 -08004954 sta_ctx->conn_info.auth_type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 || eCSR_AUTH_TYPE_CCKM_RSN ==
Jeff Johnson96e33512019-02-27 15:10:21 -08004956 sta_ctx->conn_info.auth_type) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004957 hdd_indicate_cckm_pre_auth(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 }
4959 break;
4960 }
4961
4962 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4963 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004964 hdd_indicate_ese_adj_ap_rep_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004965 break;
4966 }
4967
4968 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4969 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004970 hdd_indicate_ese_bcn_report_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 break;
4972 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004973#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304974 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004975 hdd_roam_channel_switch_handler(adapter, roam_info);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304976 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304977
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304978 case eCSR_ROAM_UPDATE_SCAN_RESULT:
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05304979 if ((roam_info) && (roam_info->bss_desc)) {
Abhishek Singhf05b0cb62018-02-20 18:06:13 +05304980 bss_status = wlan_hdd_inform_bss_frame(adapter,
Pragaspathi Thilagaraj96742ae2019-05-29 00:49:33 +05304981 roam_info->bss_desc);
Jeff Johnsond36fa332019-03-18 13:42:25 -07004982 if (!bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004983 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304984 else
4985 cfg80211_put_bss(
4986#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
Jeff Johnsonba388342017-10-02 13:31:01 -07004987 (WLAN_HDD_GET_CTX(adapter))->wiphy,
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304988#endif
4989 bss_status);
4990 }
4991 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004992 case eCSR_ROAM_NDP_STATUS_UPDATE:
Jeff Johnson29c78672019-02-26 21:05:53 -08004993 hdd_ndp_event_handler(adapter, roam_info, roam_id, roam_status,
4994 roam_result);
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004995 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004996 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004997 hdd_debug("Process ROAM_START from firmware");
Jeff Johnsonba388342017-10-02 13:31:01 -07004998 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304999 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005000 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005001 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005002 hdd_set_roaming_in_progress(true);
Dustin Brown76cd2932018-09-11 16:03:05 -07005003 policy_mgr_restart_opportunistic_timer(hdd_ctx->psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005004 break;
5005 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005006 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005007 hdd_napi_serialize(0);
Jeff Johnsonba388342017-10-02 13:31:01 -07005008 wlan_hdd_netif_queue_control(adapter,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005009 WLAN_WAKE_ALL_NETIF_QUEUE,
5010 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005011 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005012 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07005013 adapter->roam_ho_fail = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07005014 sta_ctx->ft_carrier_on = false;
Jeff Johnsonba388342017-10-02 13:31:01 -07005015 complete(&adapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005016 break;
5017
Padma, Santhosh Kumareb90a552018-01-16 19:41:58 +05305018 case eCSR_ROAM_SAE_COMPUTE:
5019 if (roam_info)
5020 wlan_hdd_sae_callback(adapter, roam_info);
5021 break;
5022
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05305023 case eCSR_ROAM_ROAMING_START:
5024 /*
5025 * For LFR2, Handle roaming start to remove disassociated
5026 * session
5027 */
5028 if (roaming_offload_enabled(hdd_ctx))
5029 break;
Jeff Johnson29c78672019-02-26 21:05:53 -08005030 if (roam_result == eCSR_ROAM_RESULT_NOT_ASSOCIATED) {
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05305031 hdd_debug("Decrement session of disassociated AP device_mode %d sessionId %d",
5032 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08005033 adapter->vdev_id);
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05305034 policy_mgr_decr_session_set_pcl(hdd_ctx->psoc,
5035 adapter->device_mode,
Jeff Johnson1abc5662019-02-04 14:27:02 -08005036 adapter->vdev_id);
Rajasekaran Kalidoss54a07c92018-10-31 02:57:38 +05305037 }
5038 break;
5039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040 default:
5041 break;
5042 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305043 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005044}
5045
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305046#ifdef WLAN_FEATURE_FILS_SK
5047/**
5048 * hdd_translate_fils_rsn_to_csr_auth() - Translate FILS RSN to CSR auth type
5049 * @auth_suite: auth suite
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305050 * @auth_type: pointer to enum csr_akm_type
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305051 *
5052 * Return: None
5053 */
5054static void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305055 enum csr_akm_type *auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305056{
5057 if (!memcmp(auth_suite, ccp_rsn_oui_0e, 4))
5058 *auth_type = eCSR_AUTH_TYPE_FILS_SHA256;
5059 else if (!memcmp(auth_suite, ccp_rsn_oui_0f, 4))
5060 *auth_type = eCSR_AUTH_TYPE_FILS_SHA384;
5061 else if (!memcmp(auth_suite, ccp_rsn_oui_10, 4))
5062 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA256;
5063 else if (!memcmp(auth_suite, ccp_rsn_oui_11, 4))
5064 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA384;
5065}
5066#else
5067static inline void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305068 enum csr_akm_type *auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305069{
5070}
5071#endif
5072
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305073#ifdef WLAN_FEATURE_SAE
5074/**
5075 * hdd_translate_sae_rsn_to_csr_auth() - Translate SAE RSN to CSR auth type
5076 * @auth_suite: auth suite
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305077 * @auth_type: pointer to enum csr_akm_type
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305078 *
5079 * Return: None
5080 */
5081static void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305082 enum csr_akm_type *auth_type)
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305083{
5084 if (qdf_mem_cmp(auth_suite, ccp_rsn_oui_80, 4) == 0)
5085 *auth_type = eCSR_AUTH_TYPE_SAE;
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305086 else if (qdf_mem_cmp(auth_suite, ccp_rsn_oui_90, 4) == 0)
5087 *auth_type = eCSR_AUTH_TYPE_FT_SAE;
5088
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305089}
5090#else
5091static inline void hdd_translate_sae_rsn_to_csr_auth(int8_t auth_suite[4],
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305092 enum csr_akm_type *auth_type)
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305093{
5094}
5095#endif
5096
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097/**
5098 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5099 * @auth_suite: auth suite
5100 *
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305101 * Return: enum csr_akm_type enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102 */
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305103enum csr_akm_type hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104{
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305105 enum csr_akm_type auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 /* is the auth type supported? */
5107 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5108 auth_type = eCSR_AUTH_TYPE_RSN;
5109 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5110 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005111 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 /* Check for 11r FT Authentication with PSK */
5113 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5114 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5115 /* Check for 11R FT Authentication with 802.1X */
5116 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5117 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118#ifdef FEATURE_WLAN_ESE
5119 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5120 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5121 } else
5122#endif /* FEATURE_WLAN_ESE */
5123#ifdef WLAN_FEATURE_11W
5124 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5125 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5126 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5127 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305128 } else if (memcmp(auth_suite, ccp_rsn_oui_18, 4) == 0) {
5129 auth_type = eCSR_AUTH_TYPE_OWE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005130 } else
5131#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305132 if (memcmp(auth_suite, ccp_rsn_oui_12, 4) == 0) {
5133 auth_type = eCSR_AUTH_TYPE_DPP_RSN;
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305134 } else if (memcmp(auth_suite, ccp_rsn_oui_0b, 4) == 0) {
5135 /* Check for Suite B EAP 256 */
5136 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
5137 } else if (memcmp(auth_suite, ccp_rsn_oui_0c, 4) == 0) {
5138 /* Check for Suite B EAP 384 */
5139 auth_type = eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305140 } else if (memcmp(auth_suite, ccp_rsn_oui_0d, 4) == 0) {
5141 /* Check for FT Suite B EAP 384 */
5142 auth_type = eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384;
Srinivas Dasarib328f1a2018-12-18 17:45:06 +05305143 } else if (memcmp(auth_suite, ccp_rsn_oui_13, 4) == 0) {
5144 auth_type = eCSR_AUTH_TYPE_OSEN;
Jeff Johnson109e79d2018-02-27 15:10:04 -08005145 } else {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305146 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305147 hdd_translate_sae_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 }
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305149 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 return auth_type;
5151}
5152
5153/**
5154 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5155 * @auth_suite: auth suite
5156 *
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305157 * Return: enum csr_akm_type enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 */
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305159enum csr_akm_type hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160{
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305161 enum csr_akm_type auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005162 /* is the auth type supported? */
5163 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5164 auth_type = eCSR_AUTH_TYPE_WPA;
5165 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5166 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5167 } else
5168#ifdef FEATURE_WLAN_ESE
5169 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5170 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5171 } else
5172#endif /* FEATURE_WLAN_ESE */
5173 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305174 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005176 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 return auth_type;
5178}
5179
5180/**
5181 * hdd_translate_rsn_to_csr_encryption_type() -
5182 * Translate RSN to CSR encryption type
5183 * @cipher_suite: cipher suite
5184 *
5185 * Return: eCsrEncryptionType enumeration
5186 */
5187eCsrEncryptionType
5188hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5189{
5190 eCsrEncryptionType cipher_type;
5191
5192 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5193 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05305194 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
5195 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
5196 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
5197 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5199 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5200 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5201 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5202 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5203 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5204 else if (memcmp(cipher_suite, ccp_rsn_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
5213/**
5214 * hdd_translate_wpa_to_csr_encryption_type() -
5215 * Translate WPA to CSR encryption type
5216 * @cipher_suite: cipher suite
5217 *
5218 * Return: eCsrEncryptionType enumeration
5219 */
5220eCsrEncryptionType
5221hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5222{
5223 eCsrEncryptionType cipher_type;
5224
5225 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5226 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5227 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5228 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5229 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5230 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5231 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5232 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5233 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5234 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5235 else
5236 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5237
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005238 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 return cipher_type;
5240}
5241
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305242#ifdef WLAN_FEATURE_FILS_SK
gaurank kathpalia82a1b2b2018-07-10 16:49:10 +05305243bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305244{
Jeff Johnson844eec72018-03-13 11:48:18 -07005245 struct csr_roam_profile *roam_profile;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305246
Jeff Johnson844eec72018-03-13 11:48:18 -07005247 roam_profile = hdd_roam_profile(adapter);
5248 if (roam_profile->fils_con_info)
5249 return roam_profile->fils_con_info->is_fils_connection;
Min Liuab6ed4f2018-01-09 13:13:57 +08005250
5251 return false;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305252}
5253#else
gaurank kathpalia82a1b2b2018-07-10 16:49:10 +05305254bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305255{
5256 return false;
5257}
5258#endif
5259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005260/**
5261 * hdd_process_genie() - process gen ie
Jeff Johnsonba388342017-10-02 13:31:01 -07005262 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005263 * @bssid: pointer to mac address
Jeff Johnsona376a032019-03-09 22:39:27 -08005264 * @encrypt_type: pointer to encryption type
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005265 * @mc_encrypt_type: pointer to multicast encryption type
Jeff Johnson4f1be2d2019-03-09 22:52:04 -08005266 * @auth_type: pointer to auth type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005267 *
5268 * Return: 0 on success, error number otherwise
5269 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005270static int32_t hdd_process_genie(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005271 u8 *bssid,
Jeff Johnsona376a032019-03-09 22:39:27 -08005272 eCsrEncryptionType *encrypt_type,
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005273 eCsrEncryptionType *mc_encrypt_type,
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305274 enum csr_akm_type *auth_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275#ifdef WLAN_FEATURE_11W
Jeff Johnson78cbade2019-03-10 21:59:35 -07005276 uint8_t *mfp_required, uint8_t *mfp_capable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005277#endif
5278 uint16_t gen_ie_len, uint8_t *gen_ie)
5279{
Jeff Johnsonf7187f22018-06-13 22:02:19 -07005280 mac_handle_t mac_handle = hdd_adapter_get_mac_handle(adapter);
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005281 tDot11fIERSN dot11_rsn_ie = {0};
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005282 tDot11fIEWPA dot11_wpa_ie = {0};
Jeff Johnsond062b8d2019-03-09 20:31:13 -08005283 uint8_t *rsn_ie;
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005284 uint16_t rsn_ie_len;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305285 uint32_t parse_status;
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005286#ifdef WLAN_CONV_CRYPTO_SUPPORTED
5287 uint16_t rsn_cap = 0;
5288#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005289
5290 /*
5291 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5292 * setting present flag to 0.
5293 */
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005294 memset(&dot11_wpa_ie, 0, sizeof(tDot11fIEWPA));
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005295 memset(&dot11_rsn_ie, 0, sizeof(tDot11fIERSN));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005296
5297 /* Type check */
5298 if (gen_ie[0] == DOT11F_EID_RSN) {
5299 /* Validity checks */
5300 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5301 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005302 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005303 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304 return -EINVAL;
5305 }
5306 /* Skip past the EID byte and length byte */
Jeff Johnsond062b8d2019-03-09 20:31:13 -08005307 rsn_ie = gen_ie + 2;
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005308 rsn_ie_len = gen_ie_len - 2;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005309 /* Unpack the RSN IE */
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005310 parse_status = sme_unpack_rsn_ie(mac_handle, rsn_ie, rsn_ie_len,
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005311 &dot11_rsn_ie, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305312 if (!DOT11F_SUCCEEDED(parse_status)) {
5313 hdd_err("Invalid RSN IE: parse status %d",
5314 parse_status);
5315 return -EINVAL;
5316 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05305317 hdd_debug("gp_cipher_suite_present: %d",
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005318 dot11_rsn_ie.gp_cipher_suite_present);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005319 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005320 hdd_debug("pairwise cipher suite count: %d",
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005321 dot11_rsn_ie.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005322 hdd_debug("authentication suite count: %d",
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005323 dot11_rsn_ie.akm_suite_cnt);
5324 /* dot11_rsn_ie.akm_suite_cnt */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005325 /* Just translate the FIRST one */
Jeff Johnson4f1be2d2019-03-09 22:52:04 -08005326 *auth_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 hdd_translate_rsn_to_csr_auth_type(
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005328 dot11_rsn_ie.akm_suite[0]);
5329 /* dot11_rsn_ie.pwise_cipher_suite_count */
Jeff Johnsona376a032019-03-09 22:39:27 -08005330 *encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005331 hdd_translate_rsn_to_csr_encryption_type(
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005332 dot11_rsn_ie.pwise_cipher_suites[0]);
5333 /* dot11_rsn_ie.gp_cipher_suite_count */
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005334 *mc_encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005335 hdd_translate_rsn_to_csr_encryption_type(
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005336 dot11_rsn_ie.gp_cipher_suite);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005337#ifdef WLAN_FEATURE_11W
Jeff Johnson9bf800e2019-03-10 21:58:34 -07005338 *mfp_required = (dot11_rsn_ie.RSN_Cap[0] >> 6) & 0x1;
Jeff Johnson78cbade2019-03-10 21:59:35 -07005339 *mfp_capable = csr_is_mfpc_capable(&dot11_rsn_ie);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005340#endif
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005341#ifdef WLAN_CONV_CRYPTO_SUPPORTED
Jeff Johnsonb94e6492019-03-09 22:24:42 -08005342 qdf_mem_copy(&rsn_cap, dot11_rsn_ie.RSN_Cap, sizeof(rsn_cap));
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005343 wlan_crypto_set_vdev_param(adapter->vdev,
5344 WLAN_CRYPTO_PARAM_RSN_CAP, rsn_cap);
5345#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005346 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5347 /* Validity checks */
5348 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5349 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005350 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005351 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 return -EINVAL;
5353 }
5354 /* Skip past the EID and length byte - and four byte WiFi OUI */
Jeff Johnsond062b8d2019-03-09 20:31:13 -08005355 rsn_ie = gen_ie + 2 + 4;
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005356 rsn_ie_len = gen_ie_len - (2 + 4);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005357 /* Unpack the WPA IE */
Jeff Johnson034f3c92018-11-09 10:46:21 -08005358 parse_status = dot11f_unpack_ie_wpa(MAC_CONTEXT(mac_handle),
Jeff Johnsonddd05cf2019-03-09 20:43:43 -08005359 rsn_ie, rsn_ie_len,
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005360 &dot11_wpa_ie, false);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305361 if (!DOT11F_SUCCEEDED(parse_status)) {
5362 hdd_err("Invalid WPA IE: parse status %d",
5363 parse_status);
5364 return -EINVAL;
5365 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005367 hdd_debug("WPA unicast cipher suite count: %d",
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005368 dot11_wpa_ie.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005369 hdd_debug("WPA authentication suite count: %d",
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005370 dot11_wpa_ie.auth_suite_count);
5371 /* dot11_wpa_ie.auth_suite_count */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005372 /* Just translate the FIRST one */
Jeff Johnson4f1be2d2019-03-09 22:52:04 -08005373 *auth_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005374 hdd_translate_wpa_to_csr_auth_type(
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005375 dot11_wpa_ie.auth_suites[0]);
5376 /* dot11_wpa_ie.unicast_cipher_count */
Jeff Johnsona376a032019-03-09 22:39:27 -08005377 *encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005378 hdd_translate_wpa_to_csr_encryption_type(
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005379 dot11_wpa_ie.unicast_ciphers[0]);
5380 /* dot11_wpa_ie.unicast_cipher_count */
Jeff Johnsoncdde6c32019-03-09 23:03:49 -08005381 *mc_encrypt_type =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005382 hdd_translate_wpa_to_csr_encryption_type(
Jeff Johnson6a2c0ca2019-03-09 22:08:45 -08005383 dot11_wpa_ie.multicast_cipher);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005384 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005385 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005386 return -EINVAL;
5387 }
5388 return 0;
5389}
5390
5391/**
Abhishek Singh6454ad32017-12-20 10:42:21 +05305392 * hdd_set_def_rsne_override() - set default encryption type and auth type
5393 * in profile.
5394 * @roam_profile: pointer to adapter
5395 * @auth_type: pointer to auth type
5396 *
5397 * Set default value of encryption type and auth type in profile to
5398 * search the AP using filter, as in force_rsne_override the RSNIE can be
5399 * currupt and we might not get the proper encryption type and auth type
5400 * while parsing the RSNIE.
5401 *
5402 * Return: void
5403 */
5404static void hdd_set_def_rsne_override(
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305405 struct csr_roam_profile *roam_profile, enum csr_akm_type *auth_type)
Abhishek Singh6454ad32017-12-20 10:42:21 +05305406{
5407
5408 hdd_debug("Set def values in roam profile");
5409 roam_profile->MFPCapable = roam_profile->MFPEnabled;
5410 roam_profile->EncryptionType.numEntries = 2;
5411 roam_profile->mcEncryptionType.numEntries = 2;
5412 /* Use the cipher type in the RSN IE */
5413 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
5414 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
5415 roam_profile->mcEncryptionType.encryptionType[0] =
5416 eCSR_ENCRYPT_TYPE_AES;
5417 roam_profile->mcEncryptionType.encryptionType[1] =
5418 eCSR_ENCRYPT_TYPE_TKIP;
5419 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
5420}
5421
5422/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005423 * hdd_set_genie_to_csr() - set genie to csr
Jeff Johnsonba388342017-10-02 13:31:01 -07005424 * @adapter: pointer to adapter
Jeff Johnson784efe22019-03-09 18:31:13 -08005425 * @rsn_auth_type: pointer to auth type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005426 *
5427 * Return: 0 on success, error number otherwise
5428 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005429int hdd_set_genie_to_csr(struct hdd_adapter *adapter,
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305430 enum csr_akm_type *rsn_auth_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005431{
Jeff Johnson844eec72018-03-13 11:48:18 -07005432 struct csr_roam_profile *roam_profile;
5433 uint8_t *security_ie;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005434 uint32_t status = 0;
Jeff Johnson51203af2019-03-09 18:38:09 -08005435 eCsrEncryptionType rsn_encrypt_type;
5436 eCsrEncryptionType mc_rsn_encrypt_type;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305437 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005438#ifdef WLAN_FEATURE_11W
Jeff Johnson5abc32d2019-03-10 22:01:17 -07005439 uint8_t mfp_required = 0;
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005440 uint8_t mfp_capable = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005441#endif
5442 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
Jeff Johnson844eec72018-03-13 11:48:18 -07005443
5444 roam_profile = hdd_roam_profile(adapter);
5445 security_ie = hdd_security_ie(adapter);
5446
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 /* MAC address of assoc peer */
5448 /* But, this routine is only called when we are NOT associated. */
Jeff Johnson844eec72018-03-13 11:48:18 -07005449 qdf_mem_copy(bssid, roam_profile->BSSIDs.bssid, sizeof(bssid));
5450 if (security_ie[0] == DOT11F_EID_RSN ||
5451 security_ie[0] == DOT11F_EID_WPA) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 /* continue */
5453 } else {
5454 return 0;
5455 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305456
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005457 /* The actual processing may eventually be more extensive than this. */
5458 /* Right now, just consume any PMKIDs that are sent in by the app. */
Jeff Johnsonba388342017-10-02 13:31:01 -07005459 status = hdd_process_genie(adapter, bssid,
Jeff Johnson51203af2019-03-09 18:38:09 -08005460 &rsn_encrypt_type,
5461 &mc_rsn_encrypt_type, rsn_auth_type,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462#ifdef WLAN_FEATURE_11W
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005463 &mfp_required, &mfp_capable,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005464#endif
Jeff Johnson844eec72018-03-13 11:48:18 -07005465 security_ie[1] + 2,
5466 security_ie);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468 if (status == 0) {
5469 /*
5470 * Now copy over all the security attributes
5471 * you have parsed out.
5472 */
Jeff Johnson844eec72018-03-13 11:48:18 -07005473 roam_profile->EncryptionType.numEntries = 1;
5474 roam_profile->mcEncryptionType.numEntries = 1;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005475
Jeff Johnson435e1b82017-10-07 14:13:10 -07005476 /* Use the cipher type in the RSN IE */
Jeff Johnson844eec72018-03-13 11:48:18 -07005477 roam_profile->EncryptionType.encryptionType[0] =
Jeff Johnson51203af2019-03-09 18:38:09 -08005478 rsn_encrypt_type;
Jeff Johnson844eec72018-03-13 11:48:18 -07005479 roam_profile->mcEncryptionType.encryptionType[0] =
Jeff Johnson51203af2019-03-09 18:38:09 -08005480 mc_rsn_encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005481
Jeff Johnsonba388342017-10-02 13:31:01 -07005482 if ((QDF_IBSS_MODE == adapter->device_mode) &&
Jeff Johnson51203af2019-03-09 18:38:09 -08005483 ((eCSR_ENCRYPT_TYPE_AES == mc_rsn_encrypt_type) ||
5484 (eCSR_ENCRYPT_TYPE_AES_GCMP == mc_rsn_encrypt_type) ||
5485 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mc_rsn_encrypt_type) ||
5486 (eCSR_ENCRYPT_TYPE_TKIP == mc_rsn_encrypt_type))) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005487 /*
5488 * For wpa none supplicant sends the WPA IE with unicast
5489 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5490 * multicast cipher as either AES/TKIP based on group
5491 * cipher configuration mentioned in the
5492 * wpa_supplicant.conf.
5493 */
5494
5495 /* Set the unicast cipher same as multicast cipher */
Jeff Johnson844eec72018-03-13 11:48:18 -07005496 roam_profile->EncryptionType.encryptionType[0]
Jeff Johnson51203af2019-03-09 18:38:09 -08005497 = mc_rsn_encrypt_type;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 }
5499#ifdef WLAN_FEATURE_11W
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005500 hdd_debug("mfp_required = %d, mfp_capable = %d",
5501 mfp_required, mfp_capable);
Jeff Johnson5abc32d2019-03-10 22:01:17 -07005502 roam_profile->MFPRequired = mfp_required;
Jeff Johnsonde8f7682019-03-10 22:02:29 -07005503 roam_profile->MFPCapable = mfp_capable;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005504#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005505 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Jeff Johnson51203af2019-03-09 18:38:09 -08005506 *rsn_auth_type, rsn_encrypt_type, mc_rsn_encrypt_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005507 }
Kiran Kumar Lokeree0ec5632019-01-08 17:50:04 -08005508#ifdef WLAN_CONV_CRYPTO_SUPPORTED
5509 if (QDF_STATUS_SUCCESS != wlan_set_vdev_crypto_prarams_from_ie(
5510 adapter->vdev, security_ie,
5511 (security_ie[1] + 2)))
5512 hdd_err("Failed to set the crypto params from IE");
5513#endif
Abhishek Singh6454ad32017-12-20 10:42:21 +05305514
5515 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5516 if (hdd_ctx->force_rsne_override &&
Jeff Johnson844eec72018-03-13 11:48:18 -07005517 (security_ie[0] == DOT11F_EID_RSN)) {
Abhishek Singh6454ad32017-12-20 10:42:21 +05305518 hdd_warn("Test mode enabled set def Auth and enc type. RSN IE passed in connect req: ");
5519 qdf_trace_hex_dump(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
Jeff Johnson844eec72018-03-13 11:48:18 -07005520 roam_profile->pRSNReqIE,
5521 roam_profile->nRSNReqIELength);
Abhishek Singh6454ad32017-12-20 10:42:21 +05305522
Jeff Johnson844eec72018-03-13 11:48:18 -07005523 roam_profile->force_rsne_override = true;
Abhishek Singh63781032018-02-23 14:59:22 +05305524
Jeff Johnson844eec72018-03-13 11:48:18 -07005525 hdd_debug("MFPEnabled %d", roam_profile->MFPEnabled);
Abhishek Singh63781032018-02-23 14:59:22 +05305526 /*
Jeff Johnson33142e62018-05-06 17:58:36 -07005527 * Reset MFPEnabled if testmode RSNE passed doesn't have MFPR
Abhishek Singh63781032018-02-23 14:59:22 +05305528 * or MFPC bit set
5529 */
Jeff Johnson844eec72018-03-13 11:48:18 -07005530 if (roam_profile->MFPEnabled &&
5531 !(roam_profile->MFPRequired ||
5532 roam_profile->MFPCapable)) {
Abhishek Singh63781032018-02-23 14:59:22 +05305533 hdd_debug("Reset MFPEnabled");
Jeff Johnson844eec72018-03-13 11:48:18 -07005534 roam_profile->MFPEnabled = 0;
Abhishek Singh63781032018-02-23 14:59:22 +05305535 }
Abhishek Singh6454ad32017-12-20 10:42:21 +05305536 /* If parsing failed set the def value for the roam profile */
5537 if (status)
Jeff Johnson784efe22019-03-09 18:31:13 -08005538 hdd_set_def_rsne_override(roam_profile, rsn_auth_type);
Abhishek Singh3f13a812018-01-16 14:24:44 +05305539 return 0;
Abhishek Singh6454ad32017-12-20 10:42:21 +05305540 }
Abhishek Singh3f13a812018-01-16 14:24:44 +05305541 return status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005542}
5543
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305544#ifdef WLAN_FEATURE_FILS_SK
5545/**
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305546 * hdd_check_fils_rsn_n_set_auth_type() - This API checks whether a give
5547 * auth type is fils if yes, sets it in profile.
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305548 * @rsn_auth_type: auth type
5549 *
5550 * Return: true if FILS auth else false
5551 */
Jeff Johnson61b5e982018-03-15 11:33:31 -07005552static
5553bool hdd_check_fils_rsn_n_set_auth_type(struct csr_roam_profile *roam_profile,
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305554 enum csr_akm_type rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305555{
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305556 bool is_fils_rsn = false;
5557
5558 if (!roam_profile->fils_con_info)
5559 return false;
5560
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305561 if ((rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA256) ||
5562 (rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA384) ||
5563 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA256) ||
5564 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA384))
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305565 is_fils_rsn = true;
5566 if (is_fils_rsn)
5567 roam_profile->fils_con_info->akm_type = rsn_auth_type;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305568
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305569 return is_fils_rsn;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305570}
5571#else
Jeff Johnson61b5e982018-03-15 11:33:31 -07005572static
5573bool hdd_check_fils_rsn_n_set_auth_type(struct csr_roam_profile *roam_profile,
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305574 enum csr_akm_type rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305575{
5576 return false;
5577}
5578#endif
5579
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005580/**
5581 * hdd_set_csr_auth_type() - set csr auth type
Jeff Johnsonba388342017-10-02 13:31:01 -07005582 * @adapter: pointer to adapter
Jeff Johnson784efe22019-03-09 18:31:13 -08005583 * @rsn_auth_type: auth type
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005584 *
5585 * Return: 0 on success, error number otherwise
5586 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005587int hdd_set_csr_auth_type(struct hdd_adapter *adapter,
Pragaspathi Thilagaraj7a1a08e2019-05-29 01:20:29 +05305588 enum csr_akm_type rsn_auth_type)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005589{
Jeff Johnson844eec72018-03-13 11:48:18 -07005590 struct csr_roam_profile *roam_profile;
Jeff Johnsond377dce2017-10-04 10:32:42 -07005591 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07005592 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson37ecea42018-03-18 17:54:40 -07005593 enum hdd_auth_key_mgmt key_mgmt = sta_ctx->auth_key_mgmt;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005594
Jeff Johnson844eec72018-03-13 11:48:18 -07005595 roam_profile = hdd_roam_profile(adapter);
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005596 roam_profile->AuthType.numEntries = 1;
Srinivas Dasari4bf1c932019-06-17 15:21:44 +05305597 hdd_debug("auth_type = %d rsn_auth_type %d wpa_versions %d key_mgmt : 0x%x",
Jeff Johnson784efe22019-03-09 18:31:13 -08005598 sta_ctx->conn_info.auth_type, rsn_auth_type,
Srinivas Dasari4bf1c932019-06-17 15:21:44 +05305599 sta_ctx->wpa_versions, key_mgmt);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005600
Jeff Johnson96e33512019-02-27 15:10:21 -08005601 switch (sta_ctx->conn_info.auth_type) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumarbd41baa2018-10-12 17:46:04 +05305603 case eCSR_AUTH_TYPE_AUTOSWITCH:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604#ifdef FEATURE_WLAN_ESE
5605 case eCSR_AUTH_TYPE_CCKM_WPA:
5606 case eCSR_AUTH_TYPE_CCKM_RSN:
5607#endif
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005608 if (!sta_ctx->wpa_versions) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005609
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005610 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005612 } else if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005613
5614#ifdef FEATURE_WLAN_ESE
Jeff Johnson784efe22019-03-09 18:31:13 -08005615 if ((rsn_auth_type == eCSR_AUTH_TYPE_CCKM_WPA) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005616 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5617 == HDD_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005618 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005619 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005620 eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson784efe22019-03-09 18:31:13 -08005621 } else if (rsn_auth_type == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005622 hdd_debug("Last chance to set authType to CCKM WPA.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005623 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 eCSR_AUTH_TYPE_CCKM_WPA;
5625 } else
5626#endif
Jeff Johnson37ecea42018-03-18 17:54:40 -07005627 if ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5628 == HDD_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005629 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 eCSR_AUTH_TYPE_WPA;
5631 } else
Jeff Johnson37ecea42018-03-18 17:54:40 -07005632 if ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5633 == HDD_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005634 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005635 eCSR_AUTH_TYPE_WPA_PSK;
5636 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005637 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005638 eCSR_AUTH_TYPE_WPA_NONE;
5639 }
5640 }
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005641 if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005642#ifdef FEATURE_WLAN_ESE
Jeff Johnson784efe22019-03-09 18:31:13 -08005643 if ((rsn_auth_type == eCSR_AUTH_TYPE_CCKM_RSN) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005644 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5645 == HDD_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005646 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005647 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005649 } else if (rsn_auth_type == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005650 hdd_debug("Last chance to set authType to CCKM RSN.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005651 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005652 eCSR_AUTH_TYPE_CCKM_RSN;
5653 } else
5654#endif
Jeff Johnson784efe22019-03-09 18:31:13 -08005655 if (rsn_auth_type == eCSR_AUTH_TYPE_DPP_RSN) {
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305656 roam_profile->AuthType.authType[0] =
5657 eCSR_AUTH_TYPE_DPP_RSN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005658 } else if (rsn_auth_type == eCSR_AUTH_TYPE_OSEN) {
Srinivas Dasarib328f1a2018-12-18 17:45:06 +05305659 roam_profile->AuthType.authType[0] =
5660 eCSR_AUTH_TYPE_OSEN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005661 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_FT_RSN) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005662 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5663 == HDD_AUTH_KEY_MGMT_802_1X)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005664 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005665 eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson784efe22019-03-09 18:31:13 -08005666 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_FT_RSN_PSK)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005668 ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5669 == HDD_AUTH_KEY_MGMT_PSK)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005670 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005671 eCSR_AUTH_TYPE_FT_RSN_PSK;
5672 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673
5674#ifdef WLAN_FEATURE_11W
Jeff Johnson784efe22019-03-09 18:31:13 -08005675 if (rsn_auth_type == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005676 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
Jeff Johnson784efe22019-03-09 18:31:13 -08005678 } else if (rsn_auth_type ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005679 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005680 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005681 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5682 } else
5683#endif
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005684 if (hdd_check_fils_rsn_n_set_auth_type(roam_profile,
Jeff Johnson784efe22019-03-09 18:31:13 -08005685 rsn_auth_type)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005686 roam_profile->AuthType.authType[0] =
Jeff Johnson784efe22019-03-09 18:31:13 -08005687 rsn_auth_type;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05305688 hdd_debug("updated profile authtype as %d",
Jeff Johnson784efe22019-03-09 18:31:13 -08005689 rsn_auth_type);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305690
Jeff Johnson784efe22019-03-09 18:31:13 -08005691 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_OWE) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005692 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5693 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305694 /* OWE case */
5695 roam_profile->AuthType.authType[0] =
5696 eCSR_AUTH_TYPE_OWE;
Srinivas Dasari4bf1c932019-06-17 15:21:44 +05305697 } else if (rsn_auth_type == eCSR_AUTH_TYPE_SAE) {
5698 /* SAE with open authentication case */
5699 roam_profile->AuthType.authType[0] =
5700 eCSR_AUTH_TYPE_SAE;
Jeff Johnson784efe22019-03-09 18:31:13 -08005701 } else if ((rsn_auth_type ==
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305702 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005703 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5704 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305705 /* Suite B EAP SHA 256 */
5706 roam_profile->AuthType.authType[0] =
5707 eCSR_AUTH_TYPE_SUITEB_EAP_SHA256;
Jeff Johnson784efe22019-03-09 18:31:13 -08005708 } else if ((rsn_auth_type ==
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305709 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384) &&
Jeff Johnson37ecea42018-03-18 17:54:40 -07005710 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5711 == HDD_AUTH_KEY_MGMT_802_1X)) {
Padma, Santhosh Kumare587a5c2017-12-21 12:44:46 +05305712 /* Suite B EAP SHA 384 */
5713 roam_profile->AuthType.authType[0] =
5714 eCSR_AUTH_TYPE_SUITEB_EAP_SHA384;
Jeff Johnson784efe22019-03-09 18:31:13 -08005715 } else if ((rsn_auth_type == eCSR_AUTH_TYPE_FT_SAE) &&
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305716 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X) ==
5717 HDD_AUTH_KEY_MGMT_802_1X)) {
5718 roam_profile->AuthType.authType[0] =
5719 eCSR_AUTH_TYPE_FT_SAE;
Jeff Johnson784efe22019-03-09 18:31:13 -08005720 } else if ((rsn_auth_type ==
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305721 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384) &&
5722 ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
5723 == HDD_AUTH_KEY_MGMT_802_1X)) {
5724 /* FT Suite-B EAP SHA 384 */
5725 roam_profile->AuthType.authType[0] =
5726 eCSR_AUTH_TYPE_FT_SUITEB_EAP_SHA384;
5727
Jeff Johnson37ecea42018-03-18 17:54:40 -07005728 } else if ((key_mgmt & HDD_AUTH_KEY_MGMT_802_1X)
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305729 == HDD_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005730 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731 eCSR_AUTH_TYPE_RSN;
5732 } else
Jeff Johnson37ecea42018-03-18 17:54:40 -07005733 if ((key_mgmt & HDD_AUTH_KEY_MGMT_PSK)
5734 == HDD_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005735 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005736 eCSR_AUTH_TYPE_RSN_PSK;
5737 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005738 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005739 eCSR_AUTH_TYPE_UNKNOWN;
5740 }
5741 }
5742 break;
5743
5744 case eCSR_AUTH_TYPE_SHARED_KEY:
5745
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005746 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005747 break;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305748
5749 case eCSR_AUTH_TYPE_SAE:
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305750
Jeff Johnson784efe22019-03-09 18:31:13 -08005751 if (rsn_auth_type == eCSR_AUTH_TYPE_FT_SAE)
Pragaspathi Thilagaraj96259b22019-02-15 01:08:27 +05305752 roam_profile->AuthType.authType[0] =
5753 eCSR_AUTH_TYPE_FT_SAE;
5754 else
5755 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SAE;
Padma, Santhosh Kumar07eb80b2017-07-05 16:10:06 +05305756 break;
5757
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 default:
5759
5760#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005761 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762#endif /* FEATURE_WLAN_ESE */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005763 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 break;
5765 }
5766
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005767 hdd_debug("Set roam Authtype to %d",
Jeff Johnson844eec72018-03-13 11:48:18 -07005768 roam_profile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770 return 0;
5771}
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005772
5773#ifdef WLAN_FEATURE_FILS_SK
5774static void hdd_initialize_fils_info(struct hdd_adapter *adapter)
5775{
5776 struct csr_roam_profile *roam_profile;
5777
5778 roam_profile = hdd_roam_profile(adapter);
5779 roam_profile->fils_con_info = NULL;
5780 roam_profile->hlp_ie = NULL;
5781 roam_profile->hlp_ie_len = 0;
5782}
5783#else
5784static void hdd_initialize_fils_info(struct hdd_adapter *adapter)
5785{ }
5786#endif
5787
5788void hdd_roam_profile_init(struct hdd_adapter *adapter)
5789{
5790 struct csr_roam_profile *roam_profile;
5791 uint8_t *security_ie;
5792 tSirAddie *assoc_additional_ie;
5793 struct hdd_station_ctx *sta_ctx;
5794
5795 hdd_enter();
5796
5797 roam_profile = hdd_roam_profile(adapter);
5798 qdf_mem_zero(roam_profile, sizeof(*roam_profile));
5799
5800 security_ie = hdd_security_ie(adapter);
Srinivas Girigowdacf161402019-03-14 11:37:33 -07005801 qdf_mem_zero(security_ie, WLAN_MAX_IE_LEN);
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005802
5803 assoc_additional_ie = hdd_assoc_additional_ie(adapter);
5804 qdf_mem_zero(assoc_additional_ie, sizeof(*assoc_additional_ie));
5805
5806 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
5807
5808 /* Configure the roaming profile links to SSID and bssid. */
5809 roam_profile->SSIDs.numOfSSIDs = 0;
Jeff Johnson4aea1802019-02-27 10:21:33 -08005810 roam_profile->SSIDs.SSIDList = &sta_ctx->conn_info.ssid;
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005811
5812 roam_profile->BSSIDs.numOfBSSIDs = 0;
Jeff Johnsone04b6992019-02-27 14:06:55 -08005813 roam_profile->BSSIDs.bssid = &sta_ctx->conn_info.bssid;
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005814
5815 /* Set the numOfChannels to zero to scan all the channels */
5816 roam_profile->ChannelInfo.numOfChannels = 0;
wadesong24c869a2019-07-19 17:38:59 +08005817 roam_profile->ChannelInfo.freq_list = NULL;
Jeff Johnson7f2c5912018-03-23 11:42:28 -07005818
5819 roam_profile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
5820
5821 roam_profile->phyMode = eCSR_DOT11_MODE_AUTO;
5822 sta_ctx->wpa_versions = 0;
5823
5824 /* Set the default scan mode */
5825 adapter->scan_info.scan_mode = eSIR_ACTIVE_SCAN;
5826
5827 hdd_clear_roam_profile_ie(adapter);
5828
5829 hdd_initialize_fils_info(adapter);
5830
5831 hdd_exit();
5832}