blob: 4d522ac3cc0cb4855f1805e72c5daf0512a87521 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_assoc.c
30 *
31 * WLAN Host Device Driver implementation
32 *
33 */
34
35#include "wlan_hdd_includes.h"
36#include <ani_global.h>
37#include "dot11f.h"
38#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053039#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include <linux/ieee80211.h>
41#include <linux/wireless.h>
42#include <linux/etherdevice.h>
43#include <net/cfg80211.h>
44#include "wlan_hdd_cfg80211.h"
45#include "csr_inside_api.h"
46#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_api.h"
49#include "wlan_hdd_hostapd.h"
50#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070051#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070052#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <cds_sched.h>
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -080054#include "wlan_policy_mgr_api.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053055#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070057#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070058#include <cdp_txrx_cmn.h>
59#include <cdp_txrx_flow_ctrl_legacy.h>
60#include <cdp_txrx_peer_ops.h>
61#include <cdp_txrx_misc.h>
Kabilan Kannan256e3182017-05-02 16:02:37 -070062#include <cdp_txrx_ctrl.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053063#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080064#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080065#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053066#include "wlan_pmo_ucfg_api.h"
Yu Wang000dc2f2017-05-26 17:38:48 +080067#include "wlan_hdd_tsf.h"
Naveen Rawat08db88f2017-09-08 15:07:48 -070068#include "wlan_utility.h"
Wu Gaoc02785d2017-09-07 18:17:13 +080069#include "wlan_p2p_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080070
71/* These are needed to recognize WPA and RSN suite types */
72#define HDD_WPA_OUI_SIZE 4
73#define HDD_RSN_OUI_SIZE 4
74uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
75uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
76uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
77uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
78uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
79uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
80
81#ifdef FEATURE_WLAN_ESE
82/* CCKM */
83uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
84/* CCKM */
85uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
86#endif /* FEATURE_WLAN_ESE */
87
88/* group cipher */
89uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
90
91/* WEP-40 or RSN */
92uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
93
94/* TKIP or RSN-PSK */
95uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
96
97/* Reserved */
98uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
99
100/* AES-CCMP */
101uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
102
103/* WEP-104 */
104uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
105
106#ifdef WLAN_FEATURE_11W
107/* RSN-PSK-SHA256 */
108uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
109
110/* RSN-8021X-SHA256 */
111uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
112#endif
113
Mukul Sharma05504ac2017-06-08 12:35:53 +0530114/* AES-GCMP-128 */
115uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
116
117/* AES-GCMP-256 */
118uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +0530119#ifdef WLAN_FEATURE_FILS_SK
120uint8_t ccp_rsn_oui_0e[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0E};
121uint8_t ccp_rsn_oui_0f[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0F};
122uint8_t ccp_rsn_oui_10[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x10};
123uint8_t ccp_rsn_oui_11[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x11};
124#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +0530125uint8_t ccp_rsn_oui_12[HDD_RSN_OUI_SIZE] = {0x50, 0x6F, 0x9A, 0x02};
Mukul Sharma05504ac2017-06-08 12:35:53 +0530126
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +0530127/* OWE https://tools.ietf.org/html/rfc8110 */
128uint8_t ccp_rsn_oui_18[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x12};
129
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800130/* Offset where the EID-Len-IE, start. */
131#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
132#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800133
134#define BEACON_FRAME_IES_OFFSET 12
135#define HDD_PEER_AUTHORIZE_WAIT 10
136
137/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700138 * beacon_filter_table - table of IEs used for beacon filtering
139 */
140static const int beacon_filter_table[] = {
141 SIR_MAC_DS_PARAM_SET_EID,
142 SIR_MAC_ERP_INFO_EID,
143 SIR_MAC_EDCA_PARAM_SET_EID,
144 SIR_MAC_QOS_CAPABILITY_EID,
145 SIR_MAC_HT_INFO_EID,
146 SIR_MAC_VHT_OPMODE_EID,
147 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700148#ifdef WLAN_FEATURE_11AX_BSS_COLOR
149 /*
150 * EID: 221 vendor IE is being used temporarily by 11AX
151 * bss-color-change IE till it gets any fixed number. This
152 * vendor EID needs to be replaced with bss-color-change IE
153 * number.
154 */
155 SIR_MAC_EID_VENDOR,
156#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700157};
158
159/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 * hdd_conn_set_authenticated() - set authentication state
Jeff Johnsonba388342017-10-02 13:31:01 -0700161 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800162 * @authState: authentication state
163 *
164 * This function updates the global HDD station context
165 * authentication state.
166 *
167 * Return: none
168 */
169static void
Jeff Johnsonba388342017-10-02 13:31:01 -0700170hdd_conn_set_authenticated(struct hdd_adapter *adapter, uint8_t authState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700172 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800173
174 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700175 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -0700176 sta_ctx->conn_info.uIsAuthenticated, authState);
177 sta_ctx->conn_info.uIsAuthenticated = authState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800178}
179
180/**
181 * hdd_conn_set_connection_state() - set connection state
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700182 * @adapter: pointer to the adapter
183 * @conn_state: connection state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800184 *
185 * This function updates the global HDD station context connection state.
186 *
187 * Return: none
188 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700189void hdd_conn_set_connection_state(struct hdd_adapter *adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700190 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800191{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700192 struct hdd_station_ctx *hdd_sta_ctx =
193 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800194
195 /* save the new connection state */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700196 hdd_debug("%pS Changed conn state from old:%d to new:%d for dev %s",
197 (void *)_RET_IP_, hdd_sta_ctx->conn_info.connState,
198 conn_state, adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800199
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700200 hdd_tsf_notify_wlan_state_change(adapter,
201 hdd_sta_ctx->conn_info.connState,
202 conn_state);
203 hdd_sta_ctx->conn_info.connState = conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204}
205
206/**
207 * hdd_conn_get_connection_state() - get connection state
Jeff Johnsonba388342017-10-02 13:31:01 -0700208 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800209 * @pConnState: pointer to connection state
210 *
211 * This function updates the global HDD station context connection state.
212 *
213 * Return: true if (Infra Associated or IBSS Connected)
214 * and sets output parameter pConnState;
215 * false otherwise
216 */
Jeff Johnson435e1b82017-10-07 14:13:10 -0700217static inline bool
218hdd_conn_get_connection_state(struct hdd_station_ctx *sta_ctx,
219 eConnectionState *pConnState)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800220{
221 bool fConnected = false;
222 eConnectionState connState;
223
224 /* get the connection state. */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700225 connState = sta_ctx->conn_info.connState;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800226
227 if (eConnectionState_Associated == connState ||
228 eConnectionState_IbssConnected == connState ||
229 eConnectionState_IbssDisconnected == connState) {
230 fConnected = true;
231 }
232
233 if (pConnState)
234 *pConnState = connState;
235
236 return fConnected;
237}
238
239/**
240 * hdd_is_connecting() - Function to check connection progress
241 * @hdd_sta_ctx: pointer to global HDD Station context
242 *
243 * Return: true if connecting, false otherwise
244 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700245bool hdd_is_connecting(struct hdd_station_ctx *hdd_sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800246{
247 return hdd_sta_ctx->conn_info.connState ==
248 eConnectionState_Connecting;
249}
250
251/**
252 * hdd_conn_is_connected() - Function to check connection status
Jeff Johnsond377dce2017-10-04 10:32:42 -0700253 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800254 *
255 * Return: false if any errors encountered, true otherwise
256 */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700257bool hdd_conn_is_connected(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700259 return hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800260}
261
262/**
263 * hdd_conn_get_connected_band() - get current connection radio band
Jeff Johnsond377dce2017-10-04 10:32:42 -0700264 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800265 *
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800266 * Return: BAND_2G or BAND_5G based on current AP connection
267 * BAND_ALL if not connected
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700269enum band_info hdd_conn_get_connected_band(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270{
271 uint8_t staChannel = 0;
272
Jeff Johnsond377dce2017-10-04 10:32:42 -0700273 if (eConnectionState_Associated == sta_ctx->conn_info.connState)
274 staChannel = sta_ctx->conn_info.operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275
276 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700277 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800278 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700279 return BAND_5G;
Varun Reddy Yeturua48bc412017-11-17 15:33:35 -0800280 else /* If station is not connected return as BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700281 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800282}
283
284/**
285 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
Jeff Johnsond377dce2017-10-04 10:32:42 -0700286 * @sta_ctx: pointer to global HDD Station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800287 * @pConnectedCipherAlgo: pointer to connected cipher algo
288 *
289 * Return: false if any errors encountered, true otherwise
290 */
291static inline bool
Jeff Johnsond377dce2017-10-04 10:32:42 -0700292hdd_conn_get_connected_cipher_algo(struct hdd_station_ctx *sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800293 eCsrEncryptionType *pConnectedCipherAlgo)
294{
295 bool fConnected = false;
296
Jeff Johnsond377dce2017-10-04 10:32:42 -0700297 fConnected = hdd_conn_get_connection_state(sta_ctx, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800298
299 if (pConnectedCipherAlgo)
Jeff Johnsond377dce2017-10-04 10:32:42 -0700300 *pConnectedCipherAlgo = sta_ctx->conn_info.ucEncryptionType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800301
302 return fConnected;
303}
304
305/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700306 * hdd_remove_beacon_filter() - remove beacon filter
307 * @adapter: Pointer to the hdd adapter
308 *
309 * Return: 0 on success and errno on failure
310 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700311static int hdd_remove_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700312{
313 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700314 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700315
316 status = sme_remove_beacon_filter(hdd_ctx->hHal,
Jeff Johnson1b780e42017-10-31 14:11:45 -0700317 adapter->session_id);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700318 if (!QDF_IS_STATUS_SUCCESS(status)) {
319 hdd_err("sme_remove_beacon_filter() failed");
320 return -EFAULT;
321 }
322
323 return 0;
324}
325
326/**
327 * hdd_add_beacon_filter() - add beacon filter
328 * @adapter: Pointer to the hdd adapter
329 *
330 * Return: 0 on success and errno on failure
331 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700332static int hdd_add_beacon_filter(struct hdd_adapter *adapter)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700333{
334 int i;
335 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
336 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -0700337 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700338
339 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530340 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700341 (unsigned long int *)ie_map);
342
343 status = sme_add_beacon_filter(hdd_ctx->hHal,
Jeff Johnson1b780e42017-10-31 14:11:45 -0700344 adapter->session_id, ie_map);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700345 if (!QDF_IS_STATUS_SUCCESS(status)) {
346 hdd_err("sme_add_beacon_filter() failed");
347 return -EFAULT;
348 }
349 return 0;
350}
351
352/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530353 * hdd_copy_vht_caps()- copy vht caps info from roam info to
354 * hdd station context.
355 * @hdd_sta_ctx: pointer to hdd station context
356 * @roam_info: pointer to roam info
357 *
358 * Return: None
359 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700360static void hdd_copy_ht_caps(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800361 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530362{
363 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
364 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
365 uint32_t i, temp_ht_cap;
366
367 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
368
369 if (roam_ht_cap->advCodingCap)
370 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
371 if (roam_ht_cap->supportedChannelWidthSet)
372 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
373 temp_ht_cap = roam_ht_cap->mimoPowerSave &
374 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
375 if (temp_ht_cap)
376 hdd_ht_cap->cap_info |=
377 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
378 if (roam_ht_cap->greenField)
379 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
380 if (roam_ht_cap->shortGI20MHz)
381 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
382 if (roam_ht_cap->shortGI40MHz)
383 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
384 if (roam_ht_cap->txSTBC)
385 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
386 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
387 IEEE80211_HT_CAP_RX_STBC_SHIFT);
388 if (temp_ht_cap)
389 hdd_ht_cap->cap_info |=
390 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
391 if (roam_ht_cap->delayedBA)
392 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
393 if (roam_ht_cap->maximalAMSDUsize)
394 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
395 if (roam_ht_cap->dsssCckMode40MHz)
396 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
397 if (roam_ht_cap->psmp)
398 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
399 if (roam_ht_cap->stbcControlFrame)
400 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
401 if (roam_ht_cap->lsigTXOPProtection)
402 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
403
404 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
405 if (roam_ht_cap->maxRxAMPDUFactor)
406 hdd_ht_cap->ampdu_params_info |=
407 IEEE80211_HT_AMPDU_PARM_FACTOR;
408 temp_ht_cap = roam_ht_cap->mpduDensity &
409 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
410 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
411 if (temp_ht_cap)
412 hdd_ht_cap->ampdu_params_info |=
413 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
414
415 /* 802.11n HT extended capabilities masks */
416 if (roam_ht_cap->pco)
417 hdd_ht_cap->extended_ht_cap_info |=
418 IEEE80211_HT_EXT_CAP_PCO;
419 temp_ht_cap = roam_ht_cap->transitionTime &
420 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
421 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
422 if (temp_ht_cap)
423 hdd_ht_cap->extended_ht_cap_info |=
424 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
425 temp_ht_cap = roam_ht_cap->mcsFeedback &
426 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
427 if (temp_ht_cap)
428 hdd_ht_cap->extended_ht_cap_info |=
429 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
430
431 /* tx_bf_cap_info capabilities */
432 if (roam_ht_cap->txBF)
433 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
434 if (roam_ht_cap->rxStaggeredSounding)
435 hdd_ht_cap->tx_BF_cap_info |=
436 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
437 if (roam_ht_cap->txStaggeredSounding)
438 hdd_ht_cap->tx_BF_cap_info |=
439 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
440 if (roam_ht_cap->rxZLF)
441 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
442 if (roam_ht_cap->txZLF)
443 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
444 if (roam_ht_cap->implicitTxBF)
445 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
446 temp_ht_cap = roam_ht_cap->calibration &
447 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
448 if (temp_ht_cap)
449 hdd_ht_cap->tx_BF_cap_info |=
450 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
451 if (roam_ht_cap->explicitCSITxBF)
452 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
453 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
454 hdd_ht_cap->tx_BF_cap_info |=
455 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
456 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
457 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
458 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
459 if (temp_ht_cap)
460 hdd_ht_cap->tx_BF_cap_info |=
461 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
462 temp_ht_cap =
463 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
464 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
465 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
466 if (temp_ht_cap)
467 hdd_ht_cap->tx_BF_cap_info |=
468 temp_ht_cap <<
469 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
470 temp_ht_cap =
471 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
472 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
473 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
474 if (temp_ht_cap)
475 hdd_ht_cap->tx_BF_cap_info |=
476 temp_ht_cap <<
477 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
478 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
479 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
480 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
481 if (temp_ht_cap)
482 hdd_ht_cap->tx_BF_cap_info |=
483 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
484 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
485 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
486 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
487 if (temp_ht_cap)
488 hdd_ht_cap->tx_BF_cap_info |=
489 temp_ht_cap <<
490 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
491 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
492 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
493 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
494 if (temp_ht_cap)
495 hdd_ht_cap->tx_BF_cap_info |=
496 temp_ht_cap <<
497 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
498
499 /* antenna selection */
500 if (roam_ht_cap->antennaSelection)
501 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
502 if (roam_ht_cap->explicitCSIFeedbackTx)
503 hdd_ht_cap->antenna_selection_info |=
504 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
505 if (roam_ht_cap->antennaIndicesFeedbackTx)
506 hdd_ht_cap->antenna_selection_info |=
507 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
508 if (roam_ht_cap->explicitCSIFeedback)
509 hdd_ht_cap->antenna_selection_info |=
510 ANTENNA_SEL_INFO_EXP_CSI_FB;
511 if (roam_ht_cap->antennaIndicesFeedback)
512 hdd_ht_cap->antenna_selection_info |=
513 ANTENNA_SEL_INFO_ANT_ID_FB;
514 if (roam_ht_cap->rxAS)
515 hdd_ht_cap->antenna_selection_info |=
516 ANTENNA_SEL_INFO_RX_AS;
517 if (roam_ht_cap->txSoundingPPDUs)
518 hdd_ht_cap->antenna_selection_info |=
519 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
520
521 /* mcs data rate */
522 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
523 hdd_ht_cap->mcs.rx_mask[i] =
524 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800525 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530526 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
527 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800528 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530529 roam_ht_cap->supportedMCSSet[12];
530}
531
532#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
533#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
534#define VHT_CAP_RXSTBC_MASK_SHIFT 8
535#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
536#define VHT_CAP_BEAMFORMEE_STS_MASK \
537 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
538#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
539#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
540 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
541#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
542#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
543 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
544#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
545
546/**
547 * hdd_copy_ht_caps()- copy ht caps info from roam info to
548 * hdd station context.
549 * @hdd_sta_ctx: pointer to hdd station context
550 * @roam_info: pointer to roam info
551 *
552 * Return: None
553 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700554static void hdd_copy_vht_caps(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800555 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530556{
557 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
558 struct ieee80211_vht_cap *hdd_vht_cap =
559 &hdd_sta_ctx->conn_info.vht_caps;
560 uint32_t temp_vht_cap;
561
562 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
563
564 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
565 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
566 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
567 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
568 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800569 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530570 if (roam_vht_cap->supportedChannelWidthSet &
571 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
572 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
573 hdd_vht_cap->vht_cap_info |=
574 temp_vht_cap <<
575 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
576 if (roam_vht_cap->supportedChannelWidthSet &
577 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
578 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
579 hdd_vht_cap->vht_cap_info |=
580 temp_vht_cap <<
581 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800582 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530583 if (roam_vht_cap->ldpcCodingCap)
584 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
585 if (roam_vht_cap->shortGI80MHz)
586 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
587 if (roam_vht_cap->shortGI160and80plus80MHz)
588 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
589 if (roam_vht_cap->txSTBC)
590 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
591 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
592 VHT_CAP_RXSTBC_MASK_SHIFT);
593 if (temp_vht_cap)
594 hdd_vht_cap->vht_cap_info |=
595 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
596 if (roam_vht_cap->suBeamFormerCap)
597 hdd_vht_cap->vht_cap_info |=
598 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
599 if (roam_vht_cap->suBeamformeeCap)
600 hdd_vht_cap->vht_cap_info |=
601 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
602 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
603 (VHT_CAP_BEAMFORMEE_STS_MASK);
604 if (temp_vht_cap)
605 hdd_vht_cap->vht_cap_info |=
606 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
607 temp_vht_cap = roam_vht_cap->numSoundingDim &
608 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
609 if (temp_vht_cap)
610 hdd_vht_cap->vht_cap_info |=
611 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
612 if (roam_vht_cap->muBeamformerCap)
613 hdd_vht_cap->vht_cap_info |=
614 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
615 if (roam_vht_cap->muBeamformeeCap)
616 hdd_vht_cap->vht_cap_info |=
617 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
618 if (roam_vht_cap->vhtTXOPPS)
619 hdd_vht_cap->vht_cap_info |=
620 IEEE80211_VHT_CAP_VHT_TXOP_PS;
621 if (roam_vht_cap->htcVHTCap)
622 hdd_vht_cap->vht_cap_info |=
623 IEEE80211_VHT_CAP_HTC_VHT;
624 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
625 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
626 if (temp_vht_cap)
627 hdd_vht_cap->vht_cap_info |=
628 temp_vht_cap <<
629 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
630 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
631 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
632 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
633 if (temp_vht_cap)
634 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
635 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
636 if (roam_vht_cap->rxAntPattern)
637 hdd_vht_cap->vht_cap_info |=
638 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
639 if (roam_vht_cap->txAntPattern)
640 hdd_vht_cap->vht_cap_info |=
641 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
642 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
643 hdd_vht_cap->supp_mcs.rx_highest =
644 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
645 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
646 hdd_vht_cap->supp_mcs.tx_highest =
647 ((uint16_t)roam_vht_cap->txSupDataRate);
648}
649
650/* ht param */
651#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
652#define HT_PARAM_SERVICE_INT_GRAN 0xe0
653#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
654
655/* operatinon mode */
656#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
657
658/* stbc_param */
659#define HT_STBC_PARAM_MCS 0x007f
660
661/**
662 * hdd_copy_ht_operation()- copy HT operation element from roam info to
663 * hdd station context.
664 * @hdd_sta_ctx: pointer to hdd station context
665 * @roam_info: pointer to roam info
666 *
667 * Return: None
668 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700669static void hdd_copy_ht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800670 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530671{
672 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
673 struct ieee80211_ht_operation *hdd_ht_ops =
674 &hdd_sta_ctx->conn_info.ht_operation;
675 uint32_t i, temp_ht_ops;
676
677 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
678
679 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
680
681 /* HT_PARAMS */
682 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
683 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
684 if (temp_ht_ops)
685 hdd_ht_ops->ht_param |= temp_ht_ops;
686 else
687 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
688 if (roam_ht_ops->recommendedTxWidthSet)
689 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
690 if (roam_ht_ops->rifsMode)
691 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
692 if (roam_ht_ops->controlledAccessOnly)
693 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
694 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
695 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
696 if (temp_ht_ops)
697 hdd_ht_ops->ht_param |= temp_ht_ops <<
698 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
699
700 /* operation mode */
701 temp_ht_ops = roam_ht_ops->opMode &
702 IEEE80211_HT_OP_MODE_PROTECTION;
703 switch (temp_ht_ops) {
704 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
705 hdd_ht_ops->operation_mode |=
706 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
707 break;
708 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
709 hdd_ht_ops->operation_mode |=
710 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
711 break;
712 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
713 hdd_ht_ops->operation_mode |=
714 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
715 break;
716 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
717 default:
718 hdd_ht_ops->operation_mode |=
719 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
720 }
721 if (roam_ht_ops->nonGFDevicesPresent)
722 hdd_ht_ops->operation_mode |=
723 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
724 if (roam_ht_ops->transmitBurstLimit)
725 hdd_ht_ops->operation_mode |=
726 HT_OP_MODE_TX_BURST_LIMIT;
727 if (roam_ht_ops->obssNonHTStaPresent)
728 hdd_ht_ops->operation_mode |=
729 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
730
731 /* stbc_param */
732 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
733 HT_STBC_PARAM_MCS;
734 if (temp_ht_ops)
735 hdd_ht_ops->stbc_param |= temp_ht_ops;
736 if (roam_ht_ops->dualCTSProtection)
737 hdd_ht_ops->stbc_param |=
738 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
739 if (roam_ht_ops->secondaryBeacon)
740 hdd_ht_ops->stbc_param |=
741 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
742 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
743 hdd_ht_ops->stbc_param |=
744 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
745 if (roam_ht_ops->pcoActive)
746 hdd_ht_ops->stbc_param |=
747 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
748 if (roam_ht_ops->pcoPhase)
749 hdd_ht_ops->stbc_param |=
750 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
751
752 /* basic MCs set */
753 for (i = 0; i < 16; ++i)
754 hdd_ht_ops->basic_set[i] =
755 roam_ht_ops->basicMCSSet[i];
756}
757
Dustin Brown8aef46d2017-08-10 15:44:50 -0700758#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
759static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
760 tDot11fIEVHTOperation *roam_ops)
761{
762 ieee_ops->center_freq_seg0_idx = roam_ops->chanCenterFreqSeg1;
763 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg2;
764}
765#else
766static void hdd_copy_vht_center_freq(struct ieee80211_vht_operation *ieee_ops,
767 tDot11fIEVHTOperation *roam_ops)
768{
769 ieee_ops->center_freq_seg1_idx = roam_ops->chanCenterFreqSeg1;
770 ieee_ops->center_freq_seg2_idx = roam_ops->chanCenterFreqSeg2;
771}
772#endif /* KERNEL_VERSION(4, 12, 0) */
773
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530774/**
775 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
776 * hdd station context.
777 * @hdd_sta_ctx: pointer to hdd station context
778 * @roam_info: pointer to roam info
779 *
780 * Return: None
781 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -0700782static void hdd_copy_vht_operation(struct hdd_station_ctx *hdd_sta_ctx,
Jeff Johnson172237b2017-11-07 15:32:59 -0800783 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530784{
785 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
786 struct ieee80211_vht_operation *hdd_vht_ops =
787 &hdd_sta_ctx->conn_info.vht_operation;
788
789 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
790
791 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
Dustin Brown8aef46d2017-08-10 15:44:50 -0700792 hdd_copy_vht_center_freq(hdd_vht_ops, roam_vht_ops);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530793 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
794}
795
796
797/**
798 * hdd_save_bss_info() - save connection info in hdd sta ctx
799 * @adapter: Pointer to adapter
800 * @roam_info: pointer to roam info
801 *
802 * Return: None
803 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -0700804static void hdd_save_bss_info(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -0800805 struct csr_roam_info *roam_info)
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530806{
Jeff Johnson435e1b82017-10-07 14:13:10 -0700807 struct hdd_station_ctx *hdd_sta_ctx =
808 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530809
810 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
811 hdd_sta_ctx->conn_info.operationChannel);
812 if (roam_info->vht_caps.present) {
813 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
814 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
815 } else {
816 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
817 }
818 if (roam_info->ht_caps.present) {
819 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
820 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
821 } else {
822 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
823 }
824 if (roam_info->reassoc)
825 hdd_sta_ctx->conn_info.roam_count++;
826 if (roam_info->hs20vendor_ie.present) {
827 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
828 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
829 &roam_info->hs20vendor_ie,
830 sizeof(roam_info->hs20vendor_ie));
831 } else {
832 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
833 }
834 if (roam_info->ht_operation.present) {
835 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
836 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
837 } else {
838 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
839 }
840 if (roam_info->vht_operation.present) {
841 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
842 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
843 } else {
844 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
845 }
846}
847
848/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800849 * hdd_conn_save_connect_info() - save current connection information
Jeff Johnsonba388342017-10-02 13:31:01 -0700850 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -0700851 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 * @eBssType: bss type
853 *
854 * Return: none
855 */
856static void
Jeff Johnson172237b2017-11-07 15:32:59 -0800857hdd_conn_save_connect_info(struct hdd_adapter *adapter,
858 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800859 eCsrRoamBssType eBssType)
860{
Jeff Johnsond377dce2017-10-04 10:32:42 -0700861 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
863
Jeff Johnsonfd060852017-10-04 10:50:51 -0700864 QDF_ASSERT(roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800865
Jeff Johnsonfd060852017-10-04 10:50:51 -0700866 if (roam_info) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800867 /* Save the BSSID for the connection */
868 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Jeff Johnsonfd060852017-10-04 10:50:51 -0700869 QDF_ASSERT(roam_info->pBssDesc);
Jeff Johnsond377dce2017-10-04 10:32:42 -0700870 qdf_copy_macaddr(&sta_ctx->conn_info.bssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700871 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800872
873 /*
874 * Save the Station ID for this station from
875 * the 'Roam Info'. For IBSS mode, staId is
876 * assigned in NEW_PEER_IND. For reassoc,
877 * the staID doesn't change and it may be invalid
878 * in this structure so no change here.
879 */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700880 if (!roam_info->fReassocReq) {
Jeff Johnsond377dce2017-10-04 10:32:42 -0700881 sta_ctx->conn_info.staId[0] =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700882 roam_info->staId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 }
884 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Jeff Johnsond377dce2017-10-04 10:32:42 -0700885 qdf_copy_macaddr(&sta_ctx->conn_info.bssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700886 &roam_info->bssid);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 } else {
888 /*
889 * can't happen. We need a valid IBSS or Infra setting
890 * in the BSSDescription or we can't function.
891 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530892 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800893 }
894
895 /* notify WMM */
Jeff Johnsonfd060852017-10-04 10:50:51 -0700896 hdd_wmm_connect(adapter, roam_info, eBssType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800897
Jeff Johnsonfd060852017-10-04 10:50:51 -0700898 if (!roam_info->u.pConnectedProfile) {
899 QDF_ASSERT(roam_info->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800900 } else {
901 /* Get Multicast Encryption Type */
902 encryptType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700903 roam_info->u.pConnectedProfile->mcEncryptionType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700904 sta_ctx->conn_info.mcEncryptionType = encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 /* Get Unicast Encryption Type */
906 encryptType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700907 roam_info->u.pConnectedProfile->EncryptionType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700908 sta_ctx->conn_info.ucEncryptionType = encryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800909
Jeff Johnsond377dce2017-10-04 10:32:42 -0700910 sta_ctx->conn_info.authType =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700911 roam_info->u.pConnectedProfile->AuthType;
Jeff Johnsond377dce2017-10-04 10:32:42 -0700912 sta_ctx->conn_info.last_auth_type =
913 sta_ctx->conn_info.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800914
Jeff Johnsond377dce2017-10-04 10:32:42 -0700915 sta_ctx->conn_info.operationChannel =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700916 roam_info->u.pConnectedProfile->operationChannel;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800917
918 /* Save the ssid for the connection */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700919 qdf_mem_copy(&sta_ctx->conn_info.SSID.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700920 &roam_info->u.pConnectedProfile->SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 sizeof(tSirMacSSid));
Jeff Johnsond377dce2017-10-04 10:32:42 -0700922 qdf_mem_copy(&sta_ctx->conn_info.last_ssid.SSID,
Jeff Johnsonfd060852017-10-04 10:50:51 -0700923 &roam_info->u.pConnectedProfile->SSID,
Zhang Qian32fd43e2017-08-24 18:36:28 +0800924 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800925
926 /* Save dot11mode in which STA associated to AP */
Jeff Johnsond377dce2017-10-04 10:32:42 -0700927 sta_ctx->conn_info.dot11Mode =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700928 roam_info->u.pConnectedProfile->dot11Mode;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929
Jeff Johnsond377dce2017-10-04 10:32:42 -0700930 sta_ctx->conn_info.proxyARPService =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700931 roam_info->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530932
Jeff Johnsonfd060852017-10-04 10:50:51 -0700933 sta_ctx->conn_info.nss = roam_info->chan_info.nss;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530934
Jeff Johnsond377dce2017-10-04 10:32:42 -0700935 sta_ctx->conn_info.rate_flags =
Jeff Johnsonfd060852017-10-04 10:50:51 -0700936 roam_info->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937 }
Jeff Johnsonfd060852017-10-04 10:50:51 -0700938 hdd_save_bss_info(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800940}
941
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800942/**
943 * hdd_send_ft_assoc_response() - send fast transition assoc response
944 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -0700945 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 * @pCsrRoamInfo: pointer to roam info
947 *
948 * Send the 11R key information to the supplicant. Only then can the supplicant
949 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
950 * for the same purpose.)
951 *
952 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
953 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
954 * This is the Assoc Response.
955 *
956 * Return: none
957 */
958static void
959hdd_send_ft_assoc_response(struct net_device *dev,
Jeff Johnsonba388342017-10-02 13:31:01 -0700960 struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -0800961 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962{
963 union iwreq_data wrqu;
964 char *buff;
965 unsigned int len = 0;
966 u8 *pFTAssocRsp = NULL;
967
968 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700969 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 return;
971 }
972
973 pFTAssocRsp =
974 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
975 pCsrRoamInfo->nAssocReqLength);
976 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700977 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800978 return;
979 }
980 /* pFTAssocRsp needs to point to the IEs */
981 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700982 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700983 (unsigned int)pFTAssocRsp[0],
984 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800985
986 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700987 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800988 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700989 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800990 return;
991 }
992 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
993 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
994 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800995 memcpy(buff, pFTAssocRsp, len);
996 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
997
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700998 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001000
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001/**
1002 * hdd_send_ft_event() - send fast transition event
Jeff Johnsonba388342017-10-02 13:31:01 -07001003 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 *
1005 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
1006 * FT events to the supplicant. At the reception of Auth2 we send the RIC
1007 * followed by the auth response IEs to the supplicant.
1008 * Once both are received in the supplicant, an FT event is generated
1009 * to the supplicant.
1010 *
1011 * Return: none
1012 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001013static void hdd_send_ft_event(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014{
1015 uint16_t auth_resp_len = 0;
1016 uint32_t ric_ies_length = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001017 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018
1019#if defined(KERNEL_SUPPORT_11R_CFG80211)
1020 struct cfg80211_ft_event_params ftEvent;
1021 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1022 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
Jeff Johnsonba388342017-10-02 13:31:01 -07001023 struct net_device *dev = adapter->dev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024#else
1025 char *buff;
1026 union iwreq_data wrqu;
1027 uint16_t str_len;
1028#endif
1029
1030#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301031 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1032 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033
Jeff Johnson1b780e42017-10-31 14:11:45 -07001034 sme_get_rici_es(hdd_ctx->hHal, adapter->session_id, (u8 *) ricIe,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001036 if (ric_ies_length == 0)
1037 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038
1039 ftEvent.ric_ies = ricIe;
1040 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001041 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042
Jeff Johnson1b780e42017-10-31 14:11:45 -07001043 sme_get_ft_pre_auth_response(hdd_ctx->hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1045 &auth_resp_len);
1046
1047 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001048 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 return;
1050 }
1051
Jeff Johnson1b780e42017-10-31 14:11:45 -07001052 sme_set_ft_pre_auth_state(hdd_ctx->hHal, adapter->session_id, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053
1054 ftEvent.target_ap = ftIe;
1055
Anurag Chouhan6d760662016-02-20 16:05:43 +05301056 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1057 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001059 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1060 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1061 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001062 ftEvent.target_ap[0], ftEvent.target_ap[1],
1063 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1064 ftEvent.target_ap[5]);
1065
1066 (void)cfg80211_ft_event(dev, &ftEvent);
1067
1068#else
1069 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001070 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001071 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001072 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073 return;
1074 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001075
1076 /* Sme needs to send the RIC IEs first */
1077 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Jeff Johnson1b780e42017-10-31 14:11:45 -07001078 sme_get_rici_es(hdd_ctx->hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001079 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1080 &ric_ies_length);
1081 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001082 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 } else {
1084 wrqu.data.length = str_len + ric_ies_length;
Jeff Johnsonba388342017-10-02 13:31:01 -07001085 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001086 }
1087
1088 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301089 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Jeff Johnson1b780e42017-10-31 14:11:45 -07001091 sme_get_ft_pre_auth_response(hdd_ctx->hHal, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001092 (u8 *) &buff[str_len],
1093 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1094
1095 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001096 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001097 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001098 return;
1099 }
1100
1101 wrqu.data.length = str_len + auth_resp_len;
Jeff Johnsonba388342017-10-02 13:31:01 -07001102 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001103
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001104 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001105#endif
1106}
1107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108#ifdef FEATURE_WLAN_ESE
1109/**
1110 * hdd_send_new_ap_channel_info() - send new ap channel info
1111 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07001112 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 * @pCsrRoamInfo: pointer to roam info
1114 *
1115 * Send the ESE required "new AP Channel info" to the supplicant.
1116 * (This keeps the supplicant "up to date" on the current channel.)
1117 *
1118 * The current (new AP) channel information is passed in.
1119 *
1120 * Return: none
1121 */
1122static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07001123hdd_send_new_ap_channel_info(struct net_device *dev,
1124 struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001125 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126{
1127 union iwreq_data wrqu;
Jeff Johnson4ba73cb2017-10-06 11:12:33 -07001128 struct bss_description *descriptor = pCsrRoamInfo->pBssDesc;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001129
1130 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001131 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132 return;
1133 }
1134 /*
1135 * Send the Channel event, the supplicant needs this to generate
1136 * the Adjacent AP report.
1137 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001138 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001139 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001140 memset(&wrqu, '\0', sizeof(wrqu));
1141 wrqu.freq.m = descriptor->channelId;
1142 wrqu.freq.e = 0;
1143 wrqu.freq.i = 0;
Jeff Johnsonba388342017-10-02 13:31:01 -07001144 wireless_send_event(adapter->dev, SIOCGIWFREQ, &wrqu, NULL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145}
1146
1147#endif /* FEATURE_WLAN_ESE */
1148
1149/**
1150 * hdd_send_update_beacon_ies_event() - send update beacons ie event
Jeff Johnsonba388342017-10-02 13:31:01 -07001151 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 * @pCsrRoamInfo: pointer to roam info
1153 *
1154 * Return: none
1155 */
1156static void
Jeff Johnsonba388342017-10-02 13:31:01 -07001157hdd_send_update_beacon_ies_event(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001158 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159{
1160 union iwreq_data wrqu;
Jeff Johnson04e00082017-10-04 12:15:58 -07001161 u8 *beacon_ies;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001162 u8 currentLen = 0;
1163 char *buff;
1164 int totalIeLen = 0, currentOffset = 0, strLen;
1165
1166 memset(&wrqu, '\0', sizeof(wrqu));
1167
1168 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001169 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001170 return;
1171 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001172 beacon_ies = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1173 if (beacon_ies == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001174 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001175 return;
1176 }
Jeff Johnson04e00082017-10-04 12:15:58 -07001177 /* beacon_ies needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001178 hdd_debug("Beacon IEs is now at %02x%02x",
Jeff Johnson04e00082017-10-04 12:15:58 -07001179 (unsigned int)beacon_ies[0],
1180 (unsigned int)beacon_ies[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001181 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001182 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183
1184 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001185 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001187 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001188 return;
1189 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190
1191 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1192 currentLen = strLen + 1;
1193
1194 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1195 do {
1196 /*
1197 * If the beacon size exceeds max CUSTOM event size, break it
1198 * into chunks of CUSTOM event max size and send it to
1199 * supplicant. Changes are done in supplicant to handle this.
1200 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301201 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001202 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301203 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Jeff Johnson04e00082017-10-04 12:15:58 -07001204 qdf_mem_copy(&buff[strLen + 1], beacon_ies + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205 currentLen);
1206 currentOffset += currentLen;
1207 totalIeLen -= currentLen;
1208 wrqu.data.length = strLen + 1 + currentLen;
1209 if (totalIeLen)
1210 buff[strLen] = 1; /* more chunks pending */
1211 else
1212 buff[strLen] = 0; /* last chunk */
1213
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001214 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001215 currentLen);
Jeff Johnsonba388342017-10-02 13:31:01 -07001216 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 } while (totalIeLen > 0);
1218
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001219 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220}
1221
1222/**
1223 * hdd_send_association_event() - send association event
1224 * @dev: pointer to net device
1225 * @pCsrRoamInfo: pointer to roam info
1226 *
1227 * Return: none
1228 */
1229static void hdd_send_association_event(struct net_device *dev,
Jeff Johnson172237b2017-11-07 15:32:59 -08001230 struct csr_roam_info *pCsrRoamInfo)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001231{
Rajeev Kumar78427682017-01-13 16:13:11 -08001232 int ret;
Jeff Johnsonba388342017-10-02 13:31:01 -07001233 struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
1234 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001235 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001236 union iwreq_data wrqu;
1237 int we_event;
1238 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301239 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001241 /* Added to find the auth type on the fly at run time */
1242 /* rather than with cfg to see if FT is enabled */
Jeff Johnson2a722002017-09-30 20:02:35 -07001243 struct hdd_wext_state *pWextState =
Jeff Johnsonba388342017-10-02 13:31:01 -07001244 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001245 tCsrRoamProfile *roam_profile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246
1247 memset(&wrqu, '\0', sizeof(wrqu));
1248 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1249 we_event = SIOCGIWAP;
1250#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1251 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301252 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001254 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301255 /* Update tdls module about the disconnection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001256 hdd_notify_sta_disconnect(adapter->session_id,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001257 true, false,
1258 adapter->hdd_vdev);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301259 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001260#endif
Jeff Johnsond377dce2017-10-04 10:32:42 -07001261 if (eConnectionState_Associated == sta_ctx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001262 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301263
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001265 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001266 return;
1267 }
1268
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001269 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Jeff Johnson8095a312017-09-03 09:13:24 -07001270 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001271 adapter->device_mode, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001272 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1273 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1274
Wu Gaoc02785d2017-09-07 18:17:13 +08001275 ucfg_p2p_status_connect(adapter->hdd_vdev);
1276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001277 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1278 MAC_ADDRESS_STR "\n",
Jeff Johnson1e851a12017-10-28 14:36:12 -07001279 MAC_ADDR_ARRAY(adapter->mac_addr.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001280 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnsonba388342017-10-02 13:31:01 -07001281 hdd_send_update_beacon_ies_event(adapter, pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282
1283 /*
1284 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1285 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001286 * fFTEnable is true.
1287 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001288 */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001289 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290 eCSR_AUTH_TYPE_FT_RSN_PSK)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001291 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292 eCSR_AUTH_TYPE_FT_RSN)
1293#ifdef FEATURE_WLAN_ESE
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001294 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 eCSR_AUTH_TYPE_CCKM_RSN)
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001296 || (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001297 eCSR_AUTH_TYPE_CCKM_WPA)
1298#endif
1299 ) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001300 hdd_send_ft_assoc_response(dev, adapter, pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001301 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301302 qdf_copy_macaddr(&peerMacAddr,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001303 &sta_ctx->conn_info.bssId);
Abhishek Singh1c676222016-05-09 14:20:28 +05301304 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1305 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1306 chan_info.info = pCsrRoamInfo->chan_info.info;
1307 chan_info.band_center_freq1 =
1308 pCsrRoamInfo->chan_info.band_center_freq1;
1309 chan_info.band_center_freq2 =
1310 pCsrRoamInfo->chan_info.band_center_freq2;
1311 chan_info.reg_info_1 =
1312 pCsrRoamInfo->chan_info.reg_info_1;
1313 chan_info.reg_info_2 =
1314 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301315
Jeff Johnsonba388342017-10-02 13:31:01 -07001316 ret = hdd_objmgr_add_peer_object(adapter->hdd_vdev,
1317 adapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301318 peerMacAddr.bytes,
1319 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001320 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301321 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1322 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Jeff Johnsonba388342017-10-02 13:31:01 -07001323 ret = hdd_objmgr_set_peer_mlme_state(adapter->hdd_vdev,
Dustin Brown7d043f62017-03-27 12:07:36 -07001324 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301325 if (ret)
1326 hdd_err("Peer object %pM fail to set associated state",
1327 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301328
Abhishek Singh1c676222016-05-09 14:20:28 +05301329 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001330 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1331 ePeerConnected,
1332 pCsrRoamInfo->timingMeasCap,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001333 adapter->session_id, &chan_info,
Jeff Johnsonba388342017-10-02 13:31:01 -07001334 adapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001335 /* Update tdls module about connection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001336 hdd_notify_sta_connect(adapter->session_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001337 pCsrRoamInfo->tdls_chan_swit_prohibited,
1338 pCsrRoamInfo->tdls_prohibited,
Jeff Johnsonba388342017-10-02 13:31:01 -07001339 adapter->hdd_vdev);
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001340
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001342#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 /* start timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001344 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001345 adapter->prev_tx_packets = adapter->stats.tx_packets;
1346 adapter->prev_rx_packets = adapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001347 cdp_get_intra_bss_fwd_pkts_count(
Jeff Johnson1b780e42017-10-31 14:11:45 -07001348 cds_get_context(QDF_MODULE_ID_SOC), adapter->session_id,
Jeff Johnsonba388342017-10-02 13:31:01 -07001349 &adapter->prev_fwd_tx_packets,
1350 &adapter->prev_fwd_rx_packets);
Jeff Johnson8095a312017-09-03 09:13:24 -07001351 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1352 hdd_bus_bw_compute_timer_start(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353#endif
1354#endif
1355 } else if (eConnectionState_IbssConnected == /* IBss Associated */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001356 sta_ctx->conn_info.connState) {
Jeff Johnson8095a312017-09-03 09:13:24 -07001357 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001358 adapter->session_id);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001359 memcpy(wrqu.ap_addr.sa_data, sta_ctx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001360 ETH_ALEN);
Abhishek Singh44725482017-11-02 16:53:23 +05301361 hdd_debug("wlan: new IBSS peer connection to BSSID " MAC_ADDRESS_STR,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001362 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001363 } else { /* Not Associated */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301364 hdd_debug("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Jeff Johnson8095a312017-09-03 09:13:24 -07001366 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001367 adapter->device_mode, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001368
1369#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001370 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001371#endif
1372
Jeff Johnsonba388342017-10-02 13:31:01 -07001373 if ((adapter->device_mode == QDF_STA_MODE) ||
1374 (adapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301375 qdf_copy_macaddr(&peerMacAddr,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001376 &sta_ctx->conn_info.bssId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377
1378 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001379 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301380 ePeerDisconnected, 0,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001381 adapter->session_id,
Abhishek Singh1c676222016-05-09 14:20:28 +05301382 NULL,
Jeff Johnsonba388342017-10-02 13:31:01 -07001383 adapter->device_mode);
Abhishek Singh44725482017-11-02 16:53:23 +05301384 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev,
1385 peerMacAddr.bytes);
1386 if (ret)
1387 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301388 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Abhishek Singh44725482017-11-02 16:53:23 +05301389 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301390
Jeff Johnsonba388342017-10-02 13:31:01 -07001391 hdd_lpass_notify_disconnect(adapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001392 /* Update tdls module about the disconnection event */
Jeff Johnson1b780e42017-10-31 14:11:45 -07001393 hdd_notify_sta_disconnect(adapter->session_id,
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001394 false,
Kabilan Kannanb6153b12017-07-13 17:54:02 -07001395 false,
Jeff Johnsonba388342017-10-02 13:31:01 -07001396 adapter->hdd_vdev);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001397
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001398#ifdef MSM_PLATFORM
1399 /* stop timer in sta/p2p_cli */
Jeff Johnson8095a312017-09-03 09:13:24 -07001400 spin_lock_bh(&hdd_ctx->bus_bw_lock);
Jeff Johnsonba388342017-10-02 13:31:01 -07001401 adapter->prev_tx_packets = 0;
1402 adapter->prev_rx_packets = 0;
1403 adapter->prev_fwd_tx_packets = 0;
1404 adapter->prev_fwd_rx_packets = 0;
Jeff Johnson8095a312017-09-03 09:13:24 -07001405 spin_unlock_bh(&hdd_ctx->bus_bw_lock);
1406 hdd_bus_bw_compute_timer_try_stop(hdd_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001407#endif
1408 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001409 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 /* Send SCC/MCC Switching event to IPA */
Jeff Johnson8095a312017-09-03 09:13:24 -07001411 hdd_ipa_send_mcc_scc_msg(hdd_ctx, hdd_ctx->mcc_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412
1413 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001414 /* During the WLAN uninitialization,supplicant is stopped before the
1415 * driver so not sending the status of the connection to supplicant
1416 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001417 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418 wireless_send_event(dev, we_event, &wrqu, msg);
1419#ifdef FEATURE_WLAN_ESE
1420 if (eConnectionState_Associated ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001421 sta_ctx->conn_info.connState) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001422 if ((roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 eCSR_AUTH_TYPE_CCKM_RSN) ||
Jeff Johnson5b34fce2017-10-13 13:24:51 -07001424 (roam_profile->AuthType.authType[0] ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 eCSR_AUTH_TYPE_CCKM_WPA))
Jeff Johnsonba388342017-10-02 13:31:01 -07001426 hdd_send_new_ap_channel_info(dev, adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 pCsrRoamInfo);
1428 }
1429#endif
1430 }
1431}
1432
1433/**
1434 * hdd_conn_remove_connect_info() - remove connection info
Jeff Johnsond377dce2017-10-04 10:32:42 -07001435 * @sta_ctx: pointer to global HDD station context
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436 * @pCsrRoamInfo: pointer to roam info
1437 *
1438 * Return: none
1439 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001440static void hdd_conn_remove_connect_info(struct hdd_station_ctx *sta_ctx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441{
1442 /* Remove staId, bssId and peerMacAddress */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001443 sta_ctx->conn_info.staId[0] = HDD_WLAN_INVALID_STA_ID;
1444 qdf_mem_zero(&sta_ctx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1445 qdf_mem_zero(&sta_ctx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301446 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001447
1448 /* Clear all security settings */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001449 sta_ctx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1450 sta_ctx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1451 sta_ctx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452
Jeff Johnsond377dce2017-10-04 10:32:42 -07001453 qdf_mem_zero(&sta_ctx->conn_info.Keys, sizeof(tCsrKeys));
1454 qdf_mem_zero(&sta_ctx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001455
Jeff Johnsond377dce2017-10-04 10:32:42 -07001456 sta_ctx->conn_info.proxyARPService = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001457
Jeff Johnsond377dce2017-10-04 10:32:42 -07001458 qdf_mem_zero(&sta_ctx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459}
1460
1461/**
1462 * hdd_roam_deregister_sta() - deregister station
Jeff Johnsonba388342017-10-02 13:31:01 -07001463 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464 * @staId: station identifier
1465 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301466 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001468QDF_STATUS hdd_roam_deregister_sta(struct hdd_adapter *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001469{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301470 QDF_STATUS qdf_status;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001471 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301472 int ret = 0;
Abhishek Singh44725482017-11-02 16:53:23 +05301473 struct qdf_mac_addr *peer_mac = NULL;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301474 struct qdf_mac_addr broadcastMacAddr =
1475 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001476 if (eConnectionState_IbssDisconnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001477 sta_ctx->conn_info.connState) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 /*
1479 * Do not set the carrier off when the last peer leaves.
1480 * We will set the carrier off while stopping the IBSS.
1481 */
1482 }
1483
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001484 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001485 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301486 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301487 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301488 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1489 staid, qdf_status, qdf_status);
1490 }
1491
1492 if (adapter->device_mode == QDF_STA_MODE) {
Abhishek Singh44725482017-11-02 16:53:23 +05301493 peer_mac = &sta_ctx->conn_info.bssId;
Naveen Rawat95eb4062017-11-02 16:46:41 -07001494 } else if (adapter->device_mode == QDF_IBSS_MODE ||
1495 adapter->device_mode == QDF_NDI_MODE) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07001496 if (sta_ctx->broadcast_staid == staid)
Abhishek Singh44725482017-11-02 16:53:23 +05301497 peer_mac = &broadcastMacAddr;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301498 else
Abhishek Singh44725482017-11-02 16:53:23 +05301499 peer_mac =
1500 hdd_wlan_get_ibss_mac_addr_from_staid(adapter, staid);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301501 }
Naveen Rawat95eb4062017-11-02 16:46:41 -07001502
Abhishek Singh44725482017-11-02 16:53:23 +05301503 if (!peer_mac) {
1504 hdd_err("Coudnt find peer MAC for staid %d, delete fails",
1505 staid);
1506 return QDF_STATUS_E_FAILURE;
1507 }
Naveen Rawat95eb4062017-11-02 16:46:41 -07001508
1509 hdd_debug("peer_mac_addr: "MAC_ADDRESS_STR,
1510 MAC_ADDR_ARRAY(peer_mac->bytes));
Abhishek Singh44725482017-11-02 16:53:23 +05301511 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac->bytes);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301512 if (ret) {
1513 hdd_err("Peer obj %pM delete fails", peer_mac);
1514 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001515 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301516 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517}
1518
1519/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301520 * hdd_print_bss_info() - print bss info
1521 * @hdd_sta_ctx: pointer to hdd station context
1522 *
1523 * Return: None
1524 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07001525static void hdd_print_bss_info(struct hdd_station_ctx *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301526{
1527 uint32_t *cap_info;
1528
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301529 hdd_debug("WIFI DATA LOGGER");
1530 hdd_debug("channel: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301531 hdd_sta_ctx->conn_info.freq);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301532 hdd_debug("dot11mode: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301533 hdd_sta_ctx->conn_info.dot11Mode);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301534 hdd_debug("AKM: %d",
1535 hdd_sta_ctx->conn_info.last_auth_type);
1536 hdd_debug("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001537 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1538 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301539 hdd_debug("roam count: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301540 hdd_sta_ctx->conn_info.roam_count);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301541 hdd_debug("ant_info: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301542 hdd_sta_ctx->conn_info.txrate.nss);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301543 hdd_debug("datarate legacy %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301544 hdd_sta_ctx->conn_info.txrate.legacy);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301545 hdd_debug("datarate mcs: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301546 hdd_sta_ctx->conn_info.txrate.mcs);
1547 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1548 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301549 hdd_debug("ht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301550 }
1551 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1552 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301553 hdd_debug("vht caps: %x", *cap_info);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301554 }
1555 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301556 hdd_debug("hs20 info: %x",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301557 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301558 hdd_debug("signal: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301559 hdd_sta_ctx->conn_info.signal);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301560 hdd_debug("noise: %d",
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301561 hdd_sta_ctx->conn_info.noise);
1562}
1563
1564/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 * hdd_dis_connect_handler() - disconnect event handler
Jeff Johnsonba388342017-10-02 13:31:01 -07001566 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07001567 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001568 * @roamId: roam identifier
1569 * @roamStatus: roam status
1570 * @roamResult: roam result
1571 *
1572 * This function handles disconnect event:
1573 * 1. Disable transmit queues;
1574 * 2. Clean up internal connection states and data structures;
1575 * 3. Send disconnect indication to supplicant.
1576 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301577 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001578 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001579static QDF_STATUS hdd_dis_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001580 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 uint32_t roamId,
1582 eRoamCmdStatus roamStatus,
1583 eCsrRoamResult roamResult)
1584{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301585 QDF_STATUS status = QDF_STATUS_SUCCESS;
1586 QDF_STATUS vstatus;
Jeff Johnsonba388342017-10-02 13:31:01 -07001587 struct net_device *dev = adapter->dev;
1588 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07001589 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590 uint8_t sta_id;
1591 bool sendDisconInd = true;
1592
1593 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001594 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301595 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 }
1597 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001598 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07001599 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301600 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1601 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602
Jeff Johnson8095a312017-09-03 09:13:24 -07001603 if (hdd_ipa_is_enabled(hdd_ctx))
Jeff Johnsond377dce2017-10-04 10:32:42 -07001604 hdd_ipa_wlan_evt(adapter, sta_ctx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001605 HDD_IPA_STA_DISCONNECT,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001606 sta_ctx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001607
1608#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07001609 wlan_hdd_auto_shutdown_enable(hdd_ctx, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610#endif
1611
Nirav Shah1da77682016-05-03 20:16:39 +05301612 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001613 adapter->session_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001614 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301615 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616
1617 /* HDD has initiated disconnect, do not send disconnect indication
1618 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301619 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001620 * to cfg80211_disconnected.
1621 */
1622 if ((eConnectionState_Disconnecting ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001623 sta_ctx->conn_info.connState) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 (eConnectionState_NotConnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001625 sta_ctx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001626 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 sendDisconInd = false;
1628 }
1629
Jeff Johnsond377dce2017-10-04 10:32:42 -07001630 if (sta_ctx->conn_info.connState != eConnectionState_Disconnecting) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001631 INIT_COMPLETION(adapter->disconnect_comp_var);
1632 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001633 eConnectionState_Disconnecting);
1634 }
1635
Jeff Johnsonba388342017-10-02 13:31:01 -07001636 hdd_clear_roam_profile_ie(adapter);
1637 hdd_wmm_init(adapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001638 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301639 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001640
1641 /* indicate 'disconnect' status to wpa_supplicant... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07001642 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 /* indicate disconnected event to nl80211 */
1644 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1645 /*
1646 * Only send indication to kernel if not initiated
1647 * by kernel
1648 */
1649 if (sendDisconInd) {
1650 /*
1651 * To avoid wpa_supplicant sending "HANGED" CMD
1652 * to ICS UI.
1653 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001654 if (eCSR_ROAM_LOSTLINK == roamStatus) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07001655 if (roam_info->reasonCode ==
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001656 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
Jeff Johnson435e1b82017-10-07 14:13:10 -07001657 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n",
1658 roam_info->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301659 wlan_hdd_cfg80211_indicate_disconnect(
1660 dev, false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07001661 roam_info->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001662 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301663 wlan_hdd_cfg80211_indicate_disconnect(
1664 dev, false,
1665 WLAN_REASON_UNSPECIFIED
1666 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001667 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05301669 hdd_debug("sent disconnected event to nl80211, reason code %d",
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301670 (eCSR_ROAM_LOSTLINK == roamStatus) ?
Jeff Johnsonfd060852017-10-04 10:50:51 -07001671 roam_info->reasonCode :
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301672 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001673 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674
Wu Gaoc02785d2017-09-07 18:17:13 +08001675 /* update P2P connection status */
1676 ucfg_p2p_status_disconnect(adapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 }
1678
Jeff Johnsonba388342017-10-02 13:31:01 -07001679 hdd_wmm_adapter_clear(adapter);
Jeff Johnson1b780e42017-10-31 14:11:45 -07001680 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(adapter), adapter->session_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001681 if (hdd_remove_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001682 hdd_err("hdd_remove_beacon_filter() failed");
1683
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301685 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001686
Jeff Johnsond377dce2017-10-04 10:32:42 -07001687 sta_id = sta_ctx->broadcast_staid;
Jeff Johnsonba388342017-10-02 13:31:01 -07001688 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301689 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001690 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301691 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301692 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001694 if (sta_id < HDD_MAX_ADAPTERS)
1695 hdd_ctx->sta_to_adapter[sta_id] = NULL;
1696 else
1697 hdd_debug("invalid sta id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301698 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001699 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001700 if (HDD_WLAN_INVALID_STA_ID ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07001701 sta_ctx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301702 continue;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001703 sta_id = sta_ctx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001704 hdd_debug("Deregister StaID %d", sta_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001705 vstatus = hdd_roam_deregister_sta(adapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301706 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001707 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301708 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301709 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301710 }
1711 /* set the staid and peer mac as 0, all other
1712 * reset are done in hdd_connRemoveConnectInfo.
1713 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001714 sta_ctx->conn_info.staId[i] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301715 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07001716 qdf_mem_zero(&sta_ctx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301717 sizeof(struct qdf_mac_addr));
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001718 if (sta_id < HDD_MAX_ADAPTERS)
Jeff Johnson8095a312017-09-03 09:13:24 -07001719 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001720 else
1721 hdd_debug("invalid sta_id %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301722 }
1723 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07001724 sta_id = sta_ctx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001725 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301726
1727 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001728 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1729 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301730 eCSR_ROAM_LOSTLINK == roamStatus) {
Jeff Johnsonba388342017-10-02 13:31:01 -07001731 wlan_hdd_cfg80211_update_bss_list(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001732 sta_ctx->conn_info.bssId.bytes);
Jeff Johnson8095a312017-09-03 09:13:24 -07001733 sme_remove_bssid_from_scan_list(hdd_ctx->hHal,
Jeff Johnsond377dce2017-10-04 10:32:42 -07001734 sta_ctx->conn_info.bssId.bytes);
Abhishek Singhc9941602016-08-09 16:06:22 +05301735 }
Rajeev Kumar4bc998f2017-10-19 14:41:43 -07001736 if (sta_id < HDD_MAX_ADAPTERS)
1737 hdd_ctx->sta_to_adapter[sta_id] = NULL;
Rajeev Kumar7774cc82017-10-20 15:16:47 -07001738 else
1739 hdd_debug("invalid sta_id %d", sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 /* Clear saved connection information in HDD */
Jeff Johnsond377dce2017-10-04 10:32:42 -07001742 hdd_conn_remove_connect_info(sta_ctx);
Jeff Johnsonba388342017-10-02 13:31:01 -07001743 hdd_conn_set_connection_state(adapter, eConnectionState_NotConnected);
1744 pmo_ucfg_flush_gtk_offload_req(adapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745
Jeff Johnsonba388342017-10-02 13:31:01 -07001746 if ((QDF_STA_MODE == adapter->device_mode) ||
1747 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07001749 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07001750 adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 }
Jeff Johnsonba388342017-10-02 13:31:01 -07001752 wlan_hdd_clear_link_layer_stats(adapter);
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301753
Jeff Johnson6ced42c2017-10-20 12:48:11 -07001754 adapter->hdd_stats.tx_rx_stats.cont_txtimeout_cnt = 0;
Sravan Kumar Kairam3a698312017-10-16 14:16:16 +05301755
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 /* Unblock anyone waiting for disconnect to complete */
Jeff Johnsonba388342017-10-02 13:31:01 -07001757 complete(&adapter->disconnect_comp_var);
Ganesh Kondabattini479a8ae2017-10-03 16:49:24 +05301758
1759 hdd_reset_limit_off_chan(adapter);
1760
Jeff Johnsond377dce2017-10-04 10:32:42 -07001761 hdd_print_bss_info(sta_ctx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001762 return status;
1763}
1764
1765/**
1766 * hdd_set_peer_authorized_event() - set peer_authorized_event
1767 * @vdev_id: vdevid
1768 *
1769 * Return: None
1770 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001771static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772{
Jeff Johnson49432062017-08-28 12:08:45 -07001773 struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Jeff Johnsonb1704c82017-08-29 14:40:57 -07001774 struct hdd_adapter *adapter = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775
1776 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1777 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001778 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001779 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 }
1781 complete(&adapter->sta_authorized_event);
1782}
1783
1784/**
1785 * hdd_change_peer_state() - change peer state
Jeff Johnsonba388342017-10-02 13:31:01 -07001786 * @adapter: HDD adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 * @sta_state: peer state
1788 * @roam_synch_in_progress: roam synch in progress
1789 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301790 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001791 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001792QDF_STATUS hdd_change_peer_state(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793 uint8_t sta_id,
1794 enum ol_txrx_peer_state sta_state,
1795 bool roam_synch_in_progress)
1796{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301797 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001798 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001799 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1800 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1801 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802
1803 if (!pdev) {
1804 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301805 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806 }
1807
1808 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001809 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301810 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811 }
1812
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001813 peer = cdp_peer_find_by_local_id(soc,
1814 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001815 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301816 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817
Leo Changfdb45c32016-10-28 11:09:23 -07001818 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001819 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001820 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001821 return QDF_STATUS_E_FAULT;
1822 }
1823
Leo Changfdb45c32016-10-28 11:09:23 -07001824 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301825 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001826 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301827 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 }
1829#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1830 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301831 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832#endif
1833
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001834 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1836 /* make sure event is reset */
Jeff Johnsonba388342017-10-02 13:31:01 -07001837 INIT_COMPLETION(adapter->sta_authorized_event);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838#endif
1839
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001840 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841 hdd_set_peer_authorized_event,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001842 adapter->session_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301843 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001844 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301845 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 }
1847
Jeff Johnsonba388342017-10-02 13:31:01 -07001848 if (adapter->device_mode == QDF_STA_MODE ||
1849 adapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001851 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 unsigned long rc;
1853
1854 /* wait for event from firmware to set the event */
1855 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07001856 &adapter->sta_authorized_event,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001857 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001858 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001859 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001860
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001861 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1862 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001863 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864#endif
1865 }
1866 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301867 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001868}
1869
1870/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001871 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1872 * @cbk_data: callback data
1873 * @sta_id: station id
1874 * @vdev_param: vdev parameter
1875 * @is_link_up: link state up or down
1876 *
1877 * Return: QDF status
1878 */
1879QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1880 uint8_t sta_id,
1881 uint32_t vdev_param,
1882 bool is_link_up)
1883{
1884 struct cdp_vdev *data_vdev;
1885 QDF_STATUS status = QDF_STATUS_SUCCESS;
1886 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
Jeff Johnson49432062017-08-28 12:08:45 -07001887 struct hdd_context *hdd_ctx;
Yun Park0dad1002017-07-14 14:57:01 -07001888 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Kabilan Kannan256e3182017-05-02 16:02:37 -07001889 struct wlan_objmgr_psoc **psoc;
1890
1891 if (!cbk_data)
1892 return status;
1893
1894 psoc = cbk_data;
Kabilan Kannan256e3182017-05-02 16:02:37 -07001895
Kabilan Kannanc0e3d582017-09-13 00:26:33 -07001896 hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Kabilan Kannan256e3182017-05-02 16:02:37 -07001897 if (!hdd_ctx->tdls_nap_active)
1898 return status;
1899
Yun Park0dad1002017-07-14 14:57:01 -07001900 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, pdev, sta_id);
Kabilan Kannan256e3182017-05-02 16:02:37 -07001901 if (NULL == data_vdev) {
1902 status = QDF_STATUS_E_FAILURE;
1903 return status;
1904 }
1905
1906 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1907
1908 return status;
1909}
1910
1911/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912 * hdd_roam_register_sta() - register station
Jeff Johnsonba388342017-10-02 13:31:01 -07001913 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07001914 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 * @staId: station identifier
1916 * @pPeerMacAddress: peer MAC address
1917 * @pBssDesc: pointer to BSS description
1918 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301919 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001920 */
Jeff Johnsonba388342017-10-02 13:31:01 -07001921QDF_STATUS hdd_roam_register_sta(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08001922 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301924 struct qdf_mac_addr *pPeerMacAddress,
Jeff Johnson4ba73cb2017-10-06 11:12:33 -07001925 struct bss_description *pBssDesc)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301927 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001928 struct ol_txrx_desc_type staDesc = { 0 };
Jeff Johnsond377dce2017-10-04 10:32:42 -07001929 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001930 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001931 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1932 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933
1934 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301935 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936
1937 /* Get the Station ID from the one saved during the association */
1938 staDesc.sta_id = staId;
1939
1940 /* set the QoS field appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07001941 if (hdd_wmm_is_active(adapter))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 staDesc.is_qos_enabled = 1;
1943 else
1944 staDesc.is_qos_enabled = 0;
1945
1946#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07001947 hdd_debug("WAPI STA Registered: %d",
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07001948 adapter->wapi_info.is_wapi_sta);
1949 if (adapter->wapi_info.is_wapi_sta)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001950 staDesc.is_wapi_supported = 1;
1951 else
1952 staDesc.is_wapi_supported = 0;
1953#endif /* FEATURE_WLAN_WAPI */
1954
Dhanashri Atre50141c52016-04-07 13:15:29 -07001955 /* Register the vdev transmit and receive functions */
1956 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1957 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001958
Jeff Johnsonba388342017-10-02 13:31:01 -07001959 adapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001960 (struct cdp_pdev *)pdev,
Jeff Johnson1b780e42017-10-31 14:11:45 -07001961 adapter->session_id);
Jeff Johnsonba388342017-10-02 13:31:01 -07001962 if (!adapter->txrx_vdev) {
Leo Changfdb45c32016-10-28 11:09:23 -07001963 hdd_err("%s find vdev fail", __func__);
1964 return QDF_STATUS_E_FAILURE;
1965 }
1966
1967 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001968 cdp_vdev_register(soc,
Jeff Johnsonba388342017-10-02 13:31:01 -07001969 (struct cdp_vdev *)adapter->txrx_vdev, adapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001970 if (!txrx_ops.tx.tx) {
1971 hdd_err("%s vdev register fail", __func__);
1972 return QDF_STATUS_E_FAILURE;
1973 }
1974
Jeff Johnsonba388342017-10-02 13:31:01 -07001975 adapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001976 qdf_status = cdp_peer_register(soc,
1977 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301978 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001979 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001980 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301981 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 }
1983
Jeff Johnsonfd060852017-10-04 10:50:51 -07001984 if (!roam_info->fAuthRequired) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985 /*
1986 * Connections that do not need Upper layer auth, transition
1987 * TLSHIM directly to 'Authenticated' state
1988 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301989 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07001990 hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001991 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07001993 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994#else
1995 false
1996#endif
1997 );
1998
Jeff Johnsonba388342017-10-02 13:31:01 -07001999 hdd_conn_set_authenticated(adapter, true);
2000 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002002 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002003 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302004 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002005 hdd_change_peer_state(adapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002006 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07002008 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009#else
2010 false
2011#endif
2012 );
Jeff Johnsonba388342017-10-02 13:31:01 -07002013 hdd_conn_set_authenticated(adapter, false);
2014 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302016 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002017}
2018
2019/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302020 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2021 * @dev: network device
2022 * @bss: cfg80211 roamed bss pointer
2023 * @req_ie: IEs used in reassociation request
2024 * @req_ie_len: Length of the @req_ie
2025 * @resp_ie: IEs received in successful reassociation response
2026 * @resp_ie_len: Length of @resp_ie
2027 *
2028 * Return: none
2029 */
2030#if defined CFG80211_ROAMED_API_UNIFIED || \
2031 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2032static void hdd_send_roamed_ind(struct net_device *dev,
2033 struct cfg80211_bss *bss, const uint8_t *req_ie,
2034 size_t req_ie_len, const uint8_t *resp_ie,
2035 size_t resp_ie_len)
2036{
2037 struct cfg80211_roam_info info = {0};
2038
2039 info.bss = bss;
2040 info.req_ie = req_ie;
2041 info.req_ie_len = req_ie_len;
2042 info.resp_ie = resp_ie;
2043 info.resp_ie_len = resp_ie_len;
2044 cfg80211_roamed(dev, &info, GFP_KERNEL);
2045}
2046#else
2047static inline void hdd_send_roamed_ind(struct net_device *dev,
2048 struct cfg80211_bss *bss,
2049 const uint8_t *req_ie, size_t req_ie_len,
2050 const uint8_t *resp_ie,
2051 size_t resp_ie_len)
2052{
2053 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2054 GFP_KERNEL);
2055}
2056#endif
2057
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302058#if defined(WLAN_FEATURE_ROAM_OFFLOAD)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302059#if defined(WLAN_FEATURE_FILS_SK)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302060void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002061 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302062{
2063 uint8_t *kek;
2064 uint32_t kek_len;
2065
2066 if (is_reassoc) {
2067 kek = csr_roam_info->kek;
2068 kek_len = csr_roam_info->kek_len;
2069 } else {
2070 /*
2071 * This should come for FILS case only.
2072 * Caller should make sure fils_join_rsp is
2073 * not NULL, if there is need to use else where.
2074 */
2075 kek = csr_roam_info->fils_join_rsp->kek;
2076 kek_len = csr_roam_info->fils_join_rsp->kek_len;
2077 }
2078
2079 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2080 csr_roam_info->replay_ctr, true);
2081
2082 hdd_debug("Kek len %d", kek_len);
2083}
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302084#else
2085void hdd_save_gtk_params(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002086 struct csr_roam_info *csr_roam_info, bool is_reassoc)
Vignesh Viswanathan0b0fa272017-09-18 17:12:04 +05302087{
2088 uint8_t *kek;
2089 uint32_t kek_len;
2090
2091 /*
2092 * is_reassoc is set to true always for Legacy GTK offload
2093 * case, It is false only for FILS case
2094 */
2095 kek = csr_roam_info->kek;
2096 kek_len = csr_roam_info->kek_len;
2097
2098 wlan_hdd_save_gtk_offload_params(adapter, NULL, kek, kek_len,
2099 csr_roam_info->replay_ctr, true);
2100
2101 hdd_debug("Kek len %d", kek_len);
2102}
2103#endif
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302104#endif
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302105/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002106 * hdd_send_re_assoc_event() - send reassoc event
2107 * @dev: pointer to net device
Jeff Johnsonba388342017-10-02 13:31:01 -07002108 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 * @pCsrRoamInfo: pointer to roam info
2110 * @reqRsnIe: pointer to RSN Information element
2111 * @reqRsnLength: length of RSN IE
2112 *
2113 * Return: none
2114 */
2115static void hdd_send_re_assoc_event(struct net_device *dev,
Jeff Johnson172237b2017-11-07 15:32:59 -08002116 struct hdd_adapter *adapter, struct csr_roam_info *pCsrRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002117 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2118{
2119 unsigned int len = 0;
2120 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002121 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2122 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 uint32_t rspRsnLength = 0;
2124 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002125 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2126 uint8_t *buf_ptr, ssid_ie_len;
2127 struct cfg80211_bss *bss = NULL;
2128 uint8_t *final_req_ie = NULL;
2129 tCsrRoamConnectedProfile roam_profile;
Jeff Johnsonba388342017-10-02 13:31:01 -07002130 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(adapter);
2131 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302132 int chan_no;
2133 int freq;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002134
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002135 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2136
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002138 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002139 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002140 }
2141
Naveen Rawat14298b92015-11-25 16:27:41 -08002142 if (!assoc_req_ies) {
2143 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002144 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002145 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002147 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002148 goto done;
2149 }
2150
2151 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002152 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002153 goto done;
2154 }
2155
2156 pFTAssocRsp =
2157 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2158 pCsrRoamInfo->nAssocReqLength);
2159 if (pFTAssocRsp == NULL)
2160 goto done;
2161
2162 /* pFTAssocRsp needs to point to the IEs */
2163 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002164 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002165 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166
2167 /*
2168 * Active session count is decremented upon disconnection, but during
2169 * roaming, there is no disconnect indication and hence active session
2170 * count is not decremented.
2171 * After roaming is completed, active session count is incremented
2172 * as a part of connect indication but effectively after roaming the
2173 * active session count should still be the same and hence upon
2174 * successful reassoc decrement the active session count here.
2175 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002176 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002177 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002178 adapter->device_mode, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179
2180 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2181 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2182 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302183 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2184 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002185
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302186 chan_no = pCsrRoamInfo->pBssDesc->channelId;
2187 if (chan_no <= 14)
2188 freq = ieee80211_channel_to_frequency(chan_no,
2189 NL80211_BAND_2GHZ);
2190 else
2191 freq = ieee80211_channel_to_frequency(chan_no,
2192 NL80211_BAND_5GHZ);
Jeff Johnsonba388342017-10-02 13:31:01 -07002193 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Ashish Kumar Dhanotiya52def212017-09-07 17:25:48 +05302194
Jeff Johnson1b780e42017-10-31 14:11:45 -07002195 sme_roam_get_connect_profile(hal_handle, adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002196 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302197
Jeff Johnsonba388342017-10-02 13:31:01 -07002198 bss = hdd_cfg80211_get_bss(adapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302199 chan, pCsrRoamInfo->bssid.bytes,
2200 &roam_profile.SSID.ssId[0],
2201 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002202
2203 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002204 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 buf_ptr = buf_ssid_ie;
2206 *buf_ptr = SIR_MAC_SSID_EID;
2207 buf_ptr++;
2208 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2209 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302210 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002211 roam_profile.SSID.length);
2212 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002213 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302214 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002215 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002216 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Kapil Gupta8731e812017-07-11 18:42:39 +05302217 if (final_req_ie == NULL) {
2218 if (bss)
Jeff Johnsonba388342017-10-02 13:31:01 -07002219 cfg80211_put_bss(adapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002220 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302221 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002222 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302223 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002224 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302225 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2226 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2227 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002228 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002229 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302230 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002231 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302232 hdd_send_roamed_ind(dev, bss, final_req_ie,
2233 (ssid_ie_len + reqRsnLength), rspRsnIe,
2234 rspRsnLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002235
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302236 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002237 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2238 pCsrRoamInfo->nAssocReqLength);
2239
Sridhar Selvaraje5260442017-08-19 10:12:03 +05302240 hdd_save_gtk_params(adapter, pCsrRoamInfo, true);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302241
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002242 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302243 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002244 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2245
Jeff Johnsonba388342017-10-02 13:31:01 -07002246 wlan_hdd_send_roam_auth_event(adapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002247 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2248 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002249 pCsrRoamInfo);
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302250
2251 hdd_update_hlp_info(dev, pCsrRoamInfo);
2252
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002253done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002254 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002256 qdf_mem_free(final_req_ie);
2257 qdf_mem_free(rspRsnIe);
2258 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002259}
2260
2261/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302262 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002263 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302264 *
2265 * Return: roam sync status if roaming offloaded else false
2266 */
2267#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnson172237b2017-11-07 15:32:59 -08002268bool hdd_is_roam_sync_in_progress(struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302269{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002270 if (roaminfo)
2271 return roaminfo->roamSynchInProgress;
2272 else
2273 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302274}
2275#endif
2276
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002277/**
2278 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2279 * @hddstactx: pointer to HDD sta context
2280 * @roaminfo: pointer to roaminfo structure
2281 *
2282 * This function returns staid for IBSS peer. If peer is broadcast
2283 * MAC address return self staid(0) else find the peer sta id of
2284 * the peer.
2285 *
2286 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2287 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07002288static uint8_t hdd_get_ibss_peer_staid(struct hdd_station_ctx *hddstactx,
Jeff Johnson172237b2017-11-07 15:32:59 -08002289 struct csr_roam_info *roaminfo)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002290{
2291 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2292 QDF_STATUS status;
2293
2294 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2295 staid = 0;
2296 } else {
2297 status = hdd_get_peer_sta_id(hddstactx,
2298 &roaminfo->peerMac, &staid);
2299 if (status != QDF_STATUS_SUCCESS) {
2300 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2301 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2302 }
2303 }
2304
2305 return staid;
2306}
Govind Singhedc5cda2015-10-23 17:11:35 +05302307
2308/**
2309 * hdd_change_sta_state_authenticated()-
2310 * This function changes STA state to authenticated
2311 * @adapter: pointer to the adapter structure.
2312 * @roaminfo: pointer to the RoamInfo structure.
2313 *
2314 * This is called from hdd_RoamSetKeyCompleteHandler
2315 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2316 *
2317 * Return: 0 on success and errno on failure
2318 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002319static int hdd_change_sta_state_authenticated(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002320 struct csr_roam_info *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302321{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002322 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002323 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002324 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Jeff Johnson435e1b82017-10-07 14:13:10 -07002325 struct hdd_station_ctx *hddstactx =
2326 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson49432062017-08-28 12:08:45 -07002327 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302328
Jeff Johnson690fe952017-10-25 11:48:39 -07002329 timeout = hddstactx->hdd_reassoc_scenario ?
Dustin Brownf660fb42016-09-09 12:04:00 -07002330 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002331 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002332
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002333 if (QDF_IBSS_MODE == adapter->device_mode)
2334 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2335 else
2336 staid = hddstactx->conn_info.staId[0];
2337
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002338 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302339
2340 /* Connections that do not need Upper layer authentication,
2341 * transition TL to 'Authenticated' state after the keys are set
2342 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002343 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302344 hdd_is_roam_sync_in_progress(roaminfo));
2345 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002346 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2347
Krunal Sonibe766b02016-03-10 13:00:44 -08002348 if ((QDF_STA_MODE == adapter->device_mode) ||
2349 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302350 sme_ps_enable_auto_ps_timer(
2351 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002352 adapter->session_id,
Dustin Brown84411b02017-07-21 16:44:44 -07002353 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302354 }
2355
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002356 return qdf_status_to_os_return(status);
2357}
2358
2359/**
2360 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2361 * if key installation is required
2362 * @encr_type: encryption type
2363 *
2364 * Return: true if key installation is required and false otherwise.
2365 */
2366static inline bool hdd_is_key_install_required_for_ibss(
2367 eCsrEncryptionType encr_type)
2368{
2369 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2370 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2371 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302372 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2373 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002374 eCSR_ENCRYPT_TYPE_AES == encr_type)
2375 return true;
2376 else
2377 return false;
2378}
2379
2380/**
2381 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2382 * complete
2383 * @adapter: pointer to HDD adapter
2384 * @roaminfo: pointer to roam info
2385 * @roam_result: roam result
2386 *
2387 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2388 * This function checks for the successful set key completion and update
2389 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2390 *
2391 * Return: None
2392 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002393static void hdd_change_peer_state_after_set_key(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002394 struct csr_roam_info *roaminfo,
2395 eCsrRoamResult roam_result)
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002396{
Jeff Johnson435e1b82017-10-07 14:13:10 -07002397 struct hdd_station_ctx *hdd_sta_ctx =
2398 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002399 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2400
2401 /*
2402 * If the security mode is one of the following, IBSS peer will be
2403 * waiting in CONN state and we will move the peer state to AUTH
2404 * here. For non-secure connection, no need to wait for set-key complete
2405 * peer will be moved to AUTH in hdd_roam_register_sta.
2406 */
2407 if (QDF_IBSS_MODE == adapter->device_mode) {
2408 if (hdd_is_key_install_required_for_ibss(encr_type))
2409 hdd_change_sta_state_authenticated(adapter, roaminfo);
2410
2411 return;
2412 }
2413
2414 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2415 hdd_sta_ctx->conn_info.gtk_installed = true;
2416 /*
2417 * PTK exchange happens in preauthentication itself if key_mgmt
2418 * is FT-PSK, ptk_installed was false as there is no set PTK
2419 * after roaming. STA TL state moves to authenticated only if
2420 * ptk_installed is true. So, make ptk_installed to true in
2421 * case of 11R roaming.
2422 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302423 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002424 adapter->session_id))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002425 hdd_sta_ctx->conn_info.ptk_installed = true;
2426 } else {
2427 hdd_sta_ctx->conn_info.ptk_installed = true;
2428 }
2429
2430 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2431 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2432 * unicast key and it was resulting in sending few un-encrypted packet.
2433 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2434 * set the unicast and broadcast key.
2435 */
2436 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2437 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2438 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2439 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2440 if (hdd_sta_ctx->conn_info.gtk_installed &&
2441 hdd_sta_ctx->conn_info.ptk_installed)
2442 hdd_change_sta_state_authenticated(adapter, roaminfo);
2443 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2444 hdd_change_sta_state_authenticated(adapter, roaminfo);
2445 }
2446
2447 if (hdd_sta_ctx->conn_info.gtk_installed &&
2448 hdd_sta_ctx->conn_info.ptk_installed) {
2449 hdd_sta_ctx->conn_info.gtk_installed = false;
2450 hdd_sta_ctx->conn_info.ptk_installed = false;
2451 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302452}
2453
2454/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 * hdd_roam_set_key_complete_handler() - Update the security parameters
Jeff Johnsonba388342017-10-02 13:31:01 -07002456 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002457 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002458 * @roamId: roam id
2459 * @roamStatus: roam status
2460 * @roamResult: roam result
2461 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302462 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002463 */
Jeff Johnson172237b2017-11-07 15:32:59 -08002464static QDF_STATUS
2465hdd_roam_set_key_complete_handler(struct hdd_adapter *adapter,
2466 struct csr_roam_info *roam_info,
2467 uint32_t roamId,
2468 eRoamCmdStatus roamStatus,
2469 eCsrRoamResult roamResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470{
2471 eCsrEncryptionType connectedCipherAlgo;
2472 bool fConnected = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002473 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302474
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 ENTER();
2476
Jeff Johnsonfd060852017-10-04 10:50:51 -07002477 if (NULL == roam_info) {
2478 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302479 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 }
2481 /*
2482 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2483 * then go to 'authenticated'. For all other authentication types
2484 * (those that do not require upper layer authentication) we can put TL
2485 * directly into 'authenticated' state.
2486 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05302487 hdd_debug("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002488 MAC_ADDRESS_STR, roamStatus, roamResult,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002489 MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490
Jeff Johnsond377dce2017-10-04 10:32:42 -07002491 fConnected = hdd_conn_get_connected_cipher_algo(sta_ctx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002492 &connectedCipherAlgo);
2493 if (fConnected) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002494 hdd_change_peer_state_after_set_key(adapter, roam_info,
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002495 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002496 }
2497
2498 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302499 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500}
2501
2502/**
2503 * hdd_perform_roam_set_key_complete() - perform set key complete
Jeff Johnsonba388342017-10-02 13:31:01 -07002504 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 *
2506 * Return: none
2507 */
Jeff Johnsonba388342017-10-02 13:31:01 -07002508void hdd_perform_roam_set_key_complete(struct hdd_adapter *adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302510 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002511 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson172237b2017-11-07 15:32:59 -08002512 struct csr_roam_info roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002513
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302515 qdf_mem_copy(roamInfo.bssid.bytes,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002516 sta_ctx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302517 qdf_mem_copy(roamInfo.peerMac.bytes,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002518 sta_ctx->roam_info.peer_mac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002519
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302520 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07002521 hdd_roam_set_key_complete_handler(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002522 &roamInfo,
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002523 sta_ctx->roam_info.roam_id,
2524 sta_ctx->roam_info.roam_status,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302526 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002527 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002529 sta_ctx->roam_info.defer_key_complete = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530}
2531
Vignesh Viswanathan3fa1d382017-08-02 19:36:43 +05302532#if defined(WLAN_FEATURE_FILS_SK) && \
2533 (defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT) || \
2534 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)))
Jeff Johnsonb1704c82017-08-29 14:40:57 -07002535void hdd_clear_fils_connection_info(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302536{
Jeff Johnson2a722002017-09-30 20:02:35 -07002537 struct hdd_wext_state *wext_state;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302538
2539 if ((adapter->device_mode == QDF_SAP_MODE) ||
2540 (adapter->device_mode == QDF_P2P_GO_MODE))
2541 return;
2542
2543 wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
2544 if (wext_state->roamProfile.fils_con_info) {
2545 qdf_mem_free(wext_state->roamProfile.fils_con_info);
2546 wext_state->roamProfile.fils_con_info = NULL;
2547 }
Vignesh Viswanathanc6d1e1c2017-09-18 12:32:49 +05302548
2549 if (wext_state->roamProfile.hlp_ie) {
2550 qdf_mem_free(wext_state->roamProfile.hlp_ie);
2551 wext_state->roamProfile.hlp_ie = NULL;
2552 wext_state->roamProfile.hlp_ie_len = 0;
2553 }
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302554}
2555#endif
2556
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002557/**
2558 * hdd_association_completion_handler() - association completion handler
Jeff Johnsonba388342017-10-02 13:31:01 -07002559 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07002560 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002561 * @roamId: roam id
2562 * @roamStatus: roam status
2563 * @roamResult: roam result
2564 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302565 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002566 */
Jeff Johnson435e1b82017-10-07 14:13:10 -07002567static QDF_STATUS
2568hdd_association_completion_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08002569 struct csr_roam_info *roam_info,
Jeff Johnson435e1b82017-10-07 14:13:10 -07002570 uint32_t roamId,
2571 eRoamCmdStatus roamStatus,
2572 eCsrRoamResult roamResult)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573{
Jeff Johnsonba388342017-10-02 13:31:01 -07002574 struct net_device *dev = adapter->dev;
2575 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002576 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302577 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002579 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002580 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 bool hddDisconInProgress = false;
2582 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302583 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302584 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002585
Jeff Johnson8095a312017-09-03 09:13:24 -07002586 if (!hdd_ctx) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002587 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302588 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 }
2590
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302591 /* validate config */
Jeff Johnson8095a312017-09-03 09:13:24 -07002592 if (!hdd_ctx->config) {
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302593 hdd_err("config is NULL");
2594 return QDF_STATUS_E_NULL_VALUE;
2595 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002596 /* HDD has initiated disconnect, do not send connect result indication
2597 * to kernel as it will be handled by __cfg80211_disconnect.
2598 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302599 if (((eConnectionState_Disconnecting ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07002600 sta_ctx->conn_info.connState) ||
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302601 (eConnectionState_NotConnected ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07002602 sta_ctx->conn_info.connState)) &&
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302603 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2604 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002605 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002606 sta_ctx->conn_info.connState,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002607 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 hddDisconInProgress = true;
2609 }
2610
2611 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07002612 if (NULL == roam_info) {
2613 hdd_err("roam_info is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302614 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002615 }
2616 if (!hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07002617 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 eConnectionState_Associated);
2619 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302620
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002621 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002622 hdd_conn_save_connect_info(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002624
Jeff Johnsonba388342017-10-02 13:31:01 -07002625 if (hdd_add_beacon_filter(adapter) != 0)
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002626 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627#ifdef FEATURE_WLAN_WAPI
Jeff Johnsonfd060852017-10-04 10:50:51 -07002628 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
Jeff Johnsonfd060852017-10-04 10:50:51 -07002630 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002632 adapter->wapi_info.is_wapi_sta = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002633 } else {
Jeff Johnson7d2f4c62017-11-02 09:25:45 -07002634 adapter->wapi_info.is_wapi_sta = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002635 }
2636#endif /* FEATURE_WLAN_WAPI */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002637 hdd_debug("bss_descr[%d] devicemode[%d]", !!roam_info->pBssDesc,
Jeff Johnsonba388342017-10-02 13:31:01 -07002638 adapter->device_mode);
2639 if ((QDF_STA_MODE == adapter->device_mode) &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07002640 roam_info->pBssDesc) {
2641 ie_len = GET_IE_LEN_IN_BSS(roam_info->pBssDesc->length);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002642 sta_ctx->ap_supports_immediate_power_save =
Krunal Soni364e0872017-05-10 21:24:34 -07002643 wlan_hdd_is_ap_supports_immediate_power_save(
Jeff Johnsonfd060852017-10-04 10:50:51 -07002644 (uint8_t *) roam_info->pBssDesc->ieFields,
Krunal Soni364e0872017-05-10 21:24:34 -07002645 ie_len);
2646 hdd_debug("ap_supports_immediate_power_save flag [%d]",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002647 sta_ctx->ap_supports_immediate_power_save);
Krunal Soni364e0872017-05-10 21:24:34 -07002648 }
2649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 /* Indicate 'connect' status to user space */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002651 hdd_send_association_event(dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002652
Jeff Johnson8095a312017-09-03 09:13:24 -07002653 if (policy_mgr_is_mcc_in_24G(hdd_ctx->hdd_psoc)) {
2654 if (hdd_ctx->miracast_value)
Jeff Johnsonba388342017-10-02 13:31:01 -07002655 wlan_hdd_set_mas(adapter,
Jeff Johnson8095a312017-09-03 09:13:24 -07002656 hdd_ctx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002657 }
2658
2659 /* Initialize the Linkup event completion variable */
Jeff Johnsonba388342017-10-02 13:31:01 -07002660 INIT_COMPLETION(adapter->linkup_event_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661
2662 /*
2663 * Sometimes Switching ON the Carrier is taking time to activate
2664 * the device properly. Before allowing any packet to go up to
2665 * the application, device activation has to be ensured for
2666 * proper queue mapping by the kernel. we have registered net
2667 * device notifier for device change notification. With this we
2668 * will come to know that the device is getting
2669 * activated properly.
2670 */
Jeff Johnsond377dce2017-10-04 10:32:42 -07002671 if (sta_ctx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002672 /*
2673 * Enable Linkup Event Servicing which allows the net
2674 * device notifier to set the linkup event variable.
2675 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002676 adapter->is_link_up_service_needed = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002678 /* Switch on the Carrier to activate the device */
Jeff Johnsonba388342017-10-02 13:31:01 -07002679 wlan_hdd_netif_queue_control(adapter,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002680 WLAN_NETIF_CARRIER_ON,
2681 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002683 /*
2684 * Wait for the Link to up to ensure all the queues
2685 * are set properly by the kernel.
2686 */
2687 rc = wait_for_completion_timeout(
Jeff Johnsonba388342017-10-02 13:31:01 -07002688 &adapter->linkup_event_var,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002689 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2690 );
2691 if (!rc)
2692 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002694 /*
2695 * Disable Linkup Event Servicing - no more service
2696 * required from the net device notifier call.
2697 */
Jeff Johnsonc72c5732017-10-28 12:49:37 -07002698 adapter->is_link_up_service_needed = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002699 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07002700 sta_ctx->ft_carrier_on = false;
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002701 ft_carrier_on = true;
2702 }
Rajeev Kumar7774cc82017-10-20 15:16:47 -07002703 if (roam_info->staId < HDD_MAX_ADAPTERS)
Jeff Johnsonfd060852017-10-04 10:50:51 -07002704 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002705 else
Jeff Johnsonfd060852017-10-04 10:50:51 -07002706 hdd_err("Wrong Staid: %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002707
Jeff Johnson8095a312017-09-03 09:13:24 -07002708 if (hdd_ipa_is_enabled(hdd_ctx))
Jeff Johnsonfd060852017-10-04 10:50:51 -07002709 hdd_ipa_wlan_evt(adapter, roam_info->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002710 HDD_IPA_STA_CONNECT,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002711 roam_info->bssid.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002712
2713#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
Jeff Johnson8095a312017-09-03 09:13:24 -07002714 wlan_hdd_auto_shutdown_enable(hdd_ctx, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715#endif
2716
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302717 hdd_debug("check if STA chan ok for DNBS");
Jeff Johnson8095a312017-09-03 09:13:24 -07002718 if (policy_mgr_is_chan_ok_for_dnbs(hdd_ctx->hdd_psoc,
Jeff Johnsond377dce2017-10-04 10:32:42 -07002719 sta_ctx->conn_info.operationChannel,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302720 &ok)) {
2721 hdd_err("Unable to check DNBS eligibility for chan:%d",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002722 sta_ctx->conn_info.operationChannel);
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302723 return QDF_STATUS_E_FAILURE;
2724 }
2725
2726 if (!ok) {
2727 hdd_err("Chan:%d not suitable for DNBS",
Jeff Johnsond377dce2017-10-04 10:32:42 -07002728 sta_ctx->conn_info.operationChannel);
Jeff Johnsonba388342017-10-02 13:31:01 -07002729 wlan_hdd_netif_queue_control(adapter,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302730 WLAN_NETIF_CARRIER_OFF,
2731 WLAN_CONTROL_PATH);
2732 if (!hddDisconInProgress) {
2733 hdd_err("Disconnecting...");
2734 sme_roam_disconnect(
Jeff Johnsonba388342017-10-02 13:31:01 -07002735 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002736 adapter->session_id,
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302737 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2738 }
2739 return QDF_STATUS_E_FAILURE;
2740 }
2741
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002742 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002743 policy_mgr_check_concurrent_intf_and_restart_sap(
Jeff Johnson8095a312017-09-03 09:13:24 -07002744 hdd_ctx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745
Nirav Shah1da77682016-05-03 20:16:39 +05302746 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002747 adapter->session_id,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002748 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302749 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002751 /*
2752 * For reassoc, the station is already registered, all we need
2753 * is to change the state of the STA in TL.
2754 * If authentication is required (WPA/WPA2/DWEP), change TL to
2755 * CONNECTED instead of AUTHENTICATED.
2756 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07002757 if (!roam_info->fReassocReq) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002759 u8 *pFTAssocRsp = NULL;
2760 unsigned int assocRsplen = 0;
2761 u8 *pFTAssocReq = NULL;
2762 unsigned int assocReqlen = 0;
2763 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002764 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2765 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2766
2767 /* add bss_id to cfg80211 data base */
2768 bss =
Jeff Johnsonba388342017-10-02 13:31:01 -07002769 wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002770 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002771 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302772 hdd_err("wlan: Not able to create BSS entry");
Jeff Johnsonba388342017-10-02 13:31:01 -07002773 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002774 WLAN_NETIF_CARRIER_OFF,
2775 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302776 if (!hddDisconInProgress) {
2777 /*
2778 * Here driver was not able to add bss
2779 * in cfg80211 database this can happen
2780 * if connected channel is not valid,
2781 * i.e reg domain was changed during
2782 * connection. Queue disconnect for the
2783 * session if disconnect is not in
2784 * progress.
2785 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002786 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302787 sme_roam_disconnect(
Jeff Johnsonba388342017-10-02 13:31:01 -07002788 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002789 adapter->session_id,
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302790 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2791 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302792 return QDF_STATUS_E_FAILURE;
Jiachao Wu0411bc92017-11-21 10:43:27 +08002793 } else {
2794 cfg80211_put_bss(
2795 hdd_ctx->wiphy,
2796 bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002797 }
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05302798
2799 /* Association Response */
2800 pFTAssocRsp =
2801 (u8 *) (roam_info->pbFrames +
2802 roam_info->nBeaconLength +
2803 roam_info->nAssocReqLength);
2804 if (pFTAssocRsp != NULL) {
2805 /*
2806 * pFTAssocRsp needs to point to the IEs
2807 */
2808 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2809 hdd_debug("AssocRsp is now at %02x%02x",
2810 (unsigned int)pFTAssocRsp[0],
2811 (unsigned int)pFTAssocRsp[1]);
2812 assocRsplen =
2813 roam_info->nAssocRspLength -
2814 FT_ASSOC_RSP_IES_OFFSET;
2815
2816 hdd_debug("assocRsplen %d", assocRsplen);
2817 hdd_debug("Assoc Rsp IE dump");
2818 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
2819 QDF_TRACE_LEVEL_DEBUG,
2820 pFTAssocRsp,
2821 assocRsplen);
2822 } else {
2823 hdd_debug("AssocRsp is NULL");
2824 assocRsplen = 0;
2825 }
2826
2827 /* Association Request */
2828 pFTAssocReq = (u8 *) (roam_info->pbFrames +
2829 roam_info->nBeaconLength);
2830 if (pFTAssocReq != NULL) {
2831 if (!ft_carrier_on) {
2832 /*
2833 * pFTAssocReq needs to point to
2834 * the IEs
2835 */
2836 pFTAssocReq +=
2837 FT_ASSOC_REQ_IES_OFFSET;
2838 hdd_debug("pFTAssocReq is now at %02x%02x",
2839 (unsigned int)
2840 pFTAssocReq[0],
2841 (unsigned int)
2842 pFTAssocReq[1]);
2843 assocReqlen =
2844 roam_info->nAssocReqLength -
2845 FT_ASSOC_REQ_IES_OFFSET;
2846 } else {
2847 /*
2848 * This should contain only the
2849 * FTIEs
2850 */
2851 assocReqlen =
2852 roam_info->nAssocReqLength;
2853 }
2854
2855 hdd_debug("assocReqlen %d", assocReqlen);
2856 hdd_debug("Assoc/Reassoc Req IE dump");
2857 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD,
2858 QDF_TRACE_LEVEL_DEBUG,
2859 pFTAssocReq,
2860 assocReqlen);
2861 } else {
2862 hdd_debug("AssocReq is NULL");
2863 assocReqlen = 0;
2864 }
2865
Jeff Johnsonfd060852017-10-04 10:50:51 -07002866 if (roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 eCSR_AUTH_TYPE_FT_RSN
Jeff Johnsonfd060852017-10-04 10:50:51 -07002868 || roam_info->u.pConnectedProfile->AuthType ==
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 eCSR_AUTH_TYPE_FT_RSN_PSK) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002870 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08002871 if (!hddDisconInProgress &&
Jeff Johnsonfd060852017-10-04 10:50:51 -07002872 roam_info->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302873 struct cfg80211_bss *roam_bss;
2874
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002875 /*
2876 * After roaming is completed,
2877 * active session count is
2878 * incremented as a part of
2879 * connect indication but
2880 * effectively the active
2881 * session count should still
2882 * be the same and hence upon
2883 * successful reassoc
2884 * decrement the active session
2885 * count here.
2886 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002887 if (!hdd_is_roam_sync_in_progress
Jeff Johnsonfd060852017-10-04 10:50:51 -07002888 (roam_info))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002889 policy_mgr_decr_session_set_pcl(
Jeff Johnson8095a312017-09-03 09:13:24 -07002890 hdd_ctx->hdd_psoc,
Jeff Johnsonba388342017-10-02 13:31:01 -07002891 adapter->device_mode,
Jeff Johnson1b780e42017-10-31 14:11:45 -07002892 adapter->session_id);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002893 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002894 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 chan =
2896 ieee80211_get_channel
Jeff Johnsonba388342017-10-02 13:31:01 -07002897 (adapter->wdev.wiphy,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002898 (int)roam_info->pBssDesc->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 channelId);
Naveen Rawat14298b92015-11-25 16:27:41 -08002900
Abhishek Singh533c9da2017-05-04 10:23:34 +05302901 roam_bss =
2902 hdd_cfg80211_get_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07002903 adapter->wdev.wiphy,
Abhishek Singh533c9da2017-05-04 10:23:34 +05302904 chan,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002905 roam_info->bssid.bytes,
2906 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05302907 pConnectedProfile->SSID.ssId,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002908 roam_info->u.
Abhishek Singh533c9da2017-05-04 10:23:34 +05302909 pConnectedProfile->SSID.length);
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302910 hdd_send_roamed_ind(
2911 dev,
2912 roam_bss,
2913 pFTAssocReq,
2914 assocReqlen,
2915 pFTAssocRsp,
2916 assocRsplen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302917 wlan_hdd_send_roam_auth_event(
Jeff Johnsonba388342017-10-02 13:31:01 -07002918 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002919 roam_info->bssid.bytes,
Abhishek Singh533c9da2017-05-04 10:23:34 +05302920 pFTAssocReq,
2921 assocReqlen,
2922 pFTAssocRsp,
2923 assocRsplen,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002924 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002925 }
2926 if (sme_get_ftptk_state
Jeff Johnsonba388342017-10-02 13:31:01 -07002927 (WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002928 adapter->session_id)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002929 sme_set_ftptk_state
2930 (WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07002931 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002932 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 false);
Jeff Johnsonfd060852017-10-04 10:50:51 -07002934 roam_info->fAuthRequired =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002935 false;
2936
Jeff Johnsond377dce2017-10-04 10:32:42 -07002937 qdf_mem_copy(sta_ctx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002938 roam_info.bssid,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002939 roam_info->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302940 QDF_MAC_ADDR_SIZE);
Jeff Johnsond377dce2017-10-04 10:32:42 -07002941 qdf_mem_copy(sta_ctx->
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002942 roam_info.peer_mac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002943 roam_info->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302944 QDF_MAC_ADDR_SIZE);
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002945 sta_ctx->roam_info.roam_id =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002946 roamId;
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002947 sta_ctx->roam_info.roam_status =
2948 roamStatus;
Jeff Johnsond377dce2017-10-04 10:32:42 -07002949 sta_ctx->roam_info.
Jeff Johnsonaf2ae4b2017-11-01 11:38:50 -07002950 defer_key_complete = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 }
2952 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002953 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002954 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302955 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002956 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302957 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002958 roam_info,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302959 pFTAssocReq,
2960 assocReqlen,
2961 pFTAssocRsp,
2962 assocRsplen,
2963 WLAN_STATUS_SUCCESS,
2964 GFP_KERNEL,
2965 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002966 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002968 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002969 /*
2970 * wpa supplicant expecting WPA/RSN IE in
2971 * connect result.
2972 */
2973 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07002974 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002975 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 &reqRsnLength,
2977 reqRsnIe);
2978
2979 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07002980 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07002981 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 &rspRsnLength,
2983 rspRsnIe);
2984 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002985 if (ft_carrier_on)
2986 hdd_send_re_assoc_event(dev,
Jeff Johnsonba388342017-10-02 13:31:01 -07002987 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07002988 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002989 reqRsnIe,
2990 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002991 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002992 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002993 MAC_ADDRESS_STR
2994 " result:%d and Status:%d",
2995 MAC_ADDR_ARRAY
Jeff Johnsonfd060852017-10-04 10:50:51 -07002996 (roam_info->bssid.bytes),
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002997 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998
2999 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05303000 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003001 roam_info->
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303002 bssid.bytes,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003003 roam_info,
Padma, Santhosh Kumar22614a02017-11-09 19:05:14 +05303004 pFTAssocReq,
3005 assocReqlen,
3006 pFTAssocRsp,
3007 assocRsplen,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303008 WLAN_STATUS_SUCCESS,
3009 GFP_KERNEL,
3010 false,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003011 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003012 }
3013 }
3014 }
3015 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003016 /*
3017 * Perform any WMM-related association
3018 * processing.
3019 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003020 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003021 eCSR_BSS_TYPE_INFRASTRUCTURE);
3022
3023 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08003024 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003025 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003026 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003027 roam_info,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003028 sta_ctx->conn_info.staId[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07003029 NULL, roam_info->pBssDesc);
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303030 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003031 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 WLAN_WAKE_ALL_NETIF_QUEUE,
3033 WLAN_CONTROL_PATH);
3034
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003035 }
3036 } else {
3037 /*
3038 * wpa supplicant expecting WPA/RSN IE in connect result
3039 * in case of reassociation also need to indicate it to
3040 * supplicant.
3041 */
3042 csr_roam_get_wpa_rsn_req_ie(
Jeff Johnsonba388342017-10-02 13:31:01 -07003043 WLAN_HDD_GET_HAL_CTX(adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003044 adapter->session_id,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 &reqRsnLength, reqRsnIe);
3046
Jeff Johnsonfd060852017-10-04 10:50:51 -07003047 hdd_send_re_assoc_event(dev, adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 reqRsnIe, reqRsnLength);
3049 /* Reassoc successfully */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003050 if (roam_info->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303051 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003052 hdd_change_peer_state(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003053 sta_ctx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003054 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003056 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057#else
3058 false
3059#endif
3060 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003061 hdd_conn_set_authenticated(adapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003062 hdd_objmgr_set_peer_mlme_auth_state(
Jeff Johnsonba388342017-10-02 13:31:01 -07003063 adapter->hdd_vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003064 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003065 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003066 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Jeff Johnsond377dce2017-10-04 10:32:42 -07003067 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303068 qdf_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07003069 hdd_change_peer_state(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003070 sta_ctx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003071 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003073 roam_info->roamSynchInProgress
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074#else
3075 false
3076#endif
3077 );
Jeff Johnsonba388342017-10-02 13:31:01 -07003078 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003079 hdd_objmgr_set_peer_mlme_auth_state(
Jeff Johnsonba388342017-10-02 13:31:01 -07003080 adapter->hdd_vdev,
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003081 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003082 }
3083
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303084 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 /*
3086 * Perform any WMM-related association
3087 * processing
3088 */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003089 hdd_wmm_assoc(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 eCSR_BSS_TYPE_INFRASTRUCTURE);
3091 }
3092
3093 /* Start the tx queues */
3094#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07003095 if (roam_info->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003096 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097#endif
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303098 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003099 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 WLAN_WAKE_ALL_NETIF_QUEUE,
3101 WLAN_CONTROL_PATH);
3102 }
3103
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303104 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003105 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303106 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 }
3108#ifdef WLAN_FEATURE_11W
Jeff Johnsondc179f42017-10-21 11:27:26 -07003109 qdf_mem_zero(&adapter->hdd_stats.hdd_pmf_stats,
3110 sizeof(adapter->hdd_stats.hdd_pmf_stats));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111#endif
3112 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303113 bool connect_timeout = false;
Vignesh Viswanathan014096a2017-12-07 01:24:44 +05303114 if (roam_info && roam_info->is_fils_connection &&
3115 eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult)
3116 qdf_copy_macaddr(&roam_info->bssid,
3117 &sta_ctx->requested_bssid);
Jeff Johnsonfd060852017-10-04 10:50:51 -07003118 if (roam_info)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303119 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003120 " result: %d and Status: %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003121 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303122 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303124 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003125 " result: %d and Status: %d",
Jeff Johnson731bc322017-10-14 19:53:44 -07003126 MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303127 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05303128
3129 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
Jeff Johnsonfd060852017-10-04 10:50:51 -07003130 (roam_info &&
Abhishek Singhc9941602016-08-09 16:06:22 +05303131 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003132 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303133 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003134 roam_info->statusCode) ||
Abhishek Singhc9941602016-08-09 16:06:22 +05303135 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
Jeff Johnsonfd060852017-10-04 10:50:51 -07003136 roam_info->statusCode)))) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003137 wlan_hdd_cfg80211_update_bss_list(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003138 roam_info ?
3139 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003140 sta_ctx->requested_bssid.bytes);
Jeff Johnson8095a312017-09-03 09:13:24 -07003141 sme_remove_bssid_from_scan_list(hdd_ctx->hHal,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003142 roam_info ?
3143 roam_info->bssid.bytes :
Jeff Johnson731bc322017-10-14 19:53:44 -07003144 sta_ctx->requested_bssid.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303145 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303146 }
3147
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003148 /*
3149 * CR465478: Only send up a connection failure result when CSR
3150 * has completed operation - with a ASSOCIATION_FAILURE status.
3151 */
3152 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3153 && !hddDisconInProgress) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003154 if (roam_info) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003155 hdd_err("send connect failure to nl80211: for bssid "
3156 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003157 " result: %d and Status: %d reasoncode: %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003158 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003159 roamResult, roamStatus,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003160 roam_info->reasonCode);
Jeff Johnsond377dce2017-10-04 10:32:42 -07003161 sta_ctx->conn_info.assoc_status_code =
Jeff Johnsonfd060852017-10-04 10:50:51 -07003162 roam_info->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003163 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003164 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003166 " result: %d and status: %d ",
Jeff Johnson731bc322017-10-14 19:53:44 -07003167 MAC_ADDR_ARRAY(sta_ctx->requested_bssid.bytes),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003168 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003169 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003170 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303171 wlan_deregister_txrx_packetdump();
3172
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003173 /* inform association failure event to nl80211 */
3174 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3175 roamResult) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003176 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303177 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003178 roam_info->bssid.bytes,
3179 roam_info, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303181 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303182 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003183 roam_info->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003184 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303185 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003186 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303187 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303189 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303190 connect_timeout,
3191 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07003193 if (roam_info)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303194 hdd_connect_result(dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003195 roam_info->bssid.bytes,
3196 roam_info, NULL, 0, NULL, 0,
3197 roam_info->reasonCode ?
3198 roam_info->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303200 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303201 connect_timeout,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003202 roam_info->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003203 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303204 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003205 sta_ctx->requested_bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303206 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303208 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303209 connect_timeout,
3210 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003212 hdd_clear_roam_profile_ie(adapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003213 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3214 && !hddDisconInProgress)) {
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003215 hdd_connect_result(dev,
Jeff Johnson731bc322017-10-14 19:53:44 -07003216 sta_ctx->requested_bssid.bytes,
Jeff Johnson59eb5fd2017-10-05 09:42:39 -07003217 NULL, NULL, 0, NULL, 0,
3218 WLAN_STATUS_UNSPECIFIED_FAILURE,
3219 GFP_KERNEL,
3220 connect_timeout,
3221 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003222 }
3223
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003224 /*
3225 * Set connection state to eConnectionState_NotConnected only
3226 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003227 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003228 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003229 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3230 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231 && !hddDisconInProgress) {
Jeff Johnsonba388342017-10-02 13:31:01 -07003232 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003233 eConnectionState_NotConnected);
3234 }
Jeff Johnsonba388342017-10-02 13:31:01 -07003235 hdd_wmm_init(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303237 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003238 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303239 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003240 WLAN_CONTROL_PATH);
3241 }
3242
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303243 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003244}
3245
3246/**
3247 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
Jeff Johnsonba388342017-10-02 13:31:01 -07003248 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003249 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 * @roamId: roam id
3251 * @roamStatus: roam status
3252 * @roamResult: roam result
3253 *
3254 * Here we update the status of the Ibss when we receive information that we
3255 * have started/joined an ibss session.
3256 *
3257 * Return: none
3258 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003259static void hdd_roam_ibss_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003260 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003261 uint32_t roamId,
3262 eRoamCmdStatus roamStatus,
3263 eCsrRoamResult roamResult)
3264{
Jeff Johnsonba388342017-10-02 13:31:01 -07003265 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003266
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003267 hdd_debug("%s: id %d, status %d, result %d",
Jeff Johnsonba388342017-10-02 13:31:01 -07003268 adapter->dev->name, roamId,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003269 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270
3271 switch (roamResult) {
3272 /* both IBSS Started and IBSS Join should come in here. */
3273 case eCSR_ROAM_RESULT_IBSS_STARTED:
3274 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3275 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3276 {
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003277 struct hdd_station_ctx *hdd_sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003278 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303279 struct qdf_mac_addr broadcastMacAddr =
3280 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Abhishek Singh44725482017-11-02 16:53:23 +05303281 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282
Jeff Johnsonfd060852017-10-04 10:50:51 -07003283 if (NULL == roam_info) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303284 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 return;
3286 }
3287
3288 /* When IBSS Started comes from CSR, we need to move
3289 * connection state to IBSS Disconnected (meaning no peers
3290 * are in the IBSS).
3291 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003292 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003293 eConnectionState_IbssDisconnected);
3294 /* notify wmm */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003295 hdd_wmm_connect(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003296 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303297
Jeff Johnsonfd060852017-10-04 10:50:51 -07003298 hdd_sta_ctx->broadcast_staid = roam_info->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303299
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003300 if (roam_info->staId < HDD_MAX_ADAPTERS)
3301 hdd_ctx->sta_to_adapter[roam_info->staId] =
3302 adapter;
3303 else
3304 hdd_debug("invalid sta id %d", roam_info->staId);
Abhishek Singh44725482017-11-02 16:53:23 +05303305
Jeff Johnsonfd060852017-10-04 10:50:51 -07003306 hdd_roam_register_sta(adapter, roam_info,
3307 roam_info->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 &broadcastMacAddr,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003309 roam_info->pBssDesc);
Abhishek Singh44725482017-11-02 16:53:23 +05303310 ret = hdd_objmgr_add_peer_object(adapter->hdd_vdev,
3311 QDF_IBSS_MODE,
3312 broadcastMacAddr.bytes,
3313 false);
3314 if (ret)
3315 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
3316 MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317
Jeff Johnsonfd060852017-10-04 10:50:51 -07003318 if (roam_info->pBssDesc) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319 struct cfg80211_bss *bss;
3320#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3321 struct ieee80211_channel *chan;
3322 int chan_no;
3323 unsigned int freq;
3324#endif
3325 /* we created the IBSS, notify supplicant */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303326 hdd_debug("%s: created ibss " MAC_ADDRESS_STR,
Jeff Johnsonba388342017-10-02 13:31:01 -07003327 adapter->dev->name,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003328 MAC_ADDR_ARRAY(
Jeff Johnsonfd060852017-10-04 10:50:51 -07003329 roam_info->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330
3331 /* we must first give cfg80211 the BSS information */
Jeff Johnsonba388342017-10-02 13:31:01 -07003332 bss = wlan_hdd_cfg80211_update_bss_db(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003333 roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003334 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003335 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003336 adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003337 return;
3338 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303339 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003340 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003341 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3342 WLAN_CONTROL_PATH);
3343
3344#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003345 chan_no = roam_info->pBssDesc->channelId;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003346
3347 if (chan_no <= 14)
3348 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003349 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 else
3351 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003352 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353
Jeff Johnsonba388342017-10-02 13:31:01 -07003354 chan = ieee80211_get_channel(adapter->wdev.wiphy, freq);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003355
3356 if (chan)
Jeff Johnsonba388342017-10-02 13:31:01 -07003357 cfg80211_ibss_joined(adapter->dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 bss->bssid, chan,
3359 GFP_KERNEL);
3360 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003361 hdd_warn("%s: chanId: %d, can't find channel",
Jeff Johnsonba388342017-10-02 13:31:01 -07003362 adapter->dev->name,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003363 (int)roam_info->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003364#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003365 cfg80211_ibss_joined(adapter->dev, bss->bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003366 GFP_KERNEL);
3367#endif
3368 cfg80211_put_bss(
Jeff Johnson8095a312017-09-03 09:13:24 -07003369 hdd_ctx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003370 bss);
3371 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003372 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003373 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003374 adapter->device_mode, adapter->session_id);
Krunal Soni2c68f232015-10-26 20:52:51 -07003375 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3376 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003377 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003378 adapter->session_id);
Krunal Soni2c68f232015-10-26 20:52:51 -07003379 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 break;
3381 }
3382
3383 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3384 {
Jeff Johnsonba388342017-10-02 13:31:01 -07003385 hdd_err("%s: unable to create IBSS", adapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003386 break;
3387 }
3388
3389 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003390 hdd_err("%s: unexpected result %d",
Jeff Johnsonba388342017-10-02 13:31:01 -07003391 adapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003392 break;
3393 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003394}
3395
3396/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003397 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3398 * @sta_ctx: pointer to hdd station context
3399 * @sta_id: station ID
3400 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003401 *
3402 * This information is passed to iwconfig later. The peer that joined
3403 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003404
3405 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003407bool hdd_save_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id,
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003408 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003409{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003410 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003412 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303413 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003414 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003415 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003416 sta_ctx->conn_info.staId[idx] = sta_id;
3417 qdf_copy_macaddr(
3418 &sta_ctx->conn_info.peerMacAddress[idx],
3419 peer_mac_addr);
3420 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 }
3422 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003423 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003424}
3425
3426/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003427 * hdd_delete_peer() - removes peer from hdd station context peer table
3428 * @sta_ctx: pointer to hdd station context
3429 * @sta_id: station ID
3430 *
3431 * Return: None
3432 */
Jeff Johnson40dae4e2017-08-29 14:00:25 -07003433void hdd_delete_peer(struct hdd_station_ctx *sta_ctx, uint8_t sta_id)
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003434{
3435 int i;
3436
3437 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3438 if (sta_id == sta_ctx->conn_info.staId[i]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303439 sta_ctx->conn_info.staId[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003440 return;
3441 }
3442 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003443}
3444
3445/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
Jeff Johnsonba388342017-10-02 13:31:01 -07003447 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003448 * @staId: station id
3449 *
3450 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003451 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003452 * false otherwise.
3453 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003454static bool roam_remove_ibss_station(struct hdd_adapter *adapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455{
3456 bool fSuccess = false;
3457 int idx = 0;
3458 uint8_t valid_idx = 0;
3459 uint8_t del_idx = 0;
3460 uint8_t empty_slots = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003461 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462
Naveen Rawatc45d1622016-07-05 12:20:09 -07003463 for (idx = 0; idx < MAX_PEERS; idx++) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003464 if (staId == sta_ctx->conn_info.staId[idx]) {
3465 sta_ctx->conn_info.staId[idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303466 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467
Jeff Johnsond377dce2017-10-04 10:32:42 -07003468 qdf_zero_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003469 peerMacAddress[idx]);
3470
3471 fSuccess = true;
3472
3473 /*
3474 * Note the deleted Index, if its 0 we need special
3475 * handling.
3476 */
3477 del_idx = idx;
3478
3479 empty_slots++;
3480 } else {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003481 if (sta_ctx->conn_info.staId[idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003482 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 valid_idx = idx;
3484 } else {
3485 /* Found an empty slot */
3486 empty_slots++;
3487 }
3488 }
3489 }
3490
Naveen Rawatc45d1622016-07-05 12:20:09 -07003491 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003492 /* Last peer departed, set the IBSS state appropriately */
Jeff Johnsonba388342017-10-02 13:31:01 -07003493 hdd_conn_set_connection_state(adapter,
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003494 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003495 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 }
3497 /* Find next active staId, to have a valid sta trigger for TL. */
3498 if (fSuccess == true) {
3499 if (del_idx == 0) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003500 if (sta_ctx->conn_info.staId[valid_idx] !=
Naveen Rawatac027cb2017-04-27 15:02:42 -07003501 HDD_WLAN_INVALID_STA_ID) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003502 sta_ctx->conn_info.staId[0] =
3503 sta_ctx->conn_info.staId[valid_idx];
3504 qdf_copy_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003505 peerMacAddress[0],
Jeff Johnsond377dce2017-10-04 10:32:42 -07003506 &sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003507 peerMacAddress[valid_idx]);
3508
Jeff Johnsond377dce2017-10-04 10:32:42 -07003509 sta_ctx->conn_info.staId[valid_idx] =
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303510 HDD_WLAN_INVALID_STA_ID;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003511 qdf_zero_macaddr(&sta_ctx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 peerMacAddress[valid_idx]);
3513 }
3514 }
3515 }
3516 return fSuccess;
3517}
3518
3519/**
3520 * roam_ibss_connect_handler() - IBSS connection handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003521 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003522 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003523 *
3524 * We update the status of the IBSS to connected in this function.
3525 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303526 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003528static QDF_STATUS roam_ibss_connect_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003529 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003530{
3531 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 /*
3533 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3534 * a partner stations).
3535 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003536 hdd_conn_set_connection_state(adapter, eConnectionState_IbssConnected);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003537
3538 /* Save the connection info from CSR... */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003539 hdd_conn_save_connect_info(adapter, roam_info, eCSR_BSS_TYPE_IBSS);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003540
3541 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003542 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543 /* add bss_id to cfg80211 data base */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003544 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003546 hdd_err("%s: unable to create IBSS entry",
Jeff Johnsonba388342017-10-02 13:31:01 -07003547 adapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303548 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 }
3550 cfg80211_put_bss(
Jeff Johnsonba388342017-10-02 13:31:01 -07003551 WLAN_HDD_GET_CTX(adapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 bss);
3553
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303554 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555}
3556
3557/**
3558 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
Jeff Johnsonba388342017-10-02 13:31:01 -07003559 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003560 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 * @roamId: roam id
3562 * @roamStatus: roam status
3563 * @roamResult: roam result
3564 *
3565 * This function indicates the Mic failure to the supplicant
3566 *
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003567 * Return: None
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 */
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003569static void
Jeff Johnsonba388342017-10-02 13:31:01 -07003570hdd_roam_mic_error_indication_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003571 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572{
Jeff Johnsond377dce2017-10-04 10:32:42 -07003573 struct hdd_station_ctx *sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003574 tSirMicFailureInfo *mic_failure_info;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003575
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003576 if (eConnectionState_Associated != sta_ctx->conn_info.connState)
3577 return;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003578
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07003579 mic_failure_info = roam_info->u.pMICFailureInfo;
3580 cfg80211_michael_mic_failure(adapter->dev,
3581 mic_failure_info->taMacAddr,
3582 mic_failure_info->multicast ?
3583 NL80211_KEYTYPE_GROUP :
3584 NL80211_KEYTYPE_PAIRWISE,
3585 mic_failure_info->keyId,
3586 mic_failure_info->TSC,
3587 GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003588}
3589
3590/**
3591 * roam_roam_connect_status_update_handler() - IBSS connect status update
Jeff Johnsonba388342017-10-02 13:31:01 -07003592 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003593 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003594 * @roamId: roam id
3595 * @roamStatus: roam status
3596 * @roamResult: roam result
3597 *
3598 * The Ibss connection status is updated regularly here in this function.
3599 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303600 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003601 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303602static QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07003603roam_roam_connect_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003604 struct csr_roam_info *roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003605 uint32_t roamId,
3606 eRoamCmdStatus roamStatus,
3607 eCsrRoamResult roamResult)
3608{
Jeff Johnsonba388342017-10-02 13:31:01 -07003609 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003610 QDF_STATUS qdf_status;
Abhishek Singh44725482017-11-02 16:53:23 +05303611 int ret;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303612
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003613 switch (roamResult) {
3614 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3615 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003616 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003617 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003618 struct station_info *stainfo;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003619 eCsrEncryptionType encr_type = sta_ctx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003620
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303621 hdd_debug("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303622 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3623 MAC_ADDRESS_STR " and stationID= %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003624 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
Jeff Johnsond377dce2017-10-04 10:32:42 -07003625 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003626 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003627
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003628 if (!hdd_save_peer
Jeff Johnsonba388342017-10-02 13:31:01 -07003629 (WLAN_HDD_GET_STATION_CTX_PTR(adapter),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003630 roam_info->staId,
3631 &roam_info->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003632 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003633 break;
3634 }
3635
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003636 if (roam_info->staId < HDD_MAX_ADAPTERS)
3637 hdd_ctx->sta_to_adapter[roam_info->staId] = adapter;
3638 else
3639 hdd_debug("invalid sta id %d", roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003641 if (hdd_is_key_install_required_for_ibss(encr_type))
Jeff Johnsonfd060852017-10-04 10:50:51 -07003642 roam_info->fAuthRequired = true;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003643
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003644 /* Register the Station with TL for the new peer. */
Jeff Johnsonba388342017-10-02 13:31:01 -07003645 qdf_status = hdd_roam_register_sta(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003646 roam_info,
3647 roam_info->staId,
3648 &roam_info->peerMac,
3649 roam_info->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003651 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303652 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 }
Abhishek Singh44725482017-11-02 16:53:23 +05303654 ret = hdd_objmgr_add_peer_object(adapter->hdd_vdev,
3655 QDF_IBSS_MODE,
3656 roam_info->peerMac.bytes,
3657 false);
3658 if (ret)
3659 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
3660 MAC_ADDR_ARRAY(roam_info->peerMac.bytes));
Jeff Johnsond377dce2017-10-04 10:32:42 -07003661 sta_ctx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003662 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3663 if (stainfo == NULL) {
3664 hdd_err("memory allocation for station_info failed");
3665 return QDF_STATUS_E_NOMEM;
3666 }
3667 stainfo->filled = 0;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003668 stainfo->generation = sta_ctx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003669
Jeff Johnsonba388342017-10-02 13:31:01 -07003670 cfg80211_new_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003671 (const u8 *)roam_info->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003672 stainfo, GFP_KERNEL);
3673 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003675 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003676 sta_ctx->ibss_enc_key.keyDirection =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 eSIR_TX_RX;
Jeff Johnsond377dce2017-10-04 10:32:42 -07003678 qdf_copy_macaddr(&sta_ctx->ibss_enc_key.peerMac,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003679 &roam_info->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003680
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303681 hdd_debug("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003682 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003683
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303684 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003685 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
Jeff Johnsonba388342017-10-02 13:31:01 -07003686 (adapter),
Jeff Johnson1b780e42017-10-31 14:11:45 -07003687 adapter->session_id,
Jeff Johnsond377dce2017-10-04 10:32:42 -07003688 &sta_ctx->ibss_enc_key,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003689 &roamId);
3690
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303691 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003692 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003693 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303694 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 }
3696 }
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303697 hdd_debug("Enabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003698 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3700 WLAN_CONTROL_PATH);
3701 break;
3702 }
3703
3704 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3705 {
3706
Jeff Johnsonfd060852017-10-04 10:50:51 -07003707 roam_ibss_connect_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708
3709 break;
3710 }
3711 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3712 {
Jeff Johnsond377dce2017-10-04 10:32:42 -07003713 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07003714 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715
Jeff Johnsonfd060852017-10-04 10:50:51 -07003716 if (!roam_remove_ibss_station(adapter, roam_info->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003717 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003718
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303719 hdd_debug("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303720 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3721 MAC_ADDRESS_STR " and stationID= %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07003722 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
Jeff Johnsond377dce2017-10-04 10:32:42 -07003723 MAC_ADDR_ARRAY(sta_ctx->conn_info.bssId.bytes),
Jeff Johnsonfd060852017-10-04 10:50:51 -07003724 roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725
Jeff Johnsonfd060852017-10-04 10:50:51 -07003726 hdd_roam_deregister_sta(adapter, roam_info->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003727
Rajeev Kumar7774cc82017-10-20 15:16:47 -07003728 if (roam_info->staId < HDD_MAX_ADAPTERS)
3729 hdd_ctx->sta_to_adapter[roam_info->staId] = NULL;
3730 else
3731 hdd_debug("invalid sta id %d", roam_info->staId);
3732
Jeff Johnsond377dce2017-10-04 10:32:42 -07003733 sta_ctx->ibss_sta_generation++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734
Jeff Johnsonba388342017-10-02 13:31:01 -07003735 cfg80211_del_sta(adapter->dev,
Jeff Johnsonfd060852017-10-04 10:50:51 -07003736 (const u8 *)&roam_info->peerMac.bytes,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003737 GFP_KERNEL);
3738 break;
3739 }
3740 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3741 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003742 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003743 /* Stop only when we are inactive */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05303744 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07003745 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303746 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07003748 hdd_conn_set_connection_state(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003749 eConnectionState_NotConnected);
3750
3751 /* Send the bssid address to the wext. */
Jeff Johnsonfd060852017-10-04 10:50:51 -07003752 hdd_send_association_event(adapter->dev, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753 break;
3754 }
3755 default:
3756 break;
3757
3758 }
3759
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303760 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003761}
3762
3763#ifdef FEATURE_WLAN_TDLS
3764/**
3765 * hdd_roam_register_tdlssta() - register new TDLS station
Jeff Johnsonba388342017-10-02 13:31:01 -07003766 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767 * @peerMac: pointer to peer MAC address
3768 * @staId: station identifier
3769 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303770 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003771 *
3772 * Construct the staDesc and register with TL the new STA.
3773 * This is called as part of ADD_STA in the TDLS setup.
3774 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303775 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003776 */
Jeff Johnsonba388342017-10-02 13:31:01 -07003777QDF_STATUS hdd_roam_register_tdlssta(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303779 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303781 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003782 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003783 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003784 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3785 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786
3787 /*
3788 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3789 * be peer MAC, here we are working on direct Link
3790 */
3791 staDesc.sta_id = staId;
3792
3793 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303794 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795
Dhanashri Atre50141c52016-04-07 13:15:29 -07003796 /* Register the vdev transmit and receive functions */
3797 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3798 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003799 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003800 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07003801 (struct cdp_pdev *)pdev, adapter->session_id),
Jeff Johnsonba388342017-10-02 13:31:01 -07003802 adapter, &txrx_ops);
3803 adapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003804
3805 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003806 qdf_status = cdp_peer_register(soc,
3807 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303808 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003809 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303810 qdf_status, qdf_status);
3811 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003812 }
3813
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303814 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815}
3816
3817/**
3818 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
Jeff Johnsonba388342017-10-02 13:31:01 -07003819 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003820 * @staId: station identifier
3821 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303822 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 */
Jeff Johnson53367842017-10-03 11:10:34 -07003824QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
3825 uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303827 QDF_STATUS qdf_status;
Jeff Johnson4f7f7c62017-10-05 08:53:41 -07003828
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003829 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003830 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3831 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303832 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003833 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003834 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003835 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303836 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837}
3838
Kabilan Kannan32eb5022016-10-04 12:24:50 -07003839#else
3840
Jeff Johnsonba388342017-10-02 13:31:01 -07003841inline QDF_STATUS hdd_roam_deregister_tdlssta(struct hdd_adapter *adapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07003842 uint8_t staId)
3843{
3844 return QDF_STATUS_SUCCESS;
3845}
3846
3847static inline QDF_STATUS
Jeff Johnsonba388342017-10-02 13:31:01 -07003848hdd_roam_tdls_status_update_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08003849 struct csr_roam_info *roam_info,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07003850 uint32_t roamId,
3851 eRoamCmdStatus roamStatus,
3852 eCsrRoamResult roamResult)
3853{
3854 return QDF_STATUS_SUCCESS;
3855}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856#endif
3857
3858#ifdef WLAN_FEATURE_11W
3859/**
3860 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
Jeff Johnsonba388342017-10-02 13:31:01 -07003861 * @adapter: pointer to the adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003862 * @nFrameLength: Length of the unprotected frame being passed
3863 * @pbFrames: Pointer to the frame buffer
3864 * @frameType: 802.11 frame type
3865 *
3866 * This function forwards the unprotected management frame to the supplicant.
3867 *
3868 * Return: nothing
3869 */
3870static void
Jeff Johnson435e1b82017-10-07 14:13:10 -07003871hdd_indicate_unprot_mgmt_frame(struct hdd_adapter *adapter,
3872 uint32_t nFrameLength,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 uint8_t *pbFrames, uint8_t frameType)
3874{
3875 uint8_t type = 0;
3876 uint8_t subType = 0;
3877
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003878 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003879 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003880
3881 /* Sanity Checks */
Jeff Johnsonba388342017-10-02 13:31:01 -07003882 if (NULL == adapter) {
3883 hdd_err("adapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 return;
3885 }
3886
Jeff Johnsonba388342017-10-02 13:31:01 -07003887 if (NULL == adapter->dev) {
3888 hdd_err("adapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 return;
3890 }
3891
Jeff Johnsonba388342017-10-02 13:31:01 -07003892 if (WLAN_HDD_ADAPTER_MAGIC != adapter->magic) {
3893 hdd_err("adapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 return;
3895 }
3896
3897 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003898 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 return;
3900 }
3901
3902 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003903 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904 return;
3905 }
3906
3907 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3908 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3909
Jeff Johnsonba388342017-10-02 13:31:01 -07003910 /* Get adapter from Destination mac address of the frame */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
3912#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
Jeff Johnsonba388342017-10-02 13:31:01 -07003913 cfg80211_rx_unprot_mlme_mgmt(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 nFrameLength);
3915#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003916 cfg80211_send_unprot_disassoc(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 nFrameLength);
3918#endif
Jeff Johnsondc179f42017-10-21 11:27:26 -07003919 adapter->hdd_stats.hdd_pmf_stats.num_unprot_disassoc_rx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003920 } else if (type == SIR_MAC_MGMT_FRAME &&
3921 subType == SIR_MAC_MGMT_DEAUTH) {
3922#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
Jeff Johnsonba388342017-10-02 13:31:01 -07003923 cfg80211_rx_unprot_mlme_mgmt(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 nFrameLength);
3925#else
Jeff Johnsonba388342017-10-02 13:31:01 -07003926 cfg80211_send_unprot_deauth(adapter->dev, pbFrames,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 nFrameLength);
3928#endif
Jeff Johnsondc179f42017-10-21 11:27:26 -07003929 adapter->hdd_stats.hdd_pmf_stats.num_unprot_deauth_rx++;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003930 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003931 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003932 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003933 return;
3934 }
3935}
3936#endif
3937
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003938#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939/**
3940 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
Jeff Johnsonba388342017-10-02 13:31:01 -07003941 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003942 * @tid: traffic identifier
3943 * @state: state
3944 * @measInterval: measurement interval
3945 *
3946 * This function sends traffic stream metrics IE information to
3947 * the supplicant via wireless event.
3948 *
3949 * Return: none
3950 */
3951static void
Jeff Johnsonba388342017-10-02 13:31:01 -07003952hdd_indicate_tsm_ie(struct hdd_adapter *adapter, uint8_t tid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003953 uint8_t state, uint16_t measInterval)
3954{
3955 union iwreq_data wrqu;
3956 char buf[IW_CUSTOM_MAX + 1];
3957 int nBytes = 0;
3958
Jeff Johnsonba388342017-10-02 13:31:01 -07003959 if (NULL == adapter)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003960 return;
3961
3962 /* create the event */
3963 memset(&wrqu, '\0', sizeof(wrqu));
3964 memset(buf, '\0', sizeof(buf));
3965
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003966 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003967 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003968
3969 nBytes =
3970 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
3971 measInterval);
3972
3973 wrqu.data.pointer = buf;
3974 wrqu.data.length = nBytes;
3975 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07003976 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003977}
3978
3979/**
3980 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
Jeff Johnsonba388342017-10-02 13:31:01 -07003981 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07003982 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 *
3984 * This function sends cckm preauth indication to the supplicant
3985 * via wireless custom event.
3986 *
3987 * Return: none
3988 */
3989static void
Jeff Johnson172237b2017-11-07 15:32:59 -08003990hdd_indicate_cckm_pre_auth(struct hdd_adapter *adapter,
3991 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992{
3993 union iwreq_data wrqu;
3994 char buf[IW_CUSTOM_MAX + 1];
3995 char *pos = buf;
3996 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3997
Jeff Johnsonfd060852017-10-04 10:50:51 -07003998 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 return;
4000
4001 /* create the event */
4002 memset(&wrqu, '\0', sizeof(wrqu));
4003 memset(buf, '\0', sizeof(buf));
4004
4005 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004006 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004007 MAC_ADDR_ARRAY(roam_info->bssid.bytes),
4008 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009
4010 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4011 pos += nBytes;
4012 freeBytes -= nBytes;
4013
Jeff Johnsonfd060852017-10-04 10:50:51 -07004014 qdf_mem_copy(pos, roam_info->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304015 pos += QDF_MAC_ADDR_SIZE;
4016 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017
4018 nBytes = snprintf(pos, freeBytes, " %u:%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004019 roam_info->timestamp[0], roam_info->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004020 freeBytes -= nBytes;
4021
4022 wrqu.data.pointer = buf;
4023 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4024
4025 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004026 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004027}
4028
4029/**
4030 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004031 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004032 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004033 *
4034 * Return: none
4035 */
4036static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004037hdd_indicate_ese_adj_ap_rep_ind(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004038 struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039{
4040 union iwreq_data wrqu;
4041 char buf[IW_CUSTOM_MAX + 1];
4042 int nBytes = 0;
4043
Jeff Johnsonfd060852017-10-04 10:50:51 -07004044 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 return;
4046
4047 /* create the event */
4048 memset(&wrqu, '\0', sizeof(wrqu));
4049 memset(buf, '\0', sizeof(buf));
4050
Jeff Johnsonfd060852017-10-04 10:50:51 -07004051 hdd_debug("CCXADJAPREP=%u", roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004052
4053 nBytes =
4054 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004055 roam_info->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004056
4057 wrqu.data.pointer = buf;
4058 wrqu.data.length = nBytes;
4059
4060 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004061 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062}
4063
4064/**
4065 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
Jeff Johnsonba388342017-10-02 13:31:01 -07004066 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 * @measurementToken: measurement token
4068 * @flag: flag
4069 * @numBss: number of bss
4070 *
4071 * If the measurement is none and no scan results found,
4072 * indicate the supplicant about measurement done.
4073 *
4074 * Return: none
4075 */
4076void
Jeff Johnsonba388342017-10-02 13:31:01 -07004077hdd_indicate_ese_bcn_report_no_results(const struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 const uint16_t measurementToken,
4079 const bool flag, const uint8_t numBss)
4080{
4081 union iwreq_data wrqu;
4082 char buf[IW_CUSTOM_MAX];
4083 char *pos = buf;
4084 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4085
4086 memset(&wrqu, '\0', sizeof(wrqu));
4087 memset(buf, '\0', sizeof(buf));
4088
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004089 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004090 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004091
4092 nBytes =
4093 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4094 flag, numBss);
4095
4096 wrqu.data.pointer = buf;
4097 wrqu.data.length = nBytes;
4098 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004099 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu, buf);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004100}
4101
4102/**
4103 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
Jeff Johnsonba388342017-10-02 13:31:01 -07004104 * @adapter: pointer to adapter
Jeff Johnsonfd060852017-10-04 10:50:51 -07004105 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 *
4107 * If the measurement is none and no scan results found,
4108 * indicate the supplicant about measurement done.
4109 *
4110 * Return: none
4111 */
4112static void
Jeff Johnsonba388342017-10-02 13:31:01 -07004113hdd_indicate_ese_bcn_report_ind(const struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004114 const struct csr_roam_info *roam_info)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004115{
4116 union iwreq_data wrqu;
4117 char buf[IW_CUSTOM_MAX];
4118 char *pos = buf;
4119 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4120 uint8_t i = 0, len = 0;
4121 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4122 uint8_t lastSent = 0, sendBss = 0;
4123 int bcnRepFieldSize =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004124 sizeof(roam_info->pEseBcnReportRsp->bcnRepBssInfo[0].
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004125 bcnReportFields);
4126 uint8_t ieLenByte = 1;
4127 /*
4128 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4129 */
4130#define ESEBCNREPHEADER_LEN (18)
4131
Jeff Johnsonfd060852017-10-04 10:50:51 -07004132 if ((NULL == adapter) || (NULL == roam_info))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004133 return;
4134
4135 /*
4136 * Custom event can pass maximum of 256 bytes of data,
4137 * based on the IE len we need to identify how many BSS info can
4138 * be filled in to custom event data.
4139 */
4140 /*
4141 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4142 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4143 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4144 */
4145
Jeff Johnsonfd060852017-10-04 10:50:51 -07004146 if ((roam_info->pEseBcnReportRsp->flag >> 1)
4147 && (!roam_info->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004148 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004150 * indicate the supplicant about measurement done
4151 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 hdd_indicate_ese_bcn_report_no_results(
Jeff Johnsonba388342017-10-02 13:31:01 -07004153 adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004154 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004156 roam_info->pEseBcnReportRsp->flag,
4157 roam_info->pEseBcnReportRsp->numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 } else {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004159 while (lastSent < roam_info->pEseBcnReportRsp->numBss) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004160 memset(&wrqu, '\0', sizeof(wrqu));
4161 memset(buf, '\0', sizeof(buf));
4162 tot_bcn_ieLen = 0;
4163 sendBss = 0;
4164 pos = buf;
4165 freeBytes = IW_CUSTOM_MAX;
4166
4167 for (i = lastSent;
Jeff Johnsonfd060852017-10-04 10:50:51 -07004168 i < roam_info->pEseBcnReportRsp->numBss; i++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 len =
4170 bcnRepFieldSize + ieLenByte +
Jeff Johnsonfd060852017-10-04 10:50:51 -07004171 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004172 bcnRepBssInfo[i].ieLen;
4173 if ((len + tot_bcn_ieLen) >
4174 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4175 break;
4176 }
4177 tot_bcn_ieLen += len;
4178 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004179 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004180 i, bcnRepFieldSize, 1,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004181 roam_info->pEseBcnReportRsp->
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004182 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004183 }
4184
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004185 hdd_debug("Sending %d BSS Info", sendBss);
4186 hdd_debug("CCXBCNREP=%d %d %d %d",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004187 roam_info->pEseBcnReportRsp->measurementToken,
4188 roam_info->pEseBcnReportRsp->flag, sendBss,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004189 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004190
4191 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004192 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004193 measurementToken,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004194 roam_info->pEseBcnReportRsp->flag,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 sendBss);
4196 pos += nBytes;
4197 freeBytes -= nBytes;
4198
4199 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304200 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 sizeof(tot_bcn_ieLen));
4202 pos += sizeof(tot_bcn_ieLen);
4203 freeBytes -= sizeof(tot_bcn_ieLen);
4204
4205 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004206 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4208 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4209 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Jeff Johnsonfd060852017-10-04 10:50:51 -07004210 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004211 bcnRepBssInfo[i +
4212 lastSent].bcnReportFields.
4213 ChanNum,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004214 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 bcnRepBssInfo[i +
4216 lastSent].bcnReportFields.
4217 Spare,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004218 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004219 bcnRepBssInfo[i +
4220 lastSent].bcnReportFields.
4221 MeasDuration,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004222 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 bcnRepBssInfo[i +
4224 lastSent].bcnReportFields.
4225 PhyType,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004226 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004227 bcnRepBssInfo[i +
4228 lastSent].bcnReportFields.
4229 RecvSigPower,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004230 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004231 bcnRepBssInfo[i +
4232 lastSent].bcnReportFields.
4233 ParentTsf,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004234 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 bcnRepBssInfo[i +
4236 lastSent].bcnReportFields.
4237 TargetTsf[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004238 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004239 bcnRepBssInfo[i +
4240 lastSent].bcnReportFields.
4241 TargetTsf[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004242 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 bcnRepBssInfo[i +
4244 lastSent].bcnReportFields.
4245 BcnInterval,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004246 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 bcnRepBssInfo[i +
4248 lastSent].bcnReportFields.
4249 CapabilityInfo,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004250 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 bcnRepBssInfo[i +
4252 lastSent].bcnReportFields.
4253 Bssid[0],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004254 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 bcnRepBssInfo[i +
4256 lastSent].bcnReportFields.
4257 Bssid[1],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004258 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004259 bcnRepBssInfo[i +
4260 lastSent].bcnReportFields.
4261 Bssid[2],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004262 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263 bcnRepBssInfo[i +
4264 lastSent].bcnReportFields.
4265 Bssid[3],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004266 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004267 bcnRepBssInfo[i +
4268 lastSent].bcnReportFields.
4269 Bssid[4],
Jeff Johnsonfd060852017-10-04 10:50:51 -07004270 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004271 bcnRepBssInfo[i +
4272 lastSent].bcnReportFields.
4273 Bssid[5]);
4274
4275 /* bcn report fields are copied */
4276 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004277 sizeof(roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004278 bcnRepBssInfo[i +
4279 lastSent].
4280 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304281 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004282 (char *)&roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004283 pEseBcnReportRsp->bcnRepBssInfo[i +
4284 lastSent].
4285 bcnReportFields, len);
4286 pos += len;
4287 freeBytes -= len;
4288
4289 /* Add 1 byte of ie len */
4290 len =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004291 roam_info->pEseBcnReportRsp->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304293 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004294 pos += sizeof(len);
4295 freeBytes -= sizeof(len);
4296
4297 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304298 qdf_mem_copy(pos,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004299 (char *)roam_info->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004300 pEseBcnReportRsp->bcnRepBssInfo[i +
4301 lastSent].
4302 pBuf, len);
4303 pos += len;
4304 freeBytes -= len;
4305 }
4306
4307 wrqu.data.pointer = buf;
4308 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4309
4310 /* send the event */
Jeff Johnsonba388342017-10-02 13:31:01 -07004311 wireless_send_event(adapter->dev, IWEVCUSTOM, &wrqu,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 buf);
4313 lastSent += sendBss;
4314 }
4315 }
4316}
4317
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004318#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319
4320/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304321 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
Jeff Johnsond377dce2017-10-04 10:32:42 -07004322 * @sta_ctx: Station Context
Komal Seelam98760ba2015-12-15 11:05:18 +05304323 *
4324 * API to check if the connection authentication type is 8021x_sha256.
4325 *
4326 * Return: bool
4327 */
4328#ifdef WLAN_FEATURE_11W
Jeff Johnson435e1b82017-10-07 14:13:10 -07004329static inline bool
4330hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304331{
4332 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004333 sta_ctx->conn_info.authType;
Komal Seelam98760ba2015-12-15 11:05:18 +05304334}
4335#else
Jeff Johnson435e1b82017-10-07 14:13:10 -07004336static inline bool
4337hdd_is_8021x_sha256_auth_type(struct hdd_station_ctx *sta_ctx)
Komal Seelam98760ba2015-12-15 11:05:18 +05304338{
4339 return false;
4340}
4341#endif
4342
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304343/*
4344 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4345 * @adapter: Pointer to adapter context
4346 * @roam_info: Pointer to roam info
4347 *
4348 * Return: None
4349 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004350static void hdd_roam_channel_switch_handler(struct hdd_adapter *adapter,
Jeff Johnson172237b2017-11-07 15:32:59 -08004351 struct csr_roam_info *roam_info)
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304352{
4353 struct hdd_chan_change_params chan_change;
4354 struct cfg80211_bss *bss;
4355 struct net_device *dev = adapter->dev;
4356 struct wireless_dev *wdev = dev->ieee80211_ptr;
4357 struct wiphy *wiphy = wdev->wiphy;
4358 QDF_STATUS status;
Jeff Johnson49432062017-08-28 12:08:45 -07004359 struct hdd_context *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304360
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004361 hdd_debug("channel switch for session:%d to channel:%d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004362 adapter->session_id, roam_info->chan_info.chan_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304363
4364 chan_change.chan = roam_info->chan_info.chan_id;
4365 chan_change.chan_params.ch_width =
4366 roam_info->chan_info.ch_width;
4367 chan_change.chan_params.sec_ch_offset =
4368 roam_info->chan_info.sec_ch_offset;
4369 chan_change.chan_params.center_freq_seg0 =
4370 roam_info->chan_info.band_center_freq1;
4371 chan_change.chan_params.center_freq_seg1 =
4372 roam_info->chan_info.band_center_freq2;
4373
4374 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4375 if (NULL == bss)
4376 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4377 else
4378 cfg80211_put_bss(wiphy, bss);
4379
bings58ce8622017-07-10 15:55:36 +08004380 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4381 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304382 if (QDF_IS_STATUS_ERROR(status))
4383 hdd_err("channel change notification failed");
4384
Ganesh Kondabattini41f34782017-09-14 21:14:29 +05304385 hdd_debug("check for SAP restart");
4386 policy_mgr_check_concurrent_intf_and_restart_sap(hdd_ctx->hdd_psoc);
4387
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004388 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004389 adapter->session_id);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304390 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004391 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304392}
4393
Komal Seelam98760ba2015-12-15 11:05:18 +05304394/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004395 * hdd_sme_roam_callback() - hdd sme roam callback
4396 * @pContext: pointer to adapter context
Jeff Johnsonfd060852017-10-04 10:50:51 -07004397 * @roam_info: pointer to roam info
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 * @roamId: roam id
4399 * @roamStatus: roam status
4400 * @roamResult: roam result
4401 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304402 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304404QDF_STATUS
Jeff Johnson172237b2017-11-07 15:32:59 -08004405hdd_sme_roam_callback(void *pContext, struct csr_roam_info *roam_info,
4406 uint32_t roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4408{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304409 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Jeff Johnsonba388342017-10-02 13:31:01 -07004410 struct hdd_adapter *adapter = (struct hdd_adapter *) pContext;
Jeff Johnson2a722002017-09-30 20:02:35 -07004411 struct hdd_wext_state *pWextState = NULL;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004412 struct hdd_station_ctx *sta_ctx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304413 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304414 struct cfg80211_bss *bss_status;
Jeff Johnson49432062017-08-28 12:08:45 -07004415 struct hdd_context *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004417 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004418 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004419
4420 /* Sanity check */
Jeff Johnsonba388342017-10-02 13:31:01 -07004421 if ((NULL == adapter) || (WLAN_HDD_ADAPTER_MAGIC != adapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004422 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304423 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004424 }
4425
Jeff Johnsonba388342017-10-02 13:31:01 -07004426 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004427 sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Jeff Johnsonba388342017-10-02 13:31:01 -07004428 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004429
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304430 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4431 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4432 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004433 adapter->session_id, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304434
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004435 switch (roamStatus) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004436 /*
4437 * We did pre-auth,then we attempted a 11r or ese reassoc.
4438 * reassoc failed due to failure, timeout, reject from ap
4439 * in any case tell the OS, our carrier is off and mark
4440 * interface down.
4441 */
4442 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004443 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004444 roamStatus, roamResult, adapter->session_id);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304445 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004446 hdd_dis_connect_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004447 roamStatus, roamResult);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004448 sta_ctx->ft_carrier_on = false;
Jeff Johnson690fe952017-10-25 11:48:39 -07004449 sta_ctx->hdd_reassoc_scenario = false;
4450 hdd_debug("hdd_reassoc_scenario set to: %d, ReAssoc Failed, session: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004451 sta_ctx->hdd_reassoc_scenario, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004452 break;
4453
4454 case eCSR_ROAM_FT_START:
4455 /*
4456 * When we roam for ESE and 11r, we dont want the OS to be
4457 * informed that the link is down. So mark the link ready for
4458 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4459 * be received. Where in we will not mark the link down
4460 * Also we want to stop tx at this point when we will be
4461 * doing disassoc at this time. This saves 30-60 msec
4462 * after reassoc.
4463 */
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304464 hdd_debug("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004465 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004466 hdd_napi_serialize(1);
Jeff Johnsonba388342017-10-02 13:31:01 -07004467 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304468 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004469 WLAN_CONTROL_PATH);
Jeff Johnsonba388342017-10-02 13:31:01 -07004470 status = hdd_roam_deregister_sta(adapter,
Jeff Johnsond377dce2017-10-04 10:32:42 -07004471 sta_ctx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304472 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304473 qdf_ret_status = QDF_STATUS_E_FAILURE;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004474 sta_ctx->ft_carrier_on = true;
Jeff Johnson690fe952017-10-25 11:48:39 -07004475 sta_ctx->hdd_reassoc_scenario = true;
4476 hdd_debug("hdd_reassoc_scenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
Jeff Johnson1b780e42017-10-31 14:11:45 -07004477 sta_ctx->hdd_reassoc_scenario, adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004478 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004479 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004480 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004481 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004482 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304483 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
Jeff Johnsonba388342017-10-02 13:31:01 -07004484 adapter->roam_ho_fail = true;
Abhishek Singh533c9da2017-05-04 10:23:34 +05304485 else
Jeff Johnsonba388342017-10-02 13:31:01 -07004486 adapter->roam_ho_fail = false;
4487 complete(&adapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004488 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004489 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004490 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -07004491 hdd_info("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004492 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304493 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004494 WLAN_CONTROL_PATH);
Jeff Johnsond377dce2017-10-04 10:32:42 -07004495 if (sta_ctx->ft_carrier_on == false) {
Jeff Johnsonba388342017-10-02 13:31:01 -07004496 wlan_hdd_netif_queue_control(adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004497 WLAN_NETIF_CARRIER_OFF,
4498 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004499 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004500 break;
4501 case eCSR_ROAM_LOSTLINK:
4502 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004503 hdd_debug("Roaming started due to connection lost");
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05304504 hdd_debug("Disabling queues");
Jeff Johnsonba388342017-10-02 13:31:01 -07004505 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304506 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004507 WLAN_CONTROL_PATH);
4508 break;
4509 }
4510 case eCSR_ROAM_DISASSOCIATED:
4511 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004512 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304513 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004514 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304515 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004516 adapter->roam_ho_fail = false;
4517 complete(&adapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304518
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004519 /* Call to clear any MC Addr List filter applied after
4520 * successful connection.
4521 */
Jeff Johnsonba388342017-10-02 13:31:01 -07004522 hdd_disable_and_flush_mc_addr_list(adapter,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304523 pmo_peer_disconnect);
4524 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004525 hdd_dis_connect_handler(adapter, roam_info, roamId,
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304526 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004527 }
4528 break;
4529 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004530 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304531 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004532 hdd_dis_connect_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004533 roamStatus, roamResult);
4534 break;
4535 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004536 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004537 /*
4538 * To Do - address probable memory leak with WEP encryption upon
4539 * successful association.
4540 */
4541 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4542 /* Clear saved connection information in HDD */
4543 hdd_conn_remove_connect_info(
Jeff Johnsonba388342017-10-02 13:31:01 -07004544 WLAN_HDD_GET_STATION_CTX_PTR(adapter));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304546 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004547 hdd_association_completion_handler(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004548 roamId, roamStatus,
4549 roamResult);
4550#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004551 if (roam_info)
4552 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004553#endif
4554 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004555 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004556 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 case eCSR_ROAM_ASSOCIATION_FAILURE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004558 qdf_ret_status = hdd_association_completion_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004559 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004560 roamId,
4561 roamStatus,
4562 roamResult);
4563 break;
4564 case eCSR_ROAM_IBSS_IND:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004565 hdd_roam_ibss_indication_handler(adapter, roam_info, roamId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004566 roamStatus, roamResult);
4567 break;
4568
4569 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304570 qdf_ret_status =
Jeff Johnsonba388342017-10-02 13:31:01 -07004571 roam_roam_connect_status_update_handler(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004572 roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004573 roamId,
4574 roamStatus,
4575 roamResult);
4576 break;
4577
4578 case eCSR_ROAM_MIC_ERROR_IND:
Jeff Johnson8b5e8f72017-10-16 12:36:09 -07004579 hdd_roam_mic_error_indication_handler(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004580 break;
4581
4582 case eCSR_ROAM_SET_KEY_COMPLETE:
4583 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304584 qdf_ret_status =
Jeff Johnsonfd060852017-10-04 10:50:51 -07004585 hdd_roam_set_key_complete_handler(adapter, roam_info,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004586 roamId, roamStatus,
4587 roamResult);
4588 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Jeff Johnson690fe952017-10-25 11:48:39 -07004589 sta_ctx->hdd_reassoc_scenario = false;
4590 hdd_debug("hdd_reassoc_scenario set to: %d, set key complete, session: %d",
4591 sta_ctx->hdd_reassoc_scenario,
Jeff Johnson1b780e42017-10-31 14:11:45 -07004592 adapter->session_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 }
4594 }
4595#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Jeff Johnsonfd060852017-10-04 10:50:51 -07004596 if (roam_info != NULL)
4597 roam_info->roamSynchInProgress = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598#endif
4599 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004600
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004601 case eCSR_ROAM_FT_RESPONSE:
Jeff Johnsonba388342017-10-02 13:31:01 -07004602 hdd_send_ft_event(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004603 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004604
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 case eCSR_ROAM_PMK_NOTIFY:
Jeff Johnsond377dce2017-10-04 10:32:42 -07004606 if (eCSR_AUTH_TYPE_RSN == sta_ctx->conn_info.authType
4607 || hdd_is_8021x_sha256_auth_type(sta_ctx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304609 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004610 wlan_hdd_cfg80211_pmksa_candidate_notify(
Jeff Johnsonfd060852017-10-04 10:50:51 -07004611 adapter, roam_info, 1, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 }
4613 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004614
4615#ifdef FEATURE_WLAN_LFR_METRICS
4616 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4617 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304618 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004619 wlan_hdd_cfg80211_roam_metrics_preauth(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004620 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304621 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 }
4623 break;
4624 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4625 /*
4626 * This event will notify pre-auth completion in case of success
4627 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304628 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004629 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004630 roam_info, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304631 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004632 }
4633 break;
4634 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4635 /*
4636 * This event will notify pre-auth completion incase of failure.
4637 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304638 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004639 wlan_hdd_cfg80211_roam_metrics_preauth_status(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004640 roam_info, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304641 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642 }
4643 break;
4644 case eCSR_ROAM_HANDOVER_SUCCESS:
4645 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004646 * It will be only invoked on success
4647 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304648 if (QDF_STATUS_SUCCESS !=
Jeff Johnsonba388342017-10-02 13:31:01 -07004649 wlan_hdd_cfg80211_roam_metrics_handover(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004650 roam_info)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304651 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 }
4653 break;
4654#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655#ifdef WLAN_FEATURE_11W
4656 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
Jeff Johnsonba388342017-10-02 13:31:01 -07004657 hdd_indicate_unprot_mgmt_frame(adapter,
Jeff Johnsonfd060852017-10-04 10:50:51 -07004658 roam_info->nFrameLength,
4659 roam_info->pbFrames,
4660 roam_info->frameType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004661 break;
4662#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004663#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 case eCSR_ROAM_TSM_IE_IND:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004665 hdd_indicate_tsm_ie(adapter, roam_info->tsmIe.tsid,
4666 roam_info->tsmIe.state,
4667 roam_info->tsmIe.msmt_interval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 break;
4669
4670 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4671 {
4672 if (eCSR_AUTH_TYPE_CCKM_WPA ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004673 sta_ctx->conn_info.authType
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004674 || eCSR_AUTH_TYPE_CCKM_RSN ==
Jeff Johnsond377dce2017-10-04 10:32:42 -07004675 sta_ctx->conn_info.authType) {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004676 hdd_indicate_cckm_pre_auth(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004677 }
4678 break;
4679 }
4680
4681 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4682 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004683 hdd_indicate_ese_adj_ap_rep_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004684 break;
4685 }
4686
4687 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4688 {
Jeff Johnsonfd060852017-10-04 10:50:51 -07004689 hdd_indicate_ese_bcn_report_ind(adapter, roam_info);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004690 break;
4691 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004692#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304693 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004694 hdd_roam_channel_switch_handler(adapter, roam_info);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304695 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304696
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304697 case eCSR_ROAM_UPDATE_SCAN_RESULT:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004698 if ((NULL != roam_info) && (NULL != roam_info->pBssDesc)) {
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304699 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
Jeff Johnsonfd060852017-10-04 10:50:51 -07004700 adapter, roam_info->pBssDesc);
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304701 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004702 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304703 else
4704 cfg80211_put_bss(
4705#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
Jeff Johnsonba388342017-10-02 13:31:01 -07004706 (WLAN_HDD_GET_CTX(adapter))->wiphy,
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304707#endif
4708 bss_status);
4709 }
4710 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004711 case eCSR_ROAM_NDP_STATUS_UPDATE:
Jeff Johnsonfd060852017-10-04 10:50:51 -07004712 hdd_ndp_event_handler(adapter, roam_info, roamId, roamStatus,
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004713 roamResult);
4714 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004715 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004716 hdd_debug("Process ROAM_START from firmware");
Jeff Johnsonba388342017-10-02 13:31:01 -07004717 wlan_hdd_netif_queue_control(adapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304718 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004719 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004720 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004721 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004722 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004723 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004724 break;
4725 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004726 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004727 hdd_napi_serialize(0);
Jeff Johnsonba388342017-10-02 13:31:01 -07004728 wlan_hdd_netif_queue_control(adapter,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004729 WLAN_WAKE_ALL_NETIF_QUEUE,
4730 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08004731 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004732 hdd_set_roaming_in_progress(false);
Jeff Johnsonba388342017-10-02 13:31:01 -07004733 adapter->roam_ho_fail = false;
Jeff Johnsond377dce2017-10-04 10:32:42 -07004734 sta_ctx->ft_carrier_on = false;
Jeff Johnsonba388342017-10-02 13:31:01 -07004735 complete(&adapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004736 break;
4737
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004738 default:
4739 break;
4740 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304741 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742}
4743
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304744#ifdef WLAN_FEATURE_FILS_SK
4745/**
4746 * hdd_translate_fils_rsn_to_csr_auth() - Translate FILS RSN to CSR auth type
4747 * @auth_suite: auth suite
4748 * @auth_type: pointer to eCsrAuthType
4749 *
4750 * Return: None
4751 */
4752static void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
4753 eCsrAuthType *auth_type)
4754{
4755 if (!memcmp(auth_suite, ccp_rsn_oui_0e, 4))
4756 *auth_type = eCSR_AUTH_TYPE_FILS_SHA256;
4757 else if (!memcmp(auth_suite, ccp_rsn_oui_0f, 4))
4758 *auth_type = eCSR_AUTH_TYPE_FILS_SHA384;
4759 else if (!memcmp(auth_suite, ccp_rsn_oui_10, 4))
4760 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA256;
4761 else if (!memcmp(auth_suite, ccp_rsn_oui_11, 4))
4762 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA384;
4763}
4764#else
4765static inline void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
4766 eCsrAuthType *auth_type)
4767{
4768}
4769#endif
4770
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004771/**
4772 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4773 * @auth_suite: auth suite
4774 *
4775 * Return: eCsrAuthType enumeration
4776 */
4777eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4778{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304779 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 /* is the auth type supported? */
4781 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4782 auth_type = eCSR_AUTH_TYPE_RSN;
4783 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4784 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004785 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004786 /* Check for 11r FT Authentication with PSK */
4787 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
4788 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
4789 /* Check for 11R FT Authentication with 802.1X */
4790 auth_type = eCSR_AUTH_TYPE_FT_RSN;
4791 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792#ifdef FEATURE_WLAN_ESE
4793 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
4794 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4795 } else
4796#endif /* FEATURE_WLAN_ESE */
4797#ifdef WLAN_FEATURE_11W
4798 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
4799 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4800 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
4801 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05304802 } else if (memcmp(auth_suite, ccp_rsn_oui_18, 4) == 0) {
4803 auth_type = eCSR_AUTH_TYPE_OWE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804 } else
4805#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05304806 if (memcmp(auth_suite, ccp_rsn_oui_12, 4) == 0) {
4807 auth_type = eCSR_AUTH_TYPE_DPP_RSN;
4808 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004809 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304810 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 }
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304812 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004813 return auth_type;
4814}
4815
4816/**
4817 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
4818 * @auth_suite: auth suite
4819 *
4820 * Return: eCsrAuthType enumeration
4821 */
4822eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
4823{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304824 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 /* is the auth type supported? */
4826 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
4827 auth_type = eCSR_AUTH_TYPE_WPA;
4828 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
4829 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
4830 } else
4831#ifdef FEATURE_WLAN_ESE
4832 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
4833 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
4834 } else
4835#endif /* FEATURE_WLAN_ESE */
4836 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05304837 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004839 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004840 return auth_type;
4841}
4842
4843/**
4844 * hdd_translate_rsn_to_csr_encryption_type() -
4845 * Translate RSN to CSR encryption type
4846 * @cipher_suite: cipher suite
4847 *
4848 * Return: eCsrEncryptionType enumeration
4849 */
4850eCsrEncryptionType
4851hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
4852{
4853 eCsrEncryptionType cipher_type;
4854
4855 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
4856 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05304857 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
4858 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
4859 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
4860 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
4862 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
4863 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
4864 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
4865 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
4866 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4867 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
4868 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4869 else
4870 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4871
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004872 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 return cipher_type;
4874}
4875
4876/**
4877 * hdd_translate_wpa_to_csr_encryption_type() -
4878 * Translate WPA to CSR encryption type
4879 * @cipher_suite: cipher suite
4880 *
4881 * Return: eCsrEncryptionType enumeration
4882 */
4883eCsrEncryptionType
4884hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
4885{
4886 eCsrEncryptionType cipher_type;
4887
4888 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
4889 cipher_type = eCSR_ENCRYPT_TYPE_AES;
4890 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
4891 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
4892 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
4893 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
4894 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
4895 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4896 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
4897 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4898 else
4899 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4900
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004901 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 return cipher_type;
4903}
4904
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304905#ifdef WLAN_FEATURE_FILS_SK
4906/*
4907 * hdd_is_fils_connection: API to determine if connection is FILS
4908 * @adapter: hdd adapter
4909 *
4910 * Return: true if fils connection else false
4911 */
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004912static inline bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304913{
Jeff Johnson2a722002017-09-30 20:02:35 -07004914 struct hdd_wext_state *wext_state =
4915 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304916
4917 if (wext_state->roamProfile.fils_con_info)
4918 return wext_state->roamProfile.
4919 fils_con_info->is_fils_connection;
4920}
4921#else
Jeff Johnsonb1704c82017-08-29 14:40:57 -07004922static inline bool hdd_is_fils_connection(struct hdd_adapter *adapter)
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05304923{
4924 return false;
4925}
4926#endif
4927
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004928/**
4929 * hdd_process_genie() - process gen ie
Jeff Johnsonba388342017-10-02 13:31:01 -07004930 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004931 * @bssid: pointer to mac address
4932 * @pEncryptType: pointer to encryption type
4933 * @mcEncryptType: pointer to multicast encryption type
4934 * @pAuthType: pointer to auth type
4935 *
4936 * Return: 0 on success, error number otherwise
4937 */
Jeff Johnsonba388342017-10-02 13:31:01 -07004938static int32_t hdd_process_genie(struct hdd_adapter *adapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 u8 *bssid,
4940 eCsrEncryptionType *pEncryptType,
4941 eCsrEncryptionType *mcEncryptType,
4942 eCsrAuthType *pAuthType,
4943#ifdef WLAN_FEATURE_11W
4944 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
4945#endif
4946 uint16_t gen_ie_len, uint8_t *gen_ie)
4947{
Jeff Johnsonba388342017-10-02 13:31:01 -07004948 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 tDot11fIERSN dot11RSNIE;
4950 tDot11fIEWPA dot11WPAIE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 uint8_t *pRsnIe;
4952 uint16_t RSNIeLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004953
4954 /*
4955 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
4956 * setting present flag to 0.
4957 */
4958 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
4959 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
4960
4961 /* Type check */
4962 if (gen_ie[0] == DOT11F_EID_RSN) {
4963 /* Validity checks */
4964 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
4965 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004966 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004967 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968 return -EINVAL;
4969 }
4970 /* Skip past the EID byte and length byte */
4971 pRsnIe = gen_ie + 2;
4972 RSNIeLen = gen_ie_len - 2;
4973 /* Unpack the RSN IE */
4974 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05304975 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004976 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004977 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004978 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004979 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004980 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 /* dot11RSNIE.akm_suite_count */
4982 /* Just translate the FIRST one */
4983 *pAuthType =
4984 hdd_translate_rsn_to_csr_auth_type(
4985 dot11RSNIE.akm_suites[0]);
4986 /* dot11RSNIE.pwise_cipher_suite_count */
4987 *pEncryptType =
4988 hdd_translate_rsn_to_csr_encryption_type(
4989 dot11RSNIE.pwise_cipher_suites[0]);
4990 /* dot11RSNIE.gp_cipher_suite_count */
4991 *mcEncryptType =
4992 hdd_translate_rsn_to_csr_encryption_type(
4993 dot11RSNIE.gp_cipher_suite);
4994#ifdef WLAN_FEATURE_11W
4995 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
Srinivas Girigowda6519b932017-08-03 14:10:57 -07004996 *pMfpCapable = csr_is_mfpc_capable(&dot11RSNIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 } else if (gen_ie[0] == DOT11F_EID_WPA) {
4999 /* Validity checks */
5000 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5001 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005002 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005003 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004 return -EINVAL;
5005 }
5006 /* Skip past the EID and length byte - and four byte WiFi OUI */
5007 pRsnIe = gen_ie + 2 + 4;
5008 RSNIeLen = gen_ie_len - (2 + 4);
5009 /* Unpack the WPA IE */
5010 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305011 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005012 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005013 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005014 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005015 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005016 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005017 /* dot11WPAIE.auth_suite_count */
5018 /* Just translate the FIRST one */
5019 *pAuthType =
5020 hdd_translate_wpa_to_csr_auth_type(
5021 dot11WPAIE.auth_suites[0]);
5022 /* dot11WPAIE.unicast_cipher_count */
5023 *pEncryptType =
5024 hdd_translate_wpa_to_csr_encryption_type(
5025 dot11WPAIE.unicast_ciphers[0]);
5026 /* dot11WPAIE.unicast_cipher_count */
5027 *mcEncryptType =
5028 hdd_translate_wpa_to_csr_encryption_type(
5029 dot11WPAIE.multicast_cipher);
5030 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005031 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005032 return -EINVAL;
5033 }
5034 return 0;
5035}
5036
5037/**
5038 * hdd_set_genie_to_csr() - set genie to csr
Jeff Johnsonba388342017-10-02 13:31:01 -07005039 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040 * @RSNAuthType: pointer to auth type
5041 *
5042 * Return: 0 on success, error number otherwise
5043 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005044int hdd_set_genie_to_csr(struct hdd_adapter *adapter,
Jeff Johnson2a722002017-09-30 20:02:35 -07005045 eCsrAuthType *RSNAuthType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046{
Jeff Johnson2a722002017-09-30 20:02:35 -07005047 struct hdd_wext_state *pWextState =
Jeff Johnsonba388342017-10-02 13:31:01 -07005048 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049 uint32_t status = 0;
5050 eCsrEncryptionType RSNEncryptType;
5051 eCsrEncryptionType mcRSNEncryptType;
5052#ifdef WLAN_FEATURE_11W
5053 uint8_t RSNMfpRequired = 0;
5054 uint8_t RSNMfpCapable = 0;
5055#endif
5056 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5057 /* MAC address of assoc peer */
5058 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305059 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 pWextState->roamProfile.BSSIDs.bssid,
5061 sizeof(bssid));
5062 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5063 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5064 /* continue */
5065 } else {
5066 return 0;
5067 }
5068 /* The actual processing may eventually be more extensive than this. */
5069 /* Right now, just consume any PMKIDs that are sent in by the app. */
Jeff Johnsonba388342017-10-02 13:31:01 -07005070 status = hdd_process_genie(adapter, bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005071 &RSNEncryptType,
5072 &mcRSNEncryptType, RSNAuthType,
5073#ifdef WLAN_FEATURE_11W
5074 &RSNMfpRequired, &RSNMfpCapable,
5075#endif
5076 pWextState->WPARSNIE[1] + 2,
5077 pWextState->WPARSNIE);
5078 if (status == 0) {
5079 /*
5080 * Now copy over all the security attributes
5081 * you have parsed out.
5082 */
5083 pWextState->roamProfile.EncryptionType.numEntries = 1;
5084 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5085
Jeff Johnson435e1b82017-10-07 14:13:10 -07005086 /* Use the cipher type in the RSN IE */
5087 pWextState->roamProfile.EncryptionType.encryptionType[0] =
5088 RSNEncryptType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005089 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5090 mcRSNEncryptType;
5091
Jeff Johnsonba388342017-10-02 13:31:01 -07005092 if ((QDF_IBSS_MODE == adapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05305094 (eCSR_ENCRYPT_TYPE_AES_GCMP == mcRSNEncryptType) ||
5095 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mcRSNEncryptType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5097 /*
5098 * For wpa none supplicant sends the WPA IE with unicast
5099 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5100 * multicast cipher as either AES/TKIP based on group
5101 * cipher configuration mentioned in the
5102 * wpa_supplicant.conf.
5103 */
5104
5105 /* Set the unicast cipher same as multicast cipher */
5106 pWextState->roamProfile.EncryptionType.encryptionType[0]
5107 = mcRSNEncryptType;
5108 }
5109#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005110 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005111 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005112 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5113 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5114#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005115 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005116 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005117 }
5118 return 0;
5119}
5120
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305121#ifdef WLAN_FEATURE_FILS_SK
5122/**
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305123 * hdd_check_fils_rsn_n_set_auth_type() - This API checks whether a give
5124 * auth type is fils if yes, sets it in profile.
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305125 * @rsn_auth_type: auth type
5126 *
5127 * Return: true if FILS auth else false
5128 */
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305129static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5130 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305131{
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305132 bool is_fils_rsn = false;
5133
5134 if (!roam_profile->fils_con_info)
5135 return false;
5136
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305137 if ((rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA256) ||
5138 (rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA384) ||
5139 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA256) ||
5140 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA384))
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305141 is_fils_rsn = true;
5142 if (is_fils_rsn)
5143 roam_profile->fils_con_info->akm_type = rsn_auth_type;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305144
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305145 return is_fils_rsn;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305146}
5147#else
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305148static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5149 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305150{
5151 return false;
5152}
5153#endif
5154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005155/**
5156 * hdd_set_csr_auth_type() - set csr auth type
Jeff Johnsonba388342017-10-02 13:31:01 -07005157 * @adapter: pointer to adapter
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 * @RSNAuthType: auth type
5159 *
5160 * Return: 0 on success, error number otherwise
5161 */
Jeff Johnsonba388342017-10-02 13:31:01 -07005162int hdd_set_csr_auth_type(struct hdd_adapter *adapter,
Jeff Johnson2a722002017-09-30 20:02:35 -07005163 eCsrAuthType RSNAuthType)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164{
Jeff Johnson2a722002017-09-30 20:02:35 -07005165 struct hdd_wext_state *pWextState =
Jeff Johnsonba388342017-10-02 13:31:01 -07005166 WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005167 tCsrRoamProfile *roam_profile = &(pWextState->roamProfile);
Jeff Johnsond377dce2017-10-04 10:32:42 -07005168 struct hdd_station_ctx *sta_ctx =
Jeff Johnsonba388342017-10-02 13:31:01 -07005169 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005171 roam_profile->AuthType.numEntries = 1;
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305172 hdd_debug("authType = %d RSNAuthType %d wpa_versions %d",
5173 sta_ctx->conn_info.authType, RSNAuthType,
5174 sta_ctx->wpa_versions);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005175
Jeff Johnsond377dce2017-10-04 10:32:42 -07005176 switch (sta_ctx->conn_info.authType) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005177 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5178#ifdef FEATURE_WLAN_ESE
5179 case eCSR_AUTH_TYPE_CCKM_WPA:
5180 case eCSR_AUTH_TYPE_CCKM_RSN:
5181#endif
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005182 if (!sta_ctx->wpa_versions) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005184 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005185 eCSR_AUTH_TYPE_OPEN_SYSTEM;
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005186 } else if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_1) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005187
5188#ifdef FEATURE_WLAN_ESE
5189 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5190 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5191 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005192 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005193 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005194 eCSR_AUTH_TYPE_CCKM_WPA;
5195 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005196 hdd_debug("Last chance to set authType to CCKM WPA.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005197 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005198 eCSR_AUTH_TYPE_CCKM_WPA;
5199 } else
5200#endif
5201 if ((pWextState->
5202 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5203 == IW_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005204 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 eCSR_AUTH_TYPE_WPA;
5206 } else
5207 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5208 == IW_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005209 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005210 eCSR_AUTH_TYPE_WPA_PSK;
5211 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005212 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005213 eCSR_AUTH_TYPE_WPA_NONE;
5214 }
5215 }
Jeff Johnsonce4a8342017-10-14 13:12:22 -07005216 if (sta_ctx->wpa_versions & NL80211_WPA_VERSION_2) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005217#ifdef FEATURE_WLAN_ESE
5218 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5219 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5220 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005221 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005222 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005223 eCSR_AUTH_TYPE_CCKM_RSN;
5224 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005225 hdd_debug("Last chance to set authType to CCKM RSN.");
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005226 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227 eCSR_AUTH_TYPE_CCKM_RSN;
5228 } else
5229#endif
Abhishek Singh02cb9e02017-08-30 17:39:50 +05305230 if (RSNAuthType == eCSR_AUTH_TYPE_DPP_RSN) {
5231 roam_profile->AuthType.authType[0] =
5232 eCSR_AUTH_TYPE_DPP_RSN;
5233 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 ((pWextState->
5235 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5236 == IW_AUTH_KEY_MGMT_802_1X)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005237 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005238 eCSR_AUTH_TYPE_FT_RSN;
5239 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5240 &&
5241 ((pWextState->
5242 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5243 == IW_AUTH_KEY_MGMT_PSK)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005244 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005245 eCSR_AUTH_TYPE_FT_RSN_PSK;
5246 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005247
5248#ifdef WLAN_FEATURE_11W
5249 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005250 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005251 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5252 } else if (RSNAuthType ==
5253 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005254 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005255 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5256 } else
5257#endif
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005258 if (hdd_check_fils_rsn_n_set_auth_type(roam_profile,
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305259 RSNAuthType)) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005260 roam_profile->AuthType.authType[0] =
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305261 RSNAuthType;
Yeshwanth Sriram Guntuka52bc6bb2017-05-02 16:57:13 +05305262 hdd_debug("updated profile authtype as %d",
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305263 RSNAuthType);
5264
Padma, Santhosh Kumarc69ce072017-11-06 18:21:05 +05305265 } else if ((RSNAuthType == eCSR_AUTH_TYPE_OWE) &&
5266 ((pWextState->
5267 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5268 == IW_AUTH_KEY_MGMT_802_1X)) {
5269 /* OWE case */
5270 roam_profile->AuthType.authType[0] =
5271 eCSR_AUTH_TYPE_OWE;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305272 } else if ((pWextState->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005273 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5274 == IW_AUTH_KEY_MGMT_802_1X) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005275 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005276 eCSR_AUTH_TYPE_RSN;
5277 } else
5278 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5279 == IW_AUTH_KEY_MGMT_PSK) {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005280 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005281 eCSR_AUTH_TYPE_RSN_PSK;
5282 } else {
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005283 roam_profile->AuthType.authType[0] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 eCSR_AUTH_TYPE_UNKNOWN;
5285 }
5286 }
5287 break;
5288
5289 case eCSR_AUTH_TYPE_SHARED_KEY:
5290
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005291 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005292 break;
5293 default:
5294
5295#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005296 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005297#endif /* FEATURE_WLAN_ESE */
Jeff Johnson5b34fce2017-10-13 13:24:51 -07005298 roam_profile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 break;
5300 }
5301
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005302 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005303 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005304
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005305 return 0;
5306}