blob: b2ba1ae089f06434e57cb8d06f6ee1565e026e6f [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"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/* These are needed to recognize WPA and RSN suite types */
70#define HDD_WPA_OUI_SIZE 4
71#define HDD_RSN_OUI_SIZE 4
72uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
73uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
74uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
75uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
76uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
77uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
78
79#ifdef FEATURE_WLAN_ESE
80/* CCKM */
81uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82/* CCKM */
83uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
84#endif /* FEATURE_WLAN_ESE */
85
86/* group cipher */
87uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
88
89/* WEP-40 or RSN */
90uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
91
92/* TKIP or RSN-PSK */
93uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
94
95/* Reserved */
96uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
97
98/* AES-CCMP */
99uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
100
101/* WEP-104 */
102uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
103
104#ifdef WLAN_FEATURE_11W
105/* RSN-PSK-SHA256 */
106uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
107
108/* RSN-8021X-SHA256 */
109uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
110#endif
111
Mukul Sharma05504ac2017-06-08 12:35:53 +0530112/* AES-GCMP-128 */
113uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
114
115/* AES-GCMP-256 */
116uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +0530117#ifdef WLAN_FEATURE_FILS_SK
118uint8_t ccp_rsn_oui_0e[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0E};
119uint8_t ccp_rsn_oui_0f[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x0F};
120uint8_t ccp_rsn_oui_10[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x10};
121uint8_t ccp_rsn_oui_11[HDD_RSN_OUI_SIZE] = {0x00, 0x0F, 0xAC, 0x11};
122#endif
Mukul Sharma05504ac2017-06-08 12:35:53 +0530123
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800124/* Offset where the EID-Len-IE, start. */
125#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
126#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800127
128#define BEACON_FRAME_IES_OFFSET 12
129#define HDD_PEER_AUTHORIZE_WAIT 10
130
131/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700132 * beacon_filter_table - table of IEs used for beacon filtering
133 */
134static const int beacon_filter_table[] = {
135 SIR_MAC_DS_PARAM_SET_EID,
136 SIR_MAC_ERP_INFO_EID,
137 SIR_MAC_EDCA_PARAM_SET_EID,
138 SIR_MAC_QOS_CAPABILITY_EID,
139 SIR_MAC_HT_INFO_EID,
140 SIR_MAC_VHT_OPMODE_EID,
141 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700142#ifdef WLAN_FEATURE_11AX_BSS_COLOR
143 /*
144 * EID: 221 vendor IE is being used temporarily by 11AX
145 * bss-color-change IE till it gets any fixed number. This
146 * vendor EID needs to be replaced with bss-color-change IE
147 * number.
148 */
149 SIR_MAC_EID_VENDOR,
150#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700151};
152
153/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800154 * hdd_conn_set_authenticated() - set authentication state
155 * @pAdapter: pointer to the adapter
156 * @authState: authentication state
157 *
158 * This function updates the global HDD station context
159 * authentication state.
160 *
161 * Return: none
162 */
163static void
164hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
165{
166 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
167 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
168
169 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700170 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700171 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 pHddStaCtx->conn_info.uIsAuthenticated = authState;
173
174 /* Check is pending ROC request or not when auth state changed */
175 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
176}
177
178/**
179 * hdd_conn_set_connection_state() - set connection state
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700180 * @adapter: pointer to the adapter
181 * @conn_state: connection state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800182 *
183 * This function updates the global HDD station context connection state.
184 *
185 * Return: none
186 */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700187void hdd_conn_set_connection_state(hdd_adapter_t *adapter,
188 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189{
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700190 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
191 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800192
193 /* save the new connection state */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700194 hdd_debug("%pS Changed conn state from old:%d to new:%d for dev %s",
195 (void *)_RET_IP_, hdd_sta_ctx->conn_info.connState,
196 conn_state, adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800197
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700198 hdd_tsf_notify_wlan_state_change(adapter,
199 hdd_sta_ctx->conn_info.connState,
200 conn_state);
201 hdd_sta_ctx->conn_info.connState = conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800202
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700203 schedule_delayed_work(&hdd_ctx->roc_req_work, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800204}
205
206/**
207 * hdd_conn_get_connection_state() - get connection state
208 * @pAdapter: pointer to the adapter
209 * @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 */
217static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
218 eConnectionState *pConnState)
219{
220 bool fConnected = false;
221 eConnectionState connState;
222
223 /* get the connection state. */
224 connState = pHddStaCtx->conn_info.connState;
225
226 if (eConnectionState_Associated == connState ||
227 eConnectionState_IbssConnected == connState ||
228 eConnectionState_IbssDisconnected == connState) {
229 fConnected = true;
230 }
231
232 if (pConnState)
233 *pConnState = connState;
234
235 return fConnected;
236}
237
238/**
239 * hdd_is_connecting() - Function to check connection progress
240 * @hdd_sta_ctx: pointer to global HDD Station context
241 *
242 * Return: true if connecting, false otherwise
243 */
244bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
245{
246 return hdd_sta_ctx->conn_info.connState ==
247 eConnectionState_Connecting;
248}
249
250/**
251 * hdd_conn_is_connected() - Function to check connection status
252 * @pHddStaCtx: pointer to global HDD Station context
253 *
254 * Return: false if any errors encountered, true otherwise
255 */
256bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
257{
258 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
259}
260
261/**
262 * hdd_conn_get_connected_band() - get current connection radio band
263 * @pHddStaCtx: pointer to global HDD Station context
264 *
265 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
266 * eCSR_BAND_ALL if not connected
267 */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700268enum band_info hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800269{
270 uint8_t staChannel = 0;
271
272 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
273 staChannel = pHddStaCtx->conn_info.operationChannel;
274
275 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700276 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800277 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700278 return BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800279 else /* If station is not connected return as eCSR_BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700280 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800281}
282
283/**
284 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
285 * @pHddStaCtx: pointer to global HDD Station context
286 * @pConnectedCipherAlgo: pointer to connected cipher algo
287 *
288 * Return: false if any errors encountered, true otherwise
289 */
290static inline bool
291hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
292 eCsrEncryptionType *pConnectedCipherAlgo)
293{
294 bool fConnected = false;
295
296 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
297
298 if (pConnectedCipherAlgo)
299 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
300
301 return fConnected;
302}
303
304/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700305 * hdd_remove_beacon_filter() - remove beacon filter
306 * @adapter: Pointer to the hdd adapter
307 *
308 * Return: 0 on success and errno on failure
309 */
310static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
311{
312 QDF_STATUS status;
313 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
314
315 status = sme_remove_beacon_filter(hdd_ctx->hHal,
316 adapter->sessionId);
317 if (!QDF_IS_STATUS_SUCCESS(status)) {
318 hdd_err("sme_remove_beacon_filter() failed");
319 return -EFAULT;
320 }
321
322 return 0;
323}
324
325/**
326 * hdd_add_beacon_filter() - add beacon filter
327 * @adapter: Pointer to the hdd adapter
328 *
329 * Return: 0 on success and errno on failure
330 */
331static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
332{
333 int i;
334 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
335 QDF_STATUS status;
336 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
337
338 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530339 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700340 (unsigned long int *)ie_map);
341
342 status = sme_add_beacon_filter(hdd_ctx->hHal,
343 adapter->sessionId, ie_map);
344 if (!QDF_IS_STATUS_SUCCESS(status)) {
345 hdd_err("sme_add_beacon_filter() failed");
346 return -EFAULT;
347 }
348 return 0;
349}
350
351/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530352 * hdd_copy_vht_caps()- copy vht caps info from roam info to
353 * hdd station context.
354 * @hdd_sta_ctx: pointer to hdd station context
355 * @roam_info: pointer to roam info
356 *
357 * Return: None
358 */
359static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
360 tCsrRoamInfo *roam_info)
361{
362 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
363 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
364 uint32_t i, temp_ht_cap;
365
366 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
367
368 if (roam_ht_cap->advCodingCap)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
370 if (roam_ht_cap->supportedChannelWidthSet)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
372 temp_ht_cap = roam_ht_cap->mimoPowerSave &
373 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
374 if (temp_ht_cap)
375 hdd_ht_cap->cap_info |=
376 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
377 if (roam_ht_cap->greenField)
378 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
379 if (roam_ht_cap->shortGI20MHz)
380 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
381 if (roam_ht_cap->shortGI40MHz)
382 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
383 if (roam_ht_cap->txSTBC)
384 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
385 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
386 IEEE80211_HT_CAP_RX_STBC_SHIFT);
387 if (temp_ht_cap)
388 hdd_ht_cap->cap_info |=
389 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
390 if (roam_ht_cap->delayedBA)
391 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
392 if (roam_ht_cap->maximalAMSDUsize)
393 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
394 if (roam_ht_cap->dsssCckMode40MHz)
395 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
396 if (roam_ht_cap->psmp)
397 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
398 if (roam_ht_cap->stbcControlFrame)
399 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
400 if (roam_ht_cap->lsigTXOPProtection)
401 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
402
403 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
404 if (roam_ht_cap->maxRxAMPDUFactor)
405 hdd_ht_cap->ampdu_params_info |=
406 IEEE80211_HT_AMPDU_PARM_FACTOR;
407 temp_ht_cap = roam_ht_cap->mpduDensity &
408 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
409 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
410 if (temp_ht_cap)
411 hdd_ht_cap->ampdu_params_info |=
412 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
413
414 /* 802.11n HT extended capabilities masks */
415 if (roam_ht_cap->pco)
416 hdd_ht_cap->extended_ht_cap_info |=
417 IEEE80211_HT_EXT_CAP_PCO;
418 temp_ht_cap = roam_ht_cap->transitionTime &
419 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
420 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
421 if (temp_ht_cap)
422 hdd_ht_cap->extended_ht_cap_info |=
423 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
424 temp_ht_cap = roam_ht_cap->mcsFeedback &
425 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
426 if (temp_ht_cap)
427 hdd_ht_cap->extended_ht_cap_info |=
428 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
429
430 /* tx_bf_cap_info capabilities */
431 if (roam_ht_cap->txBF)
432 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
433 if (roam_ht_cap->rxStaggeredSounding)
434 hdd_ht_cap->tx_BF_cap_info |=
435 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
436 if (roam_ht_cap->txStaggeredSounding)
437 hdd_ht_cap->tx_BF_cap_info |=
438 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
439 if (roam_ht_cap->rxZLF)
440 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
441 if (roam_ht_cap->txZLF)
442 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
443 if (roam_ht_cap->implicitTxBF)
444 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
445 temp_ht_cap = roam_ht_cap->calibration &
446 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
447 if (temp_ht_cap)
448 hdd_ht_cap->tx_BF_cap_info |=
449 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
450 if (roam_ht_cap->explicitCSITxBF)
451 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
452 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
453 hdd_ht_cap->tx_BF_cap_info |=
454 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
455 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
456 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
457 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
458 if (temp_ht_cap)
459 hdd_ht_cap->tx_BF_cap_info |=
460 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
461 temp_ht_cap =
462 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
463 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
464 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
465 if (temp_ht_cap)
466 hdd_ht_cap->tx_BF_cap_info |=
467 temp_ht_cap <<
468 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
469 temp_ht_cap =
470 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
471 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
472 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
473 if (temp_ht_cap)
474 hdd_ht_cap->tx_BF_cap_info |=
475 temp_ht_cap <<
476 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
477 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
478 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
479 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
480 if (temp_ht_cap)
481 hdd_ht_cap->tx_BF_cap_info |=
482 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
483 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
484 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
485 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
486 if (temp_ht_cap)
487 hdd_ht_cap->tx_BF_cap_info |=
488 temp_ht_cap <<
489 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
490 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
491 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
492 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
493 if (temp_ht_cap)
494 hdd_ht_cap->tx_BF_cap_info |=
495 temp_ht_cap <<
496 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
497
498 /* antenna selection */
499 if (roam_ht_cap->antennaSelection)
500 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
501 if (roam_ht_cap->explicitCSIFeedbackTx)
502 hdd_ht_cap->antenna_selection_info |=
503 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
504 if (roam_ht_cap->antennaIndicesFeedbackTx)
505 hdd_ht_cap->antenna_selection_info |=
506 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
507 if (roam_ht_cap->explicitCSIFeedback)
508 hdd_ht_cap->antenna_selection_info |=
509 ANTENNA_SEL_INFO_EXP_CSI_FB;
510 if (roam_ht_cap->antennaIndicesFeedback)
511 hdd_ht_cap->antenna_selection_info |=
512 ANTENNA_SEL_INFO_ANT_ID_FB;
513 if (roam_ht_cap->rxAS)
514 hdd_ht_cap->antenna_selection_info |=
515 ANTENNA_SEL_INFO_RX_AS;
516 if (roam_ht_cap->txSoundingPPDUs)
517 hdd_ht_cap->antenna_selection_info |=
518 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
519
520 /* mcs data rate */
521 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
522 hdd_ht_cap->mcs.rx_mask[i] =
523 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800524 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530525 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
526 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800527 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530528 roam_ht_cap->supportedMCSSet[12];
529}
530
531#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
532#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
533#define VHT_CAP_RXSTBC_MASK_SHIFT 8
534#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
535#define VHT_CAP_BEAMFORMEE_STS_MASK \
536 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
537#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
538#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
539 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
540#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
541#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
542 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
543#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
544
545/**
546 * hdd_copy_ht_caps()- copy ht caps info from roam info to
547 * hdd station context.
548 * @hdd_sta_ctx: pointer to hdd station context
549 * @roam_info: pointer to roam info
550 *
551 * Return: None
552 */
553static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
554 tCsrRoamInfo *roam_info)
555{
556 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
557 struct ieee80211_vht_cap *hdd_vht_cap =
558 &hdd_sta_ctx->conn_info.vht_caps;
559 uint32_t temp_vht_cap;
560
561 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
562
563 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
564 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
565 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
566 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
567 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800568 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530569 if (roam_vht_cap->supportedChannelWidthSet &
570 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
571 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
572 hdd_vht_cap->vht_cap_info |=
573 temp_vht_cap <<
574 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
575 if (roam_vht_cap->supportedChannelWidthSet &
576 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
577 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
578 hdd_vht_cap->vht_cap_info |=
579 temp_vht_cap <<
580 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800581 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530582 if (roam_vht_cap->ldpcCodingCap)
583 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
584 if (roam_vht_cap->shortGI80MHz)
585 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
586 if (roam_vht_cap->shortGI160and80plus80MHz)
587 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
588 if (roam_vht_cap->txSTBC)
589 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
590 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
591 VHT_CAP_RXSTBC_MASK_SHIFT);
592 if (temp_vht_cap)
593 hdd_vht_cap->vht_cap_info |=
594 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
595 if (roam_vht_cap->suBeamFormerCap)
596 hdd_vht_cap->vht_cap_info |=
597 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
598 if (roam_vht_cap->suBeamformeeCap)
599 hdd_vht_cap->vht_cap_info |=
600 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
601 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
602 (VHT_CAP_BEAMFORMEE_STS_MASK);
603 if (temp_vht_cap)
604 hdd_vht_cap->vht_cap_info |=
605 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
606 temp_vht_cap = roam_vht_cap->numSoundingDim &
607 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
608 if (temp_vht_cap)
609 hdd_vht_cap->vht_cap_info |=
610 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
611 if (roam_vht_cap->muBeamformerCap)
612 hdd_vht_cap->vht_cap_info |=
613 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
614 if (roam_vht_cap->muBeamformeeCap)
615 hdd_vht_cap->vht_cap_info |=
616 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
617 if (roam_vht_cap->vhtTXOPPS)
618 hdd_vht_cap->vht_cap_info |=
619 IEEE80211_VHT_CAP_VHT_TXOP_PS;
620 if (roam_vht_cap->htcVHTCap)
621 hdd_vht_cap->vht_cap_info |=
622 IEEE80211_VHT_CAP_HTC_VHT;
623 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
624 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
625 if (temp_vht_cap)
626 hdd_vht_cap->vht_cap_info |=
627 temp_vht_cap <<
628 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
629 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
630 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
631 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
632 if (temp_vht_cap)
633 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
634 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
635 if (roam_vht_cap->rxAntPattern)
636 hdd_vht_cap->vht_cap_info |=
637 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
638 if (roam_vht_cap->txAntPattern)
639 hdd_vht_cap->vht_cap_info |=
640 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
641 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
642 hdd_vht_cap->supp_mcs.rx_highest =
643 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
644 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
645 hdd_vht_cap->supp_mcs.tx_highest =
646 ((uint16_t)roam_vht_cap->txSupDataRate);
647}
648
649/* ht param */
650#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
651#define HT_PARAM_SERVICE_INT_GRAN 0xe0
652#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
653
654/* operatinon mode */
655#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
656
657/* stbc_param */
658#define HT_STBC_PARAM_MCS 0x007f
659
660/**
661 * hdd_copy_ht_operation()- copy HT operation element from roam info to
662 * hdd station context.
663 * @hdd_sta_ctx: pointer to hdd station context
664 * @roam_info: pointer to roam info
665 *
666 * Return: None
667 */
668static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
669 tCsrRoamInfo *roam_info)
670{
671 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
672 struct ieee80211_ht_operation *hdd_ht_ops =
673 &hdd_sta_ctx->conn_info.ht_operation;
674 uint32_t i, temp_ht_ops;
675
676 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
677
678 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
679
680 /* HT_PARAMS */
681 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
682 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
683 if (temp_ht_ops)
684 hdd_ht_ops->ht_param |= temp_ht_ops;
685 else
686 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
687 if (roam_ht_ops->recommendedTxWidthSet)
688 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
689 if (roam_ht_ops->rifsMode)
690 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
691 if (roam_ht_ops->controlledAccessOnly)
692 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
693 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
694 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
695 if (temp_ht_ops)
696 hdd_ht_ops->ht_param |= temp_ht_ops <<
697 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
698
699 /* operation mode */
700 temp_ht_ops = roam_ht_ops->opMode &
701 IEEE80211_HT_OP_MODE_PROTECTION;
702 switch (temp_ht_ops) {
703 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
704 hdd_ht_ops->operation_mode |=
705 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
706 break;
707 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
708 hdd_ht_ops->operation_mode |=
709 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
710 break;
711 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
712 hdd_ht_ops->operation_mode |=
713 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
714 break;
715 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
716 default:
717 hdd_ht_ops->operation_mode |=
718 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
719 }
720 if (roam_ht_ops->nonGFDevicesPresent)
721 hdd_ht_ops->operation_mode |=
722 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
723 if (roam_ht_ops->transmitBurstLimit)
724 hdd_ht_ops->operation_mode |=
725 HT_OP_MODE_TX_BURST_LIMIT;
726 if (roam_ht_ops->obssNonHTStaPresent)
727 hdd_ht_ops->operation_mode |=
728 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
729
730 /* stbc_param */
731 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
732 HT_STBC_PARAM_MCS;
733 if (temp_ht_ops)
734 hdd_ht_ops->stbc_param |= temp_ht_ops;
735 if (roam_ht_ops->dualCTSProtection)
736 hdd_ht_ops->stbc_param |=
737 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
738 if (roam_ht_ops->secondaryBeacon)
739 hdd_ht_ops->stbc_param |=
740 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
741 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
742 hdd_ht_ops->stbc_param |=
743 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
744 if (roam_ht_ops->pcoActive)
745 hdd_ht_ops->stbc_param |=
746 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
747 if (roam_ht_ops->pcoPhase)
748 hdd_ht_ops->stbc_param |=
749 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
750
751 /* basic MCs set */
752 for (i = 0; i < 16; ++i)
753 hdd_ht_ops->basic_set[i] =
754 roam_ht_ops->basicMCSSet[i];
755}
756
757/**
758 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
759 * hdd station context.
760 * @hdd_sta_ctx: pointer to hdd station context
761 * @roam_info: pointer to roam info
762 *
763 * Return: None
764 */
765static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
766 tCsrRoamInfo *roam_info)
767{
768 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
769 struct ieee80211_vht_operation *hdd_vht_ops =
770 &hdd_sta_ctx->conn_info.vht_operation;
771
772 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
773
774 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
775 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
776 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
777 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
778}
779
780
781/**
782 * hdd_save_bss_info() - save connection info in hdd sta ctx
783 * @adapter: Pointer to adapter
784 * @roam_info: pointer to roam info
785 *
786 * Return: None
787 */
788static void hdd_save_bss_info(hdd_adapter_t *adapter,
789 tCsrRoamInfo *roam_info)
790{
791 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
792
793 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
794 hdd_sta_ctx->conn_info.operationChannel);
795 if (roam_info->vht_caps.present) {
796 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
797 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
798 } else {
799 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
800 }
801 if (roam_info->ht_caps.present) {
802 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
803 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
804 } else {
805 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
806 }
807 if (roam_info->reassoc)
808 hdd_sta_ctx->conn_info.roam_count++;
809 if (roam_info->hs20vendor_ie.present) {
810 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
811 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
812 &roam_info->hs20vendor_ie,
813 sizeof(roam_info->hs20vendor_ie));
814 } else {
815 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
816 }
817 if (roam_info->ht_operation.present) {
818 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
819 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
820 } else {
821 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
822 }
823 if (roam_info->vht_operation.present) {
824 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
825 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
826 } else {
827 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
828 }
829}
830
831/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800832 * hdd_conn_save_connect_info() - save current connection information
833 * @pAdapter: pointer to adapter
834 * @pRoamInfo: pointer to roam info
835 * @eBssType: bss type
836 *
837 * Return: none
838 */
839static void
840hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
841 eCsrRoamBssType eBssType)
842{
843 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
844 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
845
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530846 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847
848 if (pRoamInfo) {
849 /* Save the BSSID for the connection */
850 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530851 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530852 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 &pRoamInfo->bssid);
854
855 /*
856 * Save the Station ID for this station from
857 * the 'Roam Info'. For IBSS mode, staId is
858 * assigned in NEW_PEER_IND. For reassoc,
859 * the staID doesn't change and it may be invalid
860 * in this structure so no change here.
861 */
862 if (!pRoamInfo->fReassocReq) {
863 pHddStaCtx->conn_info.staId[0] =
864 pRoamInfo->staId;
865 }
866 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530867 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800868 &pRoamInfo->bssid);
869 } else {
870 /*
871 * can't happen. We need a valid IBSS or Infra setting
872 * in the BSSDescription or we can't function.
873 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530874 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800875 }
876
877 /* notify WMM */
878 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
879
880 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530881 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800882 } else {
883 /* Get Multicast Encryption Type */
884 encryptType =
885 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
886 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
887 /* Get Unicast Encryption Type */
888 encryptType =
889 pRoamInfo->u.pConnectedProfile->EncryptionType;
890 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
891
892 pHddStaCtx->conn_info.authType =
893 pRoamInfo->u.pConnectedProfile->AuthType;
Zhang Qian32fd43e2017-08-24 18:36:28 +0800894 pHddStaCtx->conn_info.last_auth_type =
895 pHddStaCtx->conn_info.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896
897 pHddStaCtx->conn_info.operationChannel =
898 pRoamInfo->u.pConnectedProfile->operationChannel;
899
900 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530901 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 &pRoamInfo->u.pConnectedProfile->SSID,
903 sizeof(tSirMacSSid));
Zhang Qian32fd43e2017-08-24 18:36:28 +0800904 qdf_mem_copy(&pHddStaCtx->conn_info.last_ssid.SSID,
905 &pRoamInfo->u.pConnectedProfile->SSID,
906 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907
908 /* Save dot11mode in which STA associated to AP */
909 pHddStaCtx->conn_info.dot11Mode =
910 pRoamInfo->u.pConnectedProfile->dot11Mode;
911
912 pHddStaCtx->conn_info.proxyARPService =
913 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530914
915 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
916
917 pHddStaCtx->conn_info.rate_flags =
918 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530920 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800922}
923
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800924/**
925 * hdd_send_ft_assoc_response() - send fast transition assoc response
926 * @dev: pointer to net device
927 * @pAdapter: pointer to adapter
928 * @pCsrRoamInfo: pointer to roam info
929 *
930 * Send the 11R key information to the supplicant. Only then can the supplicant
931 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
932 * for the same purpose.)
933 *
934 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
935 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
936 * This is the Assoc Response.
937 *
938 * Return: none
939 */
940static void
941hdd_send_ft_assoc_response(struct net_device *dev,
942 hdd_adapter_t *pAdapter,
943 tCsrRoamInfo *pCsrRoamInfo)
944{
945 union iwreq_data wrqu;
946 char *buff;
947 unsigned int len = 0;
948 u8 *pFTAssocRsp = NULL;
949
950 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700951 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952 return;
953 }
954
955 pFTAssocRsp =
956 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
957 pCsrRoamInfo->nAssocReqLength);
958 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700959 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 return;
961 }
962 /* pFTAssocRsp needs to point to the IEs */
963 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700964 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700965 (unsigned int)pFTAssocRsp[0],
966 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800967
968 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700969 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700971 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800972 return;
973 }
974 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
975 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
976 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977 memcpy(buff, pFTAssocRsp, len);
978 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
979
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700980 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800981}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800983/**
984 * hdd_send_ft_event() - send fast transition event
985 * @pAdapter: pointer to adapter
986 *
987 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
988 * FT events to the supplicant. At the reception of Auth2 we send the RIC
989 * followed by the auth response IEs to the supplicant.
990 * Once both are received in the supplicant, an FT event is generated
991 * to the supplicant.
992 *
993 * Return: none
994 */
995static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
996{
997 uint16_t auth_resp_len = 0;
998 uint32_t ric_ies_length = 0;
999 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1000
1001#if defined(KERNEL_SUPPORT_11R_CFG80211)
1002 struct cfg80211_ft_event_params ftEvent;
1003 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
1004 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
1005 struct net_device *dev = pAdapter->dev;
1006#else
1007 char *buff;
1008 union iwreq_data wrqu;
1009 uint16_t str_len;
1010#endif
1011
1012#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301013 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1014 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001015
1016 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
1017 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001018 if (ric_ies_length == 0)
1019 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001020
1021 ftEvent.ric_ies = ricIe;
1022 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001023 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024
1025 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1026 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1027 &auth_resp_len);
1028
1029 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001030 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 return;
1032 }
1033
1034 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1035
1036 ftEvent.target_ap = ftIe;
1037
Anurag Chouhan6d760662016-02-20 16:05:43 +05301038 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1039 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001041 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1042 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1043 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001044 ftEvent.target_ap[0], ftEvent.target_ap[1],
1045 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1046 ftEvent.target_ap[5]);
1047
1048 (void)cfg80211_ft_event(dev, &ftEvent);
1049
1050#else
1051 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001052 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001053 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001054 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 return;
1056 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057
1058 /* Sme needs to send the RIC IEs first */
1059 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1060 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1061 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1062 &ric_ies_length);
1063 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001064 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001065 } else {
1066 wrqu.data.length = str_len + ric_ies_length;
1067 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1068 }
1069
1070 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301071 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001072 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1073 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1074 (u8 *) &buff[str_len],
1075 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1076
1077 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001078 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001079 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001080 return;
1081 }
1082
1083 wrqu.data.length = str_len + auth_resp_len;
1084 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1085
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001086 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001087#endif
1088}
1089
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090#ifdef FEATURE_WLAN_ESE
1091/**
1092 * hdd_send_new_ap_channel_info() - send new ap channel info
1093 * @dev: pointer to net device
1094 * @pAdapter: pointer to adapter
1095 * @pCsrRoamInfo: pointer to roam info
1096 *
1097 * Send the ESE required "new AP Channel info" to the supplicant.
1098 * (This keeps the supplicant "up to date" on the current channel.)
1099 *
1100 * The current (new AP) channel information is passed in.
1101 *
1102 * Return: none
1103 */
1104static void
1105hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1106 tCsrRoamInfo *pCsrRoamInfo)
1107{
1108 union iwreq_data wrqu;
1109 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1110
1111 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001112 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 return;
1114 }
1115 /*
1116 * Send the Channel event, the supplicant needs this to generate
1117 * the Adjacent AP report.
1118 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001119 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001120 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 memset(&wrqu, '\0', sizeof(wrqu));
1122 wrqu.freq.m = descriptor->channelId;
1123 wrqu.freq.e = 0;
1124 wrqu.freq.i = 0;
1125 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1126}
1127
1128#endif /* FEATURE_WLAN_ESE */
1129
1130/**
1131 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1132 * @pAdapter: pointer to adapter
1133 * @pCsrRoamInfo: pointer to roam info
1134 *
1135 * Return: none
1136 */
1137static void
1138hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1139 tCsrRoamInfo *pCsrRoamInfo)
1140{
1141 union iwreq_data wrqu;
1142 u8 *pBeaconIes;
1143 u8 currentLen = 0;
1144 char *buff;
1145 int totalIeLen = 0, currentOffset = 0, strLen;
1146
1147 memset(&wrqu, '\0', sizeof(wrqu));
1148
1149 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001150 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 return;
1152 }
1153 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1154 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001155 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156 return;
1157 }
1158 /* pBeaconIes needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001159 hdd_debug("Beacon IEs is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001160 (unsigned int)pBeaconIes[0],
1161 (unsigned int)pBeaconIes[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001162 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001163 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001164
1165 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001166 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001168 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 return;
1170 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171
1172 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1173 currentLen = strLen + 1;
1174
1175 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1176 do {
1177 /*
1178 * If the beacon size exceeds max CUSTOM event size, break it
1179 * into chunks of CUSTOM event max size and send it to
1180 * supplicant. Changes are done in supplicant to handle this.
1181 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301182 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001183 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301184 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301185 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001186 currentLen);
1187 currentOffset += currentLen;
1188 totalIeLen -= currentLen;
1189 wrqu.data.length = strLen + 1 + currentLen;
1190 if (totalIeLen)
1191 buff[strLen] = 1; /* more chunks pending */
1192 else
1193 buff[strLen] = 0; /* last chunk */
1194
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001195 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001196 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1198 } while (totalIeLen > 0);
1199
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001200 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201}
1202
1203/**
1204 * hdd_send_association_event() - send association event
1205 * @dev: pointer to net device
1206 * @pCsrRoamInfo: pointer to roam info
1207 *
1208 * Return: none
1209 */
1210static void hdd_send_association_event(struct net_device *dev,
1211 tCsrRoamInfo *pCsrRoamInfo)
1212{
Rajeev Kumar78427682017-01-13 16:13:11 -08001213 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1215 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1216 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1217 union iwreq_data wrqu;
1218 int we_event;
1219 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301220 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001221
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 /* Added to find the auth type on the fly at run time */
1223 /* rather than with cfg to see if FT is enabled */
1224 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1225 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001226
1227 memset(&wrqu, '\0', sizeof(wrqu));
1228 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1229 we_event = SIOCGIWAP;
1230#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1231 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301232 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001234 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301235 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001236 hdd_notify_sta_disconnect(pAdapter->sessionId,
1237 true, pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301238 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301239 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240#endif
1241 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001242 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301243
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001244 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001245 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 return;
1247 }
1248
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001249 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001250 policy_mgr_incr_active_session(pHddCtx->hdd_psoc,
1251 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001252 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1253 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1254
1255#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001256 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001257 if (global_p2p_connection_status ==
1258 P2P_CLIENT_CONNECTING_STATE_1) {
1259 global_p2p_connection_status =
1260 P2P_CLIENT_CONNECTED_STATE_1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001261 hdd_debug("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001262 } else if (global_p2p_connection_status ==
1263 P2P_CLIENT_CONNECTING_STATE_2) {
1264 global_p2p_connection_status =
1265 P2P_CLIENT_COMPLETED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001266 hdd_debug("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001267 }
1268 }
1269#endif
1270 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1271 MAC_ADDRESS_STR "\n",
1272 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1273 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1274 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1275
1276 /*
1277 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1278 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001279 * fFTEnable is true.
1280 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001281 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001282 if ((pRoamProfile->AuthType.authType[0] ==
1283 eCSR_AUTH_TYPE_FT_RSN_PSK)
1284 || (pRoamProfile->AuthType.authType[0] ==
1285 eCSR_AUTH_TYPE_FT_RSN)
1286#ifdef FEATURE_WLAN_ESE
1287 || (pRoamProfile->AuthType.authType[0] ==
1288 eCSR_AUTH_TYPE_CCKM_RSN)
1289 || (pRoamProfile->AuthType.authType[0] ==
1290 eCSR_AUTH_TYPE_CCKM_WPA)
1291#endif
1292 ) {
1293 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1294 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301295 qdf_copy_macaddr(&peerMacAddr,
1296 &pHddStaCtx->conn_info.bssId);
1297 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1298 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1299 chan_info.info = pCsrRoamInfo->chan_info.info;
1300 chan_info.band_center_freq1 =
1301 pCsrRoamInfo->chan_info.band_center_freq1;
1302 chan_info.band_center_freq2 =
1303 pCsrRoamInfo->chan_info.band_center_freq2;
1304 chan_info.reg_info_1 =
1305 pCsrRoamInfo->chan_info.reg_info_1;
1306 chan_info.reg_info_2 =
1307 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301308
Dustin Brown7d043f62017-03-27 12:07:36 -07001309 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1310 pAdapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301311 peerMacAddr.bytes,
1312 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001313 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301314 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1315 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001316 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1317 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301318 if (ret)
1319 hdd_err("Peer object %pM fail to set associated state",
1320 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301321
Abhishek Singh1c676222016-05-09 14:20:28 +05301322 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001323 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1324 ePeerConnected,
1325 pCsrRoamInfo->timingMeasCap,
1326 pAdapter->sessionId, &chan_info,
1327 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001328 /* Update tdls module about connection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001329 hdd_notify_sta_connect(pAdapter->sessionId,
1330 pCsrRoamInfo->tdls_chan_swit_prohibited,
1331 pCsrRoamInfo->tdls_prohibited,
1332 pAdapter->hdd_vdev);
1333
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001334 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001335
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001336
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001338#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001339 /* start timer in sta/p2p_cli */
1340 spin_lock_bh(&pHddCtx->bus_bw_lock);
1341 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1342 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001343 cdp_get_intra_bss_fwd_pkts_count(
1344 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301345 &pAdapter->prev_fwd_tx_packets,
1346 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001347 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001348 hdd_bus_bw_compute_timer_start(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349#endif
1350#endif
1351 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1352 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001353 policy_mgr_update_connection_info(pHddCtx->hdd_psoc,
1354 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001355 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001356 ETH_ALEN);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001357 hdd_info("wlan: new IBSS connection to " MAC_ADDRESS_STR,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001358 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301359
Dustin Brown7d043f62017-03-27 12:07:36 -07001360 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1361 QDF_IBSS_MODE,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301362 pCsrRoamInfo->bssid.bytes,
1363 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001364 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301365 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1366 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001367 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1368 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301369 if (ret)
1370 hdd_err("Peer object %pM fail to set associated state",
1371 peerMacAddr.bytes);
1372
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 } else { /* Not Associated */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001374 hdd_info("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001375 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001376 policy_mgr_decr_session_set_pcl(pHddCtx->hdd_psoc,
1377 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001378
1379#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1380 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1381#endif
1382
Abhishek Singh1c676222016-05-09 14:20:28 +05301383 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1384 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301385 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 &pHddStaCtx->conn_info.bssId);
1387
1388 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001389 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301390 ePeerDisconnected, 0,
1391 pAdapter->sessionId,
1392 NULL,
1393 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301395
Dustin Brown7d043f62017-03-27 12:07:36 -07001396 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1397 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001398 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301399 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1400 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1401
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001402 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001403 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001404 hdd_notify_sta_disconnect(pAdapter->sessionId,
1405 false,
1406 pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301407 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409#ifdef MSM_PLATFORM
1410 /* stop timer in sta/p2p_cli */
1411 spin_lock_bh(&pHddCtx->bus_bw_lock);
1412 pAdapter->prev_tx_packets = 0;
1413 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301414 pAdapter->prev_fwd_tx_packets = 0;
1415 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001416 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001417 hdd_bus_bw_compute_timer_try_stop(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001418#endif
1419 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001420 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 /* Send SCC/MCC Switching event to IPA */
1422 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1423
1424 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001425 /* During the WLAN uninitialization,supplicant is stopped before the
1426 * driver so not sending the status of the connection to supplicant
1427 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001428 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001429 wireless_send_event(dev, we_event, &wrqu, msg);
1430#ifdef FEATURE_WLAN_ESE
1431 if (eConnectionState_Associated ==
1432 pHddStaCtx->conn_info.connState) {
1433 if ((pRoamProfile->AuthType.authType[0] ==
1434 eCSR_AUTH_TYPE_CCKM_RSN) ||
1435 (pRoamProfile->AuthType.authType[0] ==
1436 eCSR_AUTH_TYPE_CCKM_WPA))
1437 hdd_send_new_ap_channel_info(dev, pAdapter,
1438 pCsrRoamInfo);
1439 }
1440#endif
1441 }
1442}
1443
1444/**
1445 * hdd_conn_remove_connect_info() - remove connection info
1446 * @pHddStaCtx: pointer to global HDD station context
1447 * @pCsrRoamInfo: pointer to roam info
1448 *
1449 * Return: none
1450 */
1451static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1452{
1453 /* Remove staId, bssId and peerMacAddress */
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301454 pHddStaCtx->conn_info.staId[0] = HDD_WLAN_INVALID_STA_ID;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301455 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1456 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301457 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001458
1459 /* Clear all security settings */
1460 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1461 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1462 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1463
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301464 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1465 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001466
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001467 pHddStaCtx->conn_info.proxyARPService = 0;
1468
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301469 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470}
1471
1472/**
1473 * hdd_roam_deregister_sta() - deregister station
1474 * @pAdapter: pointer to adapter
1475 * @staId: station identifier
1476 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301477 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001478 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301479QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001480{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301481 QDF_STATUS qdf_status;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301482 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1483 int ret = 0;
1484 uint8_t *peer_mac = NULL;
1485 struct qdf_mac_addr broadcastMacAddr =
1486 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001487 if (eConnectionState_IbssDisconnected ==
1488 pHddStaCtx->conn_info.connState) {
1489 /*
1490 * Do not set the carrier off when the last peer leaves.
1491 * We will set the carrier off while stopping the IBSS.
1492 */
1493 }
1494
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001495 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001496 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301497 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301498 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301499 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1500 staid, qdf_status, qdf_status);
1501 }
1502
1503 if (adapter->device_mode == QDF_STA_MODE) {
1504 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1505 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1506 if (pHddStaCtx->broadcast_staid == staid)
1507 peer_mac = broadcastMacAddr.bytes;
1508 else
1509 peer_mac = pHddStaCtx->conn_info.
1510 peerMacAddress[staid].bytes;
1511 }
1512
Dustin Brown7d043f62017-03-27 12:07:36 -07001513 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301514 if (ret) {
1515 hdd_err("Peer obj %pM delete fails", peer_mac);
1516 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001517 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301518 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001519}
1520
1521/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301522 * hdd_print_bss_info() - print bss info
1523 * @hdd_sta_ctx: pointer to hdd station context
1524 *
1525 * Return: None
1526 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001527static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301528{
1529 uint32_t *cap_info;
1530
1531 hdd_info("WIFI DATA LOGGER");
1532 hdd_info("channel: %d",
1533 hdd_sta_ctx->conn_info.freq);
1534 hdd_info("dot11mode: %d",
1535 hdd_sta_ctx->conn_info.dot11Mode);
1536 hdd_info("AKM: %d",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001537 hdd_sta_ctx->conn_info.last_auth_type);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301538 hdd_info("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001539 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1540 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301541 hdd_info("roam count: %d",
1542 hdd_sta_ctx->conn_info.roam_count);
1543 hdd_info("ant_info: %d",
1544 hdd_sta_ctx->conn_info.txrate.nss);
1545 hdd_info("datarate legacy %d",
1546 hdd_sta_ctx->conn_info.txrate.legacy);
1547 hdd_info("datarate mcs: %d",
1548 hdd_sta_ctx->conn_info.txrate.mcs);
1549 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1550 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1551 hdd_info("ht caps: %x", *cap_info);
1552 }
1553 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1554 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1555 hdd_info("vht caps: %x", *cap_info);
1556 }
1557 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1558 hdd_info("hs20 info: %x",
1559 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1560 hdd_info("signal: %d",
1561 hdd_sta_ctx->conn_info.signal);
1562 hdd_info("noise: %d",
1563 hdd_sta_ctx->conn_info.noise);
1564}
1565
1566/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001567 * hdd_dis_connect_handler() - disconnect event handler
1568 * @pAdapter: pointer to adapter
1569 * @pRoamInfo: pointer to roam info
1570 * @roamId: roam identifier
1571 * @roamStatus: roam status
1572 * @roamResult: roam result
1573 *
1574 * This function handles disconnect event:
1575 * 1. Disable transmit queues;
1576 * 2. Clean up internal connection states and data structures;
1577 * 3. Send disconnect indication to supplicant.
1578 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301579 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001580 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301581static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001582 tCsrRoamInfo *pRoamInfo,
1583 uint32_t roamId,
1584 eRoamCmdStatus roamStatus,
1585 eCsrRoamResult roamResult)
1586{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301587 QDF_STATUS status = QDF_STATUS_SUCCESS;
1588 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001589 struct net_device *dev = pAdapter->dev;
1590 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1591 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1592 uint8_t sta_id;
1593 bool sendDisconInd = true;
1594
1595 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001596 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301597 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598 }
1599 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001600 hdd_debug("Disabling queues");
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301601 wlan_hdd_netif_queue_control(pAdapter,
1602 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1603 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604
1605 if (hdd_ipa_is_enabled(pHddCtx))
1606 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001607 HDD_IPA_STA_DISCONNECT,
1608 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609
1610#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1611 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1612#endif
1613
Nirav Shah1da77682016-05-03 20:16:39 +05301614 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1615 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001616 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301617 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001618
1619 /* HDD has initiated disconnect, do not send disconnect indication
1620 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301621 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 * to cfg80211_disconnected.
1623 */
1624 if ((eConnectionState_Disconnecting ==
1625 pHddStaCtx->conn_info.connState) ||
1626 (eConnectionState_NotConnected ==
1627 pHddStaCtx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001628 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 sendDisconInd = false;
1630 }
1631
1632 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1633 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 hdd_conn_set_connection_state(pAdapter,
1635 eConnectionState_Disconnecting);
1636 }
1637
1638 hdd_clear_roam_profile_ie(pAdapter);
1639 hdd_wmm_init(pAdapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001640 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301641 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642
1643 /* indicate 'disconnect' status to wpa_supplicant... */
1644 hdd_send_association_event(dev, pRoamInfo);
1645 /* indicate disconnected event to nl80211 */
1646 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1647 /*
1648 * Only send indication to kernel if not initiated
1649 * by kernel
1650 */
1651 if (sendDisconInd) {
1652 /*
1653 * To avoid wpa_supplicant sending "HANGED" CMD
1654 * to ICS UI.
1655 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001656 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1657 if (pRoamInfo->reasonCode ==
1658 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1659 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301660 wlan_hdd_cfg80211_indicate_disconnect(
1661 dev, false,
1662 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001663 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301664 wlan_hdd_cfg80211_indicate_disconnect(
1665 dev, false,
1666 WLAN_REASON_UNSPECIFIED
1667 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001669
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301670 hdd_info("sent disconnected event to nl80211, reason code %d",
1671 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1672 pRoamInfo->reasonCode :
1673 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 }
1675 /*
1676 * During the WLAN uninitialization,supplicant is stopped
1677 * before the driver so not sending the status of the
1678 * connection to supplicant.
1679 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001680 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001682 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 if (global_p2p_connection_status ==
1684 P2P_CLIENT_CONNECTED_STATE_1) {
1685 global_p2p_connection_status =
1686 P2P_CLIENT_DISCONNECTED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001687 hdd_debug("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 } else if (global_p2p_connection_status ==
1689 P2P_CLIENT_COMPLETED_STATE) {
1690 global_p2p_connection_status =
1691 P2P_NOT_ACTIVE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001692 hdd_debug("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001693 }
1694 }
1695#endif
1696
1697 }
1698 }
1699
1700 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001701 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001702 if (hdd_remove_beacon_filter(pAdapter) != 0)
1703 hdd_err("hdd_remove_beacon_filter() failed");
1704
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301706 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001707
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001708 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001709 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301710 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001711 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301712 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301713 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001714 }
1715 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301716 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001717 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001718 if (HDD_WLAN_INVALID_STA_ID ==
1719 pHddStaCtx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301720 continue;
1721 sta_id = pHddStaCtx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001722 hdd_debug("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301723 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301724 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001725 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301726 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301727 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301728 }
1729 /* set the staid and peer mac as 0, all other
1730 * reset are done in hdd_connRemoveConnectInfo.
1731 */
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301732 pHddStaCtx->conn_info.staId[i] =
1733 HDD_WLAN_INVALID_STA_ID;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301734 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301735 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301736 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1737 pHddCtx->sta_to_adapter[sta_id] = NULL;
1738 }
1739 } else {
1740 sta_id = pHddStaCtx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001741 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301742
1743 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001744 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1745 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301746 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301747 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1748 pHddStaCtx->conn_info.bssId.bytes);
1749 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1750 pHddStaCtx->conn_info.bssId.bytes);
1751 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301752 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 /* Clear saved connection information in HDD */
1755 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301757 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758
1759#ifdef FEATURE_WLAN_TDLS
1760 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1761 wlan_hdd_tdls_disconnection_callback(pAdapter);
1762#endif
1763
Krunal Sonibe766b02016-03-10 13:00:44 -08001764 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1765 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1767 (pAdapter),
1768 pAdapter->sessionId);
1769 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301770 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 /* Unblock anyone waiting for disconnect to complete */
1772 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301773 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 return status;
1775}
1776
1777/**
1778 * hdd_set_peer_authorized_event() - set peer_authorized_event
1779 * @vdev_id: vdevid
1780 *
1781 * Return: None
1782 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001783static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301785 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 hdd_adapter_t *adapter = NULL;
1787
1788 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1789 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001790 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001791 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792 }
1793 complete(&adapter->sta_authorized_event);
1794}
1795
1796/**
1797 * hdd_change_peer_state() - change peer state
1798 * @pAdapter: HDD adapter
1799 * @sta_state: peer state
1800 * @roam_synch_in_progress: roam synch in progress
1801 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301802 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 uint8_t sta_id,
1806 enum ol_txrx_peer_state sta_state,
1807 bool roam_synch_in_progress)
1808{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301809 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001810 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001811 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1812 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1813 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814
1815 if (!pdev) {
1816 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301817 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001818 }
1819
1820 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001821 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301822 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 }
1824
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001825 peer = cdp_peer_find_by_local_id(soc,
1826 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301828 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829
Leo Changfdb45c32016-10-28 11:09:23 -07001830 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001831 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001832 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001833 return QDF_STATUS_E_FAULT;
1834 }
1835
Leo Changfdb45c32016-10-28 11:09:23 -07001836 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001838 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301839 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 }
1841#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1842 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301843 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844#endif
1845
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001846 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1848 /* make sure event is reset */
1849 INIT_COMPLETION(pAdapter->sta_authorized_event);
1850#endif
1851
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001852 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853 hdd_set_peer_authorized_event,
1854 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301855 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001856 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301857 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 }
1859
Krunal Sonibe766b02016-03-10 13:00:44 -08001860 if (pAdapter->device_mode == QDF_STA_MODE ||
1861 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001863 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001864 unsigned long rc;
1865
1866 /* wait for event from firmware to set the event */
1867 rc = wait_for_completion_timeout(
1868 &pAdapter->sta_authorized_event,
1869 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001870 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001871 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001872
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001873 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1874 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001875 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001876#endif
1877 }
1878 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301879 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880}
1881
1882/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001883 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1884 * @cbk_data: callback data
1885 * @sta_id: station id
1886 * @vdev_param: vdev parameter
1887 * @is_link_up: link state up or down
1888 *
1889 * Return: QDF status
1890 */
1891QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1892 uint8_t sta_id,
1893 uint32_t vdev_param,
1894 bool is_link_up)
1895{
1896 struct cdp_vdev *data_vdev;
1897 QDF_STATUS status = QDF_STATUS_SUCCESS;
1898 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1899 hdd_context_t *hdd_ctx;
1900 struct wlan_objmgr_psoc **psoc;
1901
1902 if (!cbk_data)
1903 return status;
1904
1905 psoc = cbk_data;
1906 hdd_ctx = container_of(psoc, hdd_context_t, hdd_psoc);
1907
1908 if (!hdd_ctx->tdls_nap_active)
1909 return status;
1910
1911 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, sta_id);
1912 if (NULL == data_vdev) {
1913 status = QDF_STATUS_E_FAILURE;
1914 return status;
1915 }
1916
1917 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1918
1919 return status;
1920}
1921
1922/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 * hdd_roam_register_sta() - register station
1924 * @pAdapter: pointer to adapter
1925 * @pRoamInfo: pointer to roam info
1926 * @staId: station identifier
1927 * @pPeerMacAddress: peer MAC address
1928 * @pBssDesc: pointer to BSS description
1929 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301930 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001931 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001932QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 tCsrRoamInfo *pRoamInfo,
1934 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301935 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 tSirBssDescription *pBssDesc)
1937{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301938 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001939 struct ol_txrx_desc_type staDesc = { 0 };
1940 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001941 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001942 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1943 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944
1945 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301946 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947
1948 /* Get the Station ID from the one saved during the association */
1949 staDesc.sta_id = staId;
1950
1951 /* set the QoS field appropriately */
1952 if (hdd_wmm_is_active(pAdapter))
1953 staDesc.is_qos_enabled = 1;
1954 else
1955 staDesc.is_qos_enabled = 0;
1956
1957#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07001958 hdd_debug("WAPI STA Registered: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001959 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 if (pAdapter->wapi_info.fIsWapiSta)
1961 staDesc.is_wapi_supported = 1;
1962 else
1963 staDesc.is_wapi_supported = 0;
1964#endif /* FEATURE_WLAN_WAPI */
1965
Dhanashri Atre50141c52016-04-07 13:15:29 -07001966 /* Register the vdev transmit and receive functions */
1967 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1968 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001969
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001970 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1971 (struct cdp_pdev *)pdev,
1972 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001973 if (!pAdapter->txrx_vdev) {
1974 hdd_err("%s find vdev fail", __func__);
1975 return QDF_STATUS_E_FAILURE;
1976 }
1977
1978 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001979 cdp_vdev_register(soc,
1980 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001981 if (!txrx_ops.tx.tx) {
1982 hdd_err("%s vdev register fail", __func__);
1983 return QDF_STATUS_E_FAILURE;
1984 }
1985
Dhanashri Atre50141c52016-04-07 13:15:29 -07001986 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001987 qdf_status = cdp_peer_register(soc,
1988 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301989 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001990 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001991 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301992 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993 }
1994
1995 if (!pRoamInfo->fAuthRequired) {
1996 /*
1997 * Connections that do not need Upper layer auth, transition
1998 * TLSHIM directly to 'Authenticated' state
1999 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302000 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002002 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002003#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2004 pRoamInfo->roamSynchInProgress
2005#else
2006 false
2007#endif
2008 );
2009
2010 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002011 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002013 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302015 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002016 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002017 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002018#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2019 pRoamInfo->roamSynchInProgress
2020#else
2021 false
2022#endif
2023 );
2024 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002025 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002026 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302027 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028}
2029
2030/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302031 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2032 * @dev: network device
2033 * @bss: cfg80211 roamed bss pointer
2034 * @req_ie: IEs used in reassociation request
2035 * @req_ie_len: Length of the @req_ie
2036 * @resp_ie: IEs received in successful reassociation response
2037 * @resp_ie_len: Length of @resp_ie
2038 *
2039 * Return: none
2040 */
2041#if defined CFG80211_ROAMED_API_UNIFIED || \
2042 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2043static void hdd_send_roamed_ind(struct net_device *dev,
2044 struct cfg80211_bss *bss, const uint8_t *req_ie,
2045 size_t req_ie_len, const uint8_t *resp_ie,
2046 size_t resp_ie_len)
2047{
2048 struct cfg80211_roam_info info = {0};
2049
2050 info.bss = bss;
2051 info.req_ie = req_ie;
2052 info.req_ie_len = req_ie_len;
2053 info.resp_ie = resp_ie;
2054 info.resp_ie_len = resp_ie_len;
2055 cfg80211_roamed(dev, &info, GFP_KERNEL);
2056}
2057#else
2058static inline void hdd_send_roamed_ind(struct net_device *dev,
2059 struct cfg80211_bss *bss,
2060 const uint8_t *req_ie, size_t req_ie_len,
2061 const uint8_t *resp_ie,
2062 size_t resp_ie_len)
2063{
2064 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2065 GFP_KERNEL);
2066}
2067#endif
2068
2069/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002070 * hdd_send_re_assoc_event() - send reassoc event
2071 * @dev: pointer to net device
2072 * @pAdapter: pointer to adapter
2073 * @pCsrRoamInfo: pointer to roam info
2074 * @reqRsnIe: pointer to RSN Information element
2075 * @reqRsnLength: length of RSN IE
2076 *
2077 * Return: none
2078 */
2079static void hdd_send_re_assoc_event(struct net_device *dev,
2080 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
2081 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2082{
2083 unsigned int len = 0;
2084 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002085 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2086 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002087 uint32_t rspRsnLength = 0;
2088 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002089 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2090 uint8_t *buf_ptr, ssid_ie_len;
2091 struct cfg80211_bss *bss = NULL;
2092 uint8_t *final_req_ie = NULL;
2093 tCsrRoamConnectedProfile roam_profile;
2094 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002095 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002097 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2098
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002099 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002100 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002101 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 }
2103
Naveen Rawat14298b92015-11-25 16:27:41 -08002104 if (!assoc_req_ies) {
2105 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002106 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002107 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002108 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002109 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002110 goto done;
2111 }
2112
2113 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002114 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 goto done;
2116 }
2117
2118 pFTAssocRsp =
2119 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2120 pCsrRoamInfo->nAssocReqLength);
2121 if (pFTAssocRsp == NULL)
2122 goto done;
2123
2124 /* pFTAssocRsp needs to point to the IEs */
2125 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002126 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002127 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128
2129 /*
2130 * Active session count is decremented upon disconnection, but during
2131 * roaming, there is no disconnect indication and hence active session
2132 * count is not decremented.
2133 * After roaming is completed, active session count is incremented
2134 * as a part of connect indication but effectively after roaming the
2135 * active session count should still be the same and hence upon
2136 * successful reassoc decrement the active session count here.
2137 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002138 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002139 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
2140 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141
2142 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2143 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2144 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302145 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2146 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147
2148 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302149 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002150 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2151 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302152
2153 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2154 chan, pCsrRoamInfo->bssid.bytes,
2155 &roam_profile.SSID.ssId[0],
2156 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002157
2158 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002159 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 buf_ptr = buf_ssid_ie;
2161 *buf_ptr = SIR_MAC_SSID_EID;
2162 buf_ptr++;
2163 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2164 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302165 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 roam_profile.SSID.length);
2167 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002168 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302169 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002170 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002171 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Kapil Gupta8731e812017-07-11 18:42:39 +05302172 if (final_req_ie == NULL) {
2173 if (bss)
2174 cfg80211_put_bss(pAdapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002175 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302176 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302178 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002179 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302180 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2181 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2182 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002183 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002184 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302185 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002186 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302187 hdd_send_roamed_ind(dev, bss, final_req_ie,
2188 (ssid_ie_len + reqRsnLength), rspRsnIe,
2189 rspRsnLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302191 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002192 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2193 pCsrRoamInfo->nAssocReqLength);
2194
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002195 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302196 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002197 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2198
Prakash Dhavali989127d2016-11-29 14:56:44 +05302199 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002200 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2201 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002202 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002204 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002205 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002206 qdf_mem_free(final_req_ie);
2207 qdf_mem_free(rspRsnIe);
2208 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002209}
2210
2211/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302212 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002213 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302214 *
2215 * Return: roam sync status if roaming offloaded else false
2216 */
2217#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002218bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302219{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002220 if (roaminfo)
2221 return roaminfo->roamSynchInProgress;
2222 else
2223 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302224}
2225#endif
2226
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002227/**
2228 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2229 * @hddstactx: pointer to HDD sta context
2230 * @roaminfo: pointer to roaminfo structure
2231 *
2232 * This function returns staid for IBSS peer. If peer is broadcast
2233 * MAC address return self staid(0) else find the peer sta id of
2234 * the peer.
2235 *
2236 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2237 */
2238static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2239 tCsrRoamInfo *roaminfo)
2240{
2241 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2242 QDF_STATUS status;
2243
2244 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2245 staid = 0;
2246 } else {
2247 status = hdd_get_peer_sta_id(hddstactx,
2248 &roaminfo->peerMac, &staid);
2249 if (status != QDF_STATUS_SUCCESS) {
2250 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2251 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2252 }
2253 }
2254
2255 return staid;
2256}
Govind Singhedc5cda2015-10-23 17:11:35 +05302257
2258/**
2259 * hdd_change_sta_state_authenticated()-
2260 * This function changes STA state to authenticated
2261 * @adapter: pointer to the adapter structure.
2262 * @roaminfo: pointer to the RoamInfo structure.
2263 *
2264 * This is called from hdd_RoamSetKeyCompleteHandler
2265 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2266 *
2267 * Return: 0 on success and errno on failure
2268 */
2269static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2270 tCsrRoamInfo *roaminfo)
2271{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002272 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002273 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002274 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302275 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002276 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302277
Dustin Brownf660fb42016-09-09 12:04:00 -07002278 timeout = hddstactx->hdd_ReassocScenario ?
2279 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002280 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002281
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002282 if (QDF_IBSS_MODE == adapter->device_mode)
2283 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2284 else
2285 staid = hddstactx->conn_info.staId[0];
2286
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002287 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302288
2289 /* Connections that do not need Upper layer authentication,
2290 * transition TL to 'Authenticated' state after the keys are set
2291 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002292 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302293 hdd_is_roam_sync_in_progress(roaminfo));
2294 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002295 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2296
Krunal Sonibe766b02016-03-10 13:00:44 -08002297 if ((QDF_STA_MODE == adapter->device_mode) ||
2298 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302299 sme_ps_enable_auto_ps_timer(
2300 WLAN_HDD_GET_HAL_CTX(adapter),
2301 adapter->sessionId,
Dustin Brown84411b02017-07-21 16:44:44 -07002302 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302303 }
2304
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002305 return qdf_status_to_os_return(status);
2306}
2307
2308/**
2309 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2310 * if key installation is required
2311 * @encr_type: encryption type
2312 *
2313 * Return: true if key installation is required and false otherwise.
2314 */
2315static inline bool hdd_is_key_install_required_for_ibss(
2316 eCsrEncryptionType encr_type)
2317{
2318 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2319 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2320 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302321 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2322 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002323 eCSR_ENCRYPT_TYPE_AES == encr_type)
2324 return true;
2325 else
2326 return false;
2327}
2328
2329/**
2330 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2331 * complete
2332 * @adapter: pointer to HDD adapter
2333 * @roaminfo: pointer to roam info
2334 * @roam_result: roam result
2335 *
2336 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2337 * This function checks for the successful set key completion and update
2338 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2339 *
2340 * Return: None
2341 */
2342static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2343 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2344{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002345 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2346 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2347
2348 /*
2349 * If the security mode is one of the following, IBSS peer will be
2350 * waiting in CONN state and we will move the peer state to AUTH
2351 * here. For non-secure connection, no need to wait for set-key complete
2352 * peer will be moved to AUTH in hdd_roam_register_sta.
2353 */
2354 if (QDF_IBSS_MODE == adapter->device_mode) {
2355 if (hdd_is_key_install_required_for_ibss(encr_type))
2356 hdd_change_sta_state_authenticated(adapter, roaminfo);
2357
2358 return;
2359 }
2360
2361 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2362 hdd_sta_ctx->conn_info.gtk_installed = true;
2363 /*
2364 * PTK exchange happens in preauthentication itself if key_mgmt
2365 * is FT-PSK, ptk_installed was false as there is no set PTK
2366 * after roaming. STA TL state moves to authenticated only if
2367 * ptk_installed is true. So, make ptk_installed to true in
2368 * case of 11R roaming.
2369 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302370 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2371 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002372 hdd_sta_ctx->conn_info.ptk_installed = true;
2373 } else {
2374 hdd_sta_ctx->conn_info.ptk_installed = true;
2375 }
2376
2377 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2378 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2379 * unicast key and it was resulting in sending few un-encrypted packet.
2380 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2381 * set the unicast and broadcast key.
2382 */
2383 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2384 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2385 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2386 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2387 if (hdd_sta_ctx->conn_info.gtk_installed &&
2388 hdd_sta_ctx->conn_info.ptk_installed)
2389 hdd_change_sta_state_authenticated(adapter, roaminfo);
2390 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2391 hdd_change_sta_state_authenticated(adapter, roaminfo);
2392 }
2393
2394 if (hdd_sta_ctx->conn_info.gtk_installed &&
2395 hdd_sta_ctx->conn_info.ptk_installed) {
2396 hdd_sta_ctx->conn_info.gtk_installed = false;
2397 hdd_sta_ctx->conn_info.ptk_installed = false;
2398 }
2399
2400 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2401
2402 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302403}
2404
2405/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 * hdd_roam_set_key_complete_handler() - Update the security parameters
2407 * @pAdapter: pointer to adapter
2408 * @pRoamInfo: pointer to roam info
2409 * @roamId: roam id
2410 * @roamStatus: roam status
2411 * @roamResult: roam result
2412 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302413 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302415static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002416 tCsrRoamInfo *pRoamInfo,
2417 uint32_t roamId,
2418 eRoamCmdStatus roamStatus,
2419 eCsrRoamResult roamResult)
2420{
2421 eCsrEncryptionType connectedCipherAlgo;
2422 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302424
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002425 ENTER();
2426
2427 if (NULL == pRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002428 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302429 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002430 }
2431 /*
2432 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2433 * then go to 'authenticated'. For all other authentication types
2434 * (those that do not require upper layer authentication) we can put TL
2435 * directly into 'authenticated' state.
2436 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002437 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002438 MAC_ADDRESS_STR, roamStatus, roamResult,
2439 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2440
2441 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2442 &connectedCipherAlgo);
2443 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002444 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2445 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 } else {
2447 /*
2448 * possible disassoc after issuing set key and waiting
2449 * set key complete.
2450 */
2451 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2452 }
2453
2454 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302455 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456}
2457
2458/**
2459 * hdd_perform_roam_set_key_complete() - perform set key complete
2460 * @pAdapter: pointer to adapter
2461 *
2462 * Return: none
2463 */
2464void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2465{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302466 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002467 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2468 tCsrRoamInfo roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002469
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302471 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302472 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302473 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302474 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302476 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002477 hdd_roam_set_key_complete_handler(pAdapter,
2478 &roamInfo,
2479 pHddStaCtx->roam_info.roamId,
2480 pHddStaCtx->roam_info.roamStatus,
2481 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302482 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002483 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484
2485 pHddStaCtx->roam_info.deferKeyComplete = false;
2486}
2487
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05302488#if defined(WLAN_FEATURE_FILS_SK) && defined(CFG80211_FILS_SK_OFFLOAD_SUPPORT)
2489void hdd_clear_fils_connection_info(hdd_adapter_t *adapter)
2490{
2491 hdd_wext_state_t *wext_state;
2492
2493 if ((adapter->device_mode == QDF_SAP_MODE) ||
2494 (adapter->device_mode == QDF_P2P_GO_MODE))
2495 return;
2496
2497 wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
2498 if (wext_state->roamProfile.fils_con_info) {
2499 qdf_mem_free(wext_state->roamProfile.fils_con_info);
2500 wext_state->roamProfile.fils_con_info = NULL;
2501 }
2502}
2503#endif
2504
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505/**
2506 * hdd_association_completion_handler() - association completion handler
2507 * @pAdapter: pointer to adapter
2508 * @pRoamInfo: pointer to roam info
2509 * @roamId: roam id
2510 * @roamStatus: roam status
2511 * @roamResult: roam result
2512 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302513 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002514 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302515static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 tCsrRoamInfo *pRoamInfo,
2517 uint32_t roamId,
2518 eRoamCmdStatus roamStatus,
2519 eCsrRoamResult roamResult)
2520{
2521 struct net_device *dev = pAdapter->dev;
2522 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2523 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302524 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002526 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002527 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002528 bool hddDisconInProgress = false;
2529 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302530 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302531 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532
2533 if (!pHddCtx) {
2534 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302535 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002536 }
2537
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302538 /* validate config */
2539 if (!pHddCtx->config) {
2540 hdd_err("config is NULL");
2541 return QDF_STATUS_E_NULL_VALUE;
2542 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543 /* HDD has initiated disconnect, do not send connect result indication
2544 * to kernel as it will be handled by __cfg80211_disconnect.
2545 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302546 if (((eConnectionState_Disconnecting ==
2547 pHddStaCtx->conn_info.connState) ||
2548 (eConnectionState_NotConnected ==
2549 pHddStaCtx->conn_info.connState)) &&
2550 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2551 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002552 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
2553 pHddStaCtx->conn_info.connState,
2554 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 hddDisconInProgress = true;
2556 }
2557
2558 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2559 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002560 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302561 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002562 }
2563 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 hdd_conn_set_connection_state(pAdapter,
2565 eConnectionState_Associated);
2566 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302567
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002568 /* Save the connection info from CSR... */
2569 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2570 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002571
2572 if (hdd_add_beacon_filter(pAdapter) != 0)
2573 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574#ifdef FEATURE_WLAN_WAPI
2575 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2576 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2577 || pRoamInfo->u.pConnectedProfile->AuthType ==
2578 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2579 pAdapter->wapi_info.fIsWapiSta = 1;
2580 } else {
2581 pAdapter->wapi_info.fIsWapiSta = 0;
2582 }
2583#endif /* FEATURE_WLAN_WAPI */
Krunal Soni364e0872017-05-10 21:24:34 -07002584 hdd_debug("bss_descr[%d] devicemode[%d]", !!pRoamInfo->pBssDesc,
2585 pAdapter->device_mode);
2586 if ((QDF_STA_MODE == pAdapter->device_mode) &&
2587 pRoamInfo->pBssDesc) {
2588 ie_len = GET_IE_LEN_IN_BSS(pRoamInfo->pBssDesc->length);
2589 pHddStaCtx->ap_supports_immediate_power_save =
2590 wlan_hdd_is_ap_supports_immediate_power_save(
2591 (uint8_t *) pRoamInfo->pBssDesc->ieFields,
2592 ie_len);
2593 hdd_debug("ap_supports_immediate_power_save flag [%d]",
2594 pHddStaCtx->ap_supports_immediate_power_save);
2595 }
2596
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002597 /* Indicate 'connect' status to user space */
2598 hdd_send_association_event(dev, pRoamInfo);
2599
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002600 if (policy_mgr_is_mcc_in_24G(pHddCtx->hdd_psoc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 if (pHddCtx->miracast_value)
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002602 wlan_hdd_set_mas(pAdapter,
2603 pHddCtx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002604 }
2605
2606 /* Initialize the Linkup event completion variable */
2607 INIT_COMPLETION(pAdapter->linkup_event_var);
2608
2609 /*
2610 * Sometimes Switching ON the Carrier is taking time to activate
2611 * the device properly. Before allowing any packet to go up to
2612 * the application, device activation has to be ensured for
2613 * proper queue mapping by the kernel. we have registered net
2614 * device notifier for device change notification. With this we
2615 * will come to know that the device is getting
2616 * activated properly.
2617 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002618 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002619 /*
2620 * Enable Linkup Event Servicing which allows the net
2621 * device notifier to set the linkup event variable.
2622 */
2623 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002624
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002625 /* Switch on the Carrier to activate the device */
2626 wlan_hdd_netif_queue_control(pAdapter,
2627 WLAN_NETIF_CARRIER_ON,
2628 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002630 /*
2631 * Wait for the Link to up to ensure all the queues
2632 * are set properly by the kernel.
2633 */
2634 rc = wait_for_completion_timeout(
2635 &pAdapter->linkup_event_var,
2636 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2637 );
2638 if (!rc)
2639 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002640
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002641 /*
2642 * Disable Linkup Event Servicing - no more service
2643 * required from the net device notifier call.
2644 */
2645 pAdapter->isLinkUpSvcNeeded = false;
2646 } else {
2647 pHddStaCtx->ft_carrier_on = false;
2648 ft_carrier_on = true;
2649 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002650 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2651 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2652 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002653 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002654
2655 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2656
2657 if (hdd_ipa_is_enabled(pHddCtx))
2658 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002659 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 pRoamInfo->bssid.bytes);
2661
2662#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2663 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2664#endif
2665
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302666 hdd_debug("check if STA chan ok for DNBS");
2667 if (policy_mgr_is_chan_ok_for_dnbs(pHddCtx->hdd_psoc,
2668 pHddStaCtx->conn_info.operationChannel,
2669 &ok)) {
2670 hdd_err("Unable to check DNBS eligibility for chan:%d",
2671 pHddStaCtx->conn_info.operationChannel);
2672 return QDF_STATUS_E_FAILURE;
2673 }
2674
2675 if (!ok) {
2676 hdd_err("Chan:%d not suitable for DNBS",
2677 pHddStaCtx->conn_info.operationChannel);
2678 wlan_hdd_netif_queue_control(pAdapter,
2679 WLAN_NETIF_CARRIER_OFF,
2680 WLAN_CONTROL_PATH);
2681 if (!hddDisconInProgress) {
2682 hdd_err("Disconnecting...");
2683 sme_roam_disconnect(
2684 WLAN_HDD_GET_HAL_CTX(pAdapter),
2685 pAdapter->sessionId,
2686 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2687 }
2688 return QDF_STATUS_E_FAILURE;
2689 }
2690
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002691 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002692 policy_mgr_check_concurrent_intf_and_restart_sap(
2693 pHddCtx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002694
Nirav Shah1da77682016-05-03 20:16:39 +05302695 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2696 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002697 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302698 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2699
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002700 /*
2701 * For reassoc, the station is already registered, all we need
2702 * is to change the state of the STA in TL.
2703 * If authentication is required (WPA/WPA2/DWEP), change TL to
2704 * CONNECTED instead of AUTHENTICATED.
2705 */
2706 if (!pRoamInfo->fReassocReq) {
2707 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708 u8 *pFTAssocRsp = NULL;
2709 unsigned int assocRsplen = 0;
2710 u8 *pFTAssocReq = NULL;
2711 unsigned int assocReqlen = 0;
2712 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2714 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2715
2716 /* add bss_id to cfg80211 data base */
2717 bss =
2718 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2719 pRoamInfo);
2720 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302721 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002722 wlan_hdd_netif_queue_control(pAdapter,
2723 WLAN_NETIF_CARRIER_OFF,
2724 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302725 if (!hddDisconInProgress) {
2726 /*
2727 * Here driver was not able to add bss
2728 * in cfg80211 database this can happen
2729 * if connected channel is not valid,
2730 * i.e reg domain was changed during
2731 * connection. Queue disconnect for the
2732 * session if disconnect is not in
2733 * progress.
2734 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002735 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302736 sme_roam_disconnect(
2737 WLAN_HDD_GET_HAL_CTX(pAdapter),
2738 pAdapter->sessionId,
2739 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2740 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302741 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2744 eCSR_AUTH_TYPE_FT_RSN
2745 || pRoamInfo->u.pConnectedProfile->AuthType ==
2746 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2747
2748 /* Association Response */
2749 pFTAssocRsp =
2750 (u8 *) (pRoamInfo->pbFrames +
2751 pRoamInfo->nBeaconLength +
2752 pRoamInfo->nAssocReqLength);
2753 if (pFTAssocRsp != NULL) {
2754 /*
2755 * pFTAssocRsp needs to point to the IEs
2756 */
2757 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002758 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002759 (unsigned int)pFTAssocRsp[0],
2760 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 assocRsplen =
2762 pRoamInfo->nAssocRspLength -
2763 FT_ASSOC_RSP_IES_OFFSET;
2764 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002765 hdd_debug("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766 assocRsplen = 0;
2767 }
2768
2769 /* Association Request */
2770 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2771 pRoamInfo->nBeaconLength);
2772 if (pFTAssocReq != NULL) {
2773 if (!ft_carrier_on) {
2774 /*
2775 * pFTAssocReq needs to point to
2776 * the IEs
2777 */
2778 pFTAssocReq +=
2779 FT_ASSOC_REQ_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002780 hdd_debug("pFTAssocReq is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002781 (unsigned int)
2782 pFTAssocReq[0],
2783 (unsigned int)
2784 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785 assocReqlen =
2786 pRoamInfo->nAssocReqLength -
2787 FT_ASSOC_REQ_IES_OFFSET;
2788 } else {
2789 /*
2790 * This should contain only the
2791 * FTIEs
2792 */
2793 assocReqlen =
2794 pRoamInfo->nAssocReqLength;
2795 }
2796 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002797 hdd_debug("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002798 assocReqlen = 0;
2799 }
2800
2801 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08002802 if (!hddDisconInProgress &&
2803 pRoamInfo->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302804 struct cfg80211_bss *roam_bss;
2805
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 /*
2807 * After roaming is completed,
2808 * active session count is
2809 * incremented as a part of
2810 * connect indication but
2811 * effectively the active
2812 * session count should still
2813 * be the same and hence upon
2814 * successful reassoc
2815 * decrement the active session
2816 * count here.
2817 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002818 if (!hdd_is_roam_sync_in_progress
2819 (pRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002820 policy_mgr_decr_session_set_pcl(
2821 pHddCtx->hdd_psoc,
2822 pAdapter->device_mode,
2823 pAdapter->sessionId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002824 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002825 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002826 chan =
2827 ieee80211_get_channel
2828 (pAdapter->wdev.wiphy,
2829 (int)pRoamInfo->pBssDesc->
2830 channelId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002831 hdd_debug(
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002832 "assocReqlen %d assocRsplen %d",
2833 assocReqlen,
2834 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002835
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002836 hdd_debug(
Naveen Rawat14298b92015-11-25 16:27:41 -08002837 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302838 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302839 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302840 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002841 pFTAssocReq,
2842 assocReqlen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302843 roam_bss =
2844 hdd_cfg80211_get_bss(
2845 pAdapter->wdev.wiphy,
2846 chan,
2847 pRoamInfo->bssid.bytes,
2848 pRoamInfo->u.
2849 pConnectedProfile->SSID.ssId,
2850 pRoamInfo->u.
2851 pConnectedProfile->SSID.length);
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302852 hdd_send_roamed_ind(
2853 dev,
2854 roam_bss,
2855 pFTAssocReq,
2856 assocReqlen,
2857 pFTAssocRsp,
2858 assocRsplen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302859 wlan_hdd_send_roam_auth_event(
2860 pAdapter,
2861 pRoamInfo->bssid.bytes,
2862 pFTAssocReq,
2863 assocReqlen,
2864 pFTAssocRsp,
2865 assocRsplen,
2866 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 }
2868 if (sme_get_ftptk_state
2869 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2870 pAdapter->sessionId)) {
2871 sme_set_ftptk_state
2872 (WLAN_HDD_GET_HAL_CTX
2873 (pAdapter),
2874 pAdapter->sessionId,
2875 false);
2876 pRoamInfo->fAuthRequired =
2877 false;
2878
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302879 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002880 roam_info.bssid,
2881 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302882 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302883 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002884 roam_info.peerMac,
2885 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302886 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002887 pHddStaCtx->roam_info.roamId =
2888 roamId;
2889 pHddStaCtx->roam_info.
2890 roamStatus = roamStatus;
2891 pHddStaCtx->roam_info.
2892 deferKeyComplete = true;
2893 }
2894 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002895 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002896 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302897 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302898 pRoamInfo->
2899 bssid.bytes,
2900 pRoamInfo,
2901 pFTAssocReq,
2902 assocReqlen,
2903 pFTAssocRsp,
2904 assocRsplen,
2905 WLAN_STATUS_SUCCESS,
2906 GFP_KERNEL,
2907 false,
2908 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002910 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 /*
2912 * wpa supplicant expecting WPA/RSN IE in
2913 * connect result.
2914 */
2915 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2916 (pAdapter),
2917 pAdapter->sessionId,
2918 &reqRsnLength,
2919 reqRsnIe);
2920
2921 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2922 (pAdapter),
2923 pAdapter->sessionId,
2924 &rspRsnLength,
2925 rspRsnIe);
2926 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002927 if (ft_carrier_on)
2928 hdd_send_re_assoc_event(dev,
2929 pAdapter,
2930 pRoamInfo,
2931 reqRsnIe,
2932 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002933 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002934 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002935 MAC_ADDRESS_STR
2936 " result:%d and Status:%d",
2937 MAC_ADDR_ARRAY
2938 (pRoamInfo->bssid.bytes),
2939 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002940
2941 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302942 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302943 pRoamInfo->
2944 bssid.bytes,
2945 pRoamInfo,
2946 reqRsnIe,
2947 reqRsnLength,
2948 rspRsnIe,
2949 rspRsnLength,
2950 WLAN_STATUS_SUCCESS,
2951 GFP_KERNEL,
2952 false,
2953 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 }
2955 }
2956 }
2957 if (!hddDisconInProgress) {
2958 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960 bss);
2961
2962 /*
2963 * Perform any WMM-related association
2964 * processing.
2965 */
2966 hdd_wmm_assoc(pAdapter, pRoamInfo,
2967 eCSR_BSS_TYPE_INFRASTRUCTURE);
2968
2969 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002970 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002971 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002972 qdf_status = hdd_roam_register_sta(pAdapter,
2973 pRoamInfo,
2974 pHddStaCtx->conn_info.staId[0],
2975 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002976 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977 wlan_hdd_netif_queue_control(pAdapter,
2978 WLAN_WAKE_ALL_NETIF_QUEUE,
2979 WLAN_CONTROL_PATH);
2980
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 }
2982 } else {
2983 /*
2984 * wpa supplicant expecting WPA/RSN IE in connect result
2985 * in case of reassociation also need to indicate it to
2986 * supplicant.
2987 */
2988 csr_roam_get_wpa_rsn_req_ie(
2989 WLAN_HDD_GET_HAL_CTX(pAdapter),
2990 pAdapter->sessionId,
2991 &reqRsnLength, reqRsnIe);
2992
2993 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2994 reqRsnIe, reqRsnLength);
2995 /* Reassoc successfully */
2996 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302997 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 hdd_change_peer_state(pAdapter,
2999 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003000 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3002 pRoamInfo->roamSynchInProgress
3003#else
3004 false
3005#endif
3006 );
3007 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003008 hdd_objmgr_set_peer_mlme_auth_state(
3009 pAdapter->hdd_vdev,
3010 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003011 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003012 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003013 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303014 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 hdd_change_peer_state(pAdapter,
3016 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08003017 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003018#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3019 pRoamInfo->roamSynchInProgress
3020#else
3021 false
3022#endif
3023 );
3024 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003025 hdd_objmgr_set_peer_mlme_auth_state(
3026 pAdapter->hdd_vdev,
3027 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003028 }
3029
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303030 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031 /*
3032 * Perform any WMM-related association
3033 * processing
3034 */
3035 hdd_wmm_assoc(pAdapter, pRoamInfo,
3036 eCSR_BSS_TYPE_INFRASTRUCTURE);
3037 }
3038
3039 /* Start the tx queues */
3040#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3041 if (pRoamInfo->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003042 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003043#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003044 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 wlan_hdd_netif_queue_control(pAdapter,
3046 WLAN_WAKE_ALL_NETIF_QUEUE,
3047 WLAN_CONTROL_PATH);
3048 }
3049
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05303050#ifdef FEATURE_WLAN_TDLS
3051 wlan_hdd_tdls_connection_callback(pAdapter);
3052#endif
3053
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303054 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003055 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303056 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003057 }
3058#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303059 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003060 sizeof(pAdapter->hdd_stats.hddPmfStats));
3061#endif
3062 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303063 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003064 hdd_wext_state_t *pWextState =
3065 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3066 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303067 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003068 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303069 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3070 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303072 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003073 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303074 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3075 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05303076
3077 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
3078 (pRoamInfo &&
3079 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
3080 pRoamInfo->statusCode) ||
3081 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
3082 pRoamInfo->statusCode) ||
3083 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
3084 pRoamInfo->statusCode)))) {
3085 wlan_hdd_cfg80211_update_bss_list(pAdapter,
3086 pRoamInfo ?
3087 pRoamInfo->bssid.bytes :
3088 pWextState->req_bssId.bytes);
3089 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
3090 pRoamInfo ?
3091 pRoamInfo->bssid.bytes :
3092 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303093 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303094 }
3095
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003096 /*
3097 * CR465478: Only send up a connection failure result when CSR
3098 * has completed operation - with a ASSOCIATION_FAILURE status.
3099 */
3100 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3101 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303102 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003103 hdd_err("send connect failure to nl80211: for bssid "
3104 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003105 " result: %d and Status: %d reasoncode: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003106 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3107 roamResult, roamStatus,
3108 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303109 pHddStaCtx->conn_info.assoc_status_code =
3110 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003111 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003112 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003114 " result: %d and status: %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3116 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003117 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003118 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303119 wlan_deregister_txrx_packetdump();
3120
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003121 /* inform association failure event to nl80211 */
3122 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3123 roamResult) {
3124 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303125 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003126 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303127 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303129 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303130 connect_timeout,
3131 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303133 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303135 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303137 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303138 connect_timeout,
3139 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003140 } else {
Wu Gao77d28352016-11-23 17:50:56 +08003141 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303142 hdd_connect_result(dev,
3143 pRoamInfo->bssid.bytes,
3144 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08003145 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05303146 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303148 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303149 connect_timeout,
3150 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003151 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303152 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303154 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003155 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303156 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303157 connect_timeout,
3158 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003159 }
Abhishek Singhac2be142015-12-03 16:16:25 +05303160 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003161 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3162 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05303163 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003164 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05303165 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003166 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303167 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303168 connect_timeout,
3169 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 }
3171
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 /*
3173 * Set connection state to eConnectionState_NotConnected only
3174 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003175 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003177 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3178 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003179 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003180 hdd_conn_set_connection_state(pAdapter,
3181 eConnectionState_NotConnected);
3182 }
3183 hdd_wmm_init(pAdapter);
3184
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003185 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003186 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303187 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 WLAN_CONTROL_PATH);
3189 }
3190
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303191 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192}
3193
3194/**
3195 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3196 * @pAdapter: pointer to adapter
3197 * @pRoamInfo: pointer to roam info
3198 * @roamId: roam id
3199 * @roamStatus: roam status
3200 * @roamResult: roam result
3201 *
3202 * Here we update the status of the Ibss when we receive information that we
3203 * have started/joined an ibss session.
3204 *
3205 * Return: none
3206 */
3207static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3208 tCsrRoamInfo *pRoamInfo,
3209 uint32_t roamId,
3210 eRoamCmdStatus roamStatus,
3211 eCsrRoamResult roamResult)
3212{
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003213 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3214
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003215 hdd_debug("%s: id %d, status %d, result %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003216 pAdapter->dev->name, roamId,
3217 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218
3219 switch (roamResult) {
3220 /* both IBSS Started and IBSS Join should come in here. */
3221 case eCSR_ROAM_RESULT_IBSS_STARTED:
3222 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3223 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3224 {
3225 hdd_context_t *pHddCtx =
3226 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303227 hdd_station_ctx_t *hdd_sta_ctx =
3228 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303229 struct qdf_mac_addr broadcastMacAddr =
3230 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003231
3232 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303233 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 return;
3235 }
3236
3237 /* When IBSS Started comes from CSR, we need to move
3238 * connection state to IBSS Disconnected (meaning no peers
3239 * are in the IBSS).
3240 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 hdd_conn_set_connection_state(pAdapter,
3242 eConnectionState_IbssDisconnected);
3243 /* notify wmm */
3244 hdd_wmm_connect(pAdapter, pRoamInfo,
3245 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303246
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003247 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303248
3249 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003250 pAdapter;
3251 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303252 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003253 &broadcastMacAddr,
3254 pRoamInfo->pBssDesc);
3255
3256 if (pRoamInfo->pBssDesc) {
3257 struct cfg80211_bss *bss;
3258#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3259 struct ieee80211_channel *chan;
3260 int chan_no;
3261 unsigned int freq;
3262#endif
3263 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003264 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3265 pAdapter->dev->name,
3266 MAC_ADDR_ARRAY(
3267 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268
3269 /* we must first give cfg80211 the BSS information */
3270 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3271 pRoamInfo);
3272 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003273 hdd_err("%s: unable to create IBSS entry",
3274 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 return;
3276 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003277 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 wlan_hdd_netif_queue_control(pAdapter,
3279 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3280 WLAN_CONTROL_PATH);
3281
3282#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3283 chan_no = pRoamInfo->pBssDesc->channelId;
3284
3285 if (chan_no <= 14)
3286 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003287 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 else
3289 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003290 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003291
3292 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3293
3294 if (chan)
3295 cfg80211_ibss_joined(pAdapter->dev,
3296 bss->bssid, chan,
3297 GFP_KERNEL);
3298 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003299 hdd_warn("%s: chanId: %d, can't find channel",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003300 pAdapter->dev->name,
3301 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003302#else
3303 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3304 GFP_KERNEL);
3305#endif
3306 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 bss);
3309 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003310 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003311 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
3312 pAdapter->device_mode, pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003313 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3314 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003315 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
3316 pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003317 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003318 break;
3319 }
3320
3321 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3322 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003323 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324 break;
3325 }
3326
3327 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003328 hdd_err("%s: unexpected result %d",
3329 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 break;
3331 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332}
3333
3334/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003335 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3336 * @sta_ctx: pointer to hdd station context
3337 * @sta_id: station ID
3338 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 *
3340 * This information is passed to iwconfig later. The peer that joined
3341 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003342
3343 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003344 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003345bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3346 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003347{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003348 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003350 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303351 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003352 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003353 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003354 sta_ctx->conn_info.staId[idx] = sta_id;
3355 qdf_copy_macaddr(
3356 &sta_ctx->conn_info.peerMacAddress[idx],
3357 peer_mac_addr);
3358 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359 }
3360 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003361 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362}
3363
3364/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003365 * hdd_delete_peer() - removes peer from hdd station context peer table
3366 * @sta_ctx: pointer to hdd station context
3367 * @sta_id: station ID
3368 *
3369 * Return: None
3370 */
3371void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3372{
3373 int i;
3374
3375 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3376 if (sta_id == sta_ctx->conn_info.staId[i]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303377 sta_ctx->conn_info.staId[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003378 return;
3379 }
3380 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003381}
3382
3383/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3385 * @pAdapter: pointer to adapter
3386 * @staId: station id
3387 *
3388 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003389 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390 * false otherwise.
3391 */
3392static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3393{
3394 bool fSuccess = false;
3395 int idx = 0;
3396 uint8_t valid_idx = 0;
3397 uint8_t del_idx = 0;
3398 uint8_t empty_slots = 0;
3399 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3400
Naveen Rawatc45d1622016-07-05 12:20:09 -07003401 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 if (staId == pHddStaCtx->conn_info.staId[idx]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303403 pHddStaCtx->conn_info.staId[idx] =
3404 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003405
Anurag Chouhanc5548422016-02-24 18:33:27 +05303406 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 peerMacAddress[idx]);
3408
3409 fSuccess = true;
3410
3411 /*
3412 * Note the deleted Index, if its 0 we need special
3413 * handling.
3414 */
3415 del_idx = idx;
3416
3417 empty_slots++;
3418 } else {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003419 if (pHddStaCtx->conn_info.staId[idx] !=
3420 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421 valid_idx = idx;
3422 } else {
3423 /* Found an empty slot */
3424 empty_slots++;
3425 }
3426 }
3427 }
3428
Naveen Rawatc45d1622016-07-05 12:20:09 -07003429 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003430 /* Last peer departed, set the IBSS state appropriately */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003431 hdd_conn_set_connection_state(pAdapter,
3432 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003433 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434 }
3435 /* Find next active staId, to have a valid sta trigger for TL. */
3436 if (fSuccess == true) {
3437 if (del_idx == 0) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003438 if (pHddStaCtx->conn_info.staId[valid_idx] !=
3439 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003440 pHddStaCtx->conn_info.staId[0] =
3441 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303442 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443 peerMacAddress[0],
3444 &pHddStaCtx->conn_info.
3445 peerMacAddress[valid_idx]);
3446
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303447 pHddStaCtx->conn_info.staId[valid_idx] =
3448 HDD_WLAN_INVALID_STA_ID;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303449 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003450 peerMacAddress[valid_idx]);
3451 }
3452 }
3453 }
3454 return fSuccess;
3455}
3456
3457/**
3458 * roam_ibss_connect_handler() - IBSS connection handler
3459 * @pAdapter: pointer to adapter
3460 * @pRoamInfo: pointer to roam info
3461 *
3462 * We update the status of the IBSS to connected in this function.
3463 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303464 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003465 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303466static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 tCsrRoamInfo *pRoamInfo)
3468{
3469 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 /*
3471 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3472 * a partner stations).
3473 */
3474 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3475
3476 /* Save the connection info from CSR... */
3477 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3478
3479 /* Send the bssid address to the wext. */
3480 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3481 /* add bss_id to cfg80211 data base */
3482 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3483 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003484 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487 }
3488 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003489 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003490 bss);
3491
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303492 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493}
3494
3495/**
3496 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3497 * @pAdapter: pointer to adapter
3498 * @pRoamInfo: pointer to roam info
3499 * @roamId: roam id
3500 * @roamStatus: roam status
3501 * @roamResult: roam result
3502 *
3503 * This function indicates the Mic failure to the supplicant
3504 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303505 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303507static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3509 tCsrRoamInfo *pRoamInfo,
3510 uint32_t roamId,
3511 eRoamCmdStatus roamStatus,
3512 eCsrRoamResult roamResult)
3513{
3514 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3515
3516 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3517 TKIP_COUNTER_MEASURE_STOPED ==
3518 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3519 struct iw_michaelmicfailure msg;
3520 union iwreq_data wreq;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003521
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 memset(&msg, '\0', sizeof(msg));
3523 msg.src_addr.sa_family = ARPHRD_ETHER;
3524 memcpy(msg.src_addr.sa_data,
3525 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3526 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003527 hdd_debug("MIC MAC " MAC_ADDRESS_STR,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003528 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003529
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003530 if (pRoamInfo->u.pMICFailureInfo->multicast == true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003531 msg.flags = IW_MICFAILURE_GROUP;
3532 else
3533 msg.flags = IW_MICFAILURE_PAIRWISE;
3534 memset(&wreq, 0, sizeof(wreq));
3535 wreq.data.length = sizeof(msg);
3536 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3537 (char *)&msg);
3538 /* inform mic failure to nl80211 */
3539 cfg80211_michael_mic_failure(pAdapter->dev,
3540 pRoamInfo->u.pMICFailureInfo->
3541 taMacAddr,
3542 ((pRoamInfo->u.pMICFailureInfo->
3543 multicast ==
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003544 true) ?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 NL80211_KEYTYPE_GROUP :
3546 NL80211_KEYTYPE_PAIRWISE),
3547 pRoamInfo->u.pMICFailureInfo->
3548 keyId,
3549 pRoamInfo->u.pMICFailureInfo->TSC,
3550 GFP_KERNEL);
3551
3552 }
3553
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303554 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003555}
3556
3557/**
3558 * roam_roam_connect_status_update_handler() - IBSS connect status update
3559 * @pAdapter: pointer to adapter
3560 * @pRoamInfo: pointer to roam info
3561 * @roamId: roam id
3562 * @roamStatus: roam status
3563 * @roamResult: roam result
3564 *
3565 * The Ibss connection status is updated regularly here in this function.
3566 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303567 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303569static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3571 tCsrRoamInfo *pRoamInfo,
3572 uint32_t roamId,
3573 eRoamCmdStatus roamStatus,
3574 eCsrRoamResult roamResult)
3575{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003577 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303578
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 switch (roamResult) {
3580 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3581 {
3582 hdd_station_ctx_t *pHddStaCtx =
3583 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003584 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003585 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003587 hdd_info("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303588 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3589 MAC_ADDRESS_STR " and stationID= %d",
3590 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3591 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3592 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003594 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003595 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3596 pRoamInfo->staId,
3597 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003598 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003599 break;
3600 }
3601
3602 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3603
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003604 if (hdd_is_key_install_required_for_ibss(encr_type))
3605 pRoamInfo->fAuthRequired = true;
3606
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303608 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 pRoamInfo,
3610 pRoamInfo->staId,
3611 &pRoamInfo->peerMac,
3612 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303613 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003614 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303615 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 }
3617 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003618 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3619 if (stainfo == NULL) {
3620 hdd_err("memory allocation for station_info failed");
3621 return QDF_STATUS_E_NOMEM;
3622 }
3623 stainfo->filled = 0;
3624 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003625
3626 cfg80211_new_sta(pAdapter->dev,
3627 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003628 stainfo, GFP_KERNEL);
3629 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003631 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003632 pHddStaCtx->ibss_enc_key.keyDirection =
3633 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303634 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003635 &pRoamInfo->peerMac);
3636
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003637 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003638 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303640 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003641 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3642 (pAdapter),
3643 pAdapter->sessionId,
3644 &pHddStaCtx->ibss_enc_key,
3645 &roamId);
3646
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303647 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003648 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003649 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 }
3652 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003653 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003654 wlan_hdd_netif_queue_control(pAdapter,
3655 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3656 WLAN_CONTROL_PATH);
3657 break;
3658 }
3659
3660 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3661 {
3662
3663 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3664
3665 break;
3666 }
3667 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3668 {
3669 hdd_station_ctx_t *pHddStaCtx =
3670 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3671
3672 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003673 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003675 hdd_info("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303676 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3677 MAC_ADDRESS_STR " and stationID= %d",
3678 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3679 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3680 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681
3682 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3683
3684 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3685 pHddStaCtx->ibss_sta_generation++;
3686
3687 cfg80211_del_sta(pAdapter->dev,
3688 (const u8 *)&pRoamInfo->peerMac.bytes,
3689 GFP_KERNEL);
3690 break;
3691 }
3692 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3693 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003694 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003695 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003696 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003697 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303698 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 hdd_conn_set_connection_state(pAdapter,
3701 eConnectionState_NotConnected);
3702
3703 /* Send the bssid address to the wext. */
3704 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3705 break;
3706 }
3707 default:
3708 break;
3709
3710 }
3711
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303712 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003713}
3714
3715#ifdef FEATURE_WLAN_TDLS
3716/**
3717 * hdd_roam_register_tdlssta() - register new TDLS station
3718 * @pAdapter: pointer to adapter
3719 * @peerMac: pointer to peer MAC address
3720 * @staId: station identifier
3721 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303722 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003723 *
3724 * Construct the staDesc and register with TL the new STA.
3725 * This is called as part of ADD_STA in the TDLS setup.
3726 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303727 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003728 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303729QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303731 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003732{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303733 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003734 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003735 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003736 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3737 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738
3739 /*
3740 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3741 * be peer MAC, here we are working on direct Link
3742 */
3743 staDesc.sta_id = staId;
3744
3745 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303746 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003747
Dhanashri Atre50141c52016-04-07 13:15:29 -07003748 /* Register the vdev transmit and receive functions */
3749 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3750 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003751 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003752 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3753 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003754 pAdapter, &txrx_ops);
3755 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003756
3757 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003758 qdf_status = cdp_peer_register(soc,
3759 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303760 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003761 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303762 qdf_status, qdf_status);
3763 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764 }
3765
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303766 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003767}
3768
3769/**
3770 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3771 * @pAdapter: pointer to adapter
3772 * @staId: station identifier
3773 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303774 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303776QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303778 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003779 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003780 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3781 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303782 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003783 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003784 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003785 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303786 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003787}
3788
3789/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003790 * hdd_tdls_connection_tracker_update() - update connection tracker state
3791 * @adapter: pointer to adapter
3792 * @roam_info: pointer to roam info
3793 * @hdd_tdls_ctx: tdls context
3794 *
3795 * Return: QDF_STATUS enumeration
3796 */
3797static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3798 tCsrRoamInfo *roam_info,
3799 tdlsCtx_t *hdd_tdls_ctx)
3800{
3801 hddTdlsPeer_t *curr_peer;
3802 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3803
3804 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303805 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003806
3807 if (!curr_peer) {
3808 hdd_err("curr_peer is null");
3809 return QDF_STATUS_E_FAILURE;
3810 }
3811
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003812 if (eTDLS_LINK_CONNECTED ==
3813 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003814 hdd_debug("Received CONNECTION_TRACKER_NOTIFICATION "
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003815 MAC_ADDRESS_STR
3816 " staId: %d, reason: %d",
3817 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3818 roam_info->staId,
3819 roam_info->reasonCode);
3820
3821 if (roam_info->reasonCode ==
3822 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3823 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003824 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3825 roam_info->reasonCode ==
3826 eWMI_TDLS_SCAN_STARTED_EVENT)
3827 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003828 else if (roam_info->reasonCode ==
3829 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3830 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003831 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3832 roam_info->reasonCode ==
3833 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3834 hdd_ctx->enable_tdls_connection_tracker = true;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003835 hdd_debug("hdd_ctx->enable_tdls_connection_tracker %d",
Nitesh Shahc549dd52017-02-23 16:45:44 +05303836 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003837 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003838 hdd_debug("TDLS not connected, ignore notification, reason: %d",
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003839 roam_info->reasonCode);
3840 }
3841
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003842 return QDF_STATUS_SUCCESS;
3843}
3844
3845
3846
3847
3848/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3850 * @pAdapter: pointer to adapter
3851 * @pRoamInfo: pointer to roam info
3852 * @roamId: roam id
3853 * @roamStatus: roam status
3854 * @roamResult: roam result
3855 *
3856 * HDD interface between SME and TL to ensure TDLS client registration with
3857 * TL in case of new TDLS client is added and deregistration at the time
3858 * TDLS client is deleted.
3859 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303860 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003861 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303862static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3864 tCsrRoamInfo *pRoamInfo,
3865 uint32_t roamId,
3866 eRoamCmdStatus roamStatus,
3867 eCsrRoamResult roamResult)
3868{
3869 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303870 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303872 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003873 uint8_t staIdx;
3874 hddTdlsPeer_t *curr_peer;
3875 uint32_t reason;
3876
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003877 hdd_debug("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 roamResult ==
3879 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3880 ==
3881 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3882 roamResult ==
3883 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3884 : roamResult ==
3885 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3886 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3887 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3888 roamResult ==
3889 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3890 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3891 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3892 : roamResult ==
3893 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3894 : roamResult ==
3895 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3896 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3897 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003899 switch (roamResult) {
3900 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3901 {
3902 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003903 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003904 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303905 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003906 } else {
3907 /*
3908 * Check if there is available index for this new TDLS
3909 * STA.
3910 */
3911 for (staIdx = 0;
3912 staIdx < pHddCtx->max_num_tdls_sta;
3913 staIdx++) {
3914 if (0 ==
3915 pHddCtx->tdlsConnInfo[staIdx].
3916 staId) {
3917 pHddCtx->tdlsConnInfo[staIdx].
3918 sessionId =
3919 pRoamInfo->sessionId;
3920 pHddCtx->tdlsConnInfo[staIdx].
3921 staId = pRoamInfo->staId;
3922
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003923 hdd_debug("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003924 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003925 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 staIdx,
3927 pHddCtx->
3928 tdlsConnInfo[staIdx].
3929 staId,
3930 MAC_ADDR_ARRAY
3931 (pRoamInfo->peerMac.bytes));
3932
Anurag Chouhanc5548422016-02-24 18:33:27 +05303933 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003934 tdlsConnInfo
3935 [staIdx].
3936 peerMac,
3937 &pRoamInfo->
3938 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303939 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003940 break;
3941 }
3942 }
3943 if (staIdx < pHddCtx->max_num_tdls_sta) {
3944 if (-1 ==
3945 wlan_hdd_tdls_set_sta_id(pAdapter,
3946 pRoamInfo->
3947 peerMac.bytes,
3948 pRoamInfo->
3949 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003950 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303951 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003952 }
3953
3954 (WLAN_HDD_GET_CTX(pAdapter))->
3955 sta_to_adapter[pRoamInfo->staId] =
3956 pAdapter;
3957 /*
3958 * store the ucast signature,
3959 * if required for further reference.
3960 */
3961
3962 wlan_hdd_tdls_set_signature(pAdapter,
3963 pRoamInfo->
3964 peerMac.bytes,
3965 pRoamInfo->
3966 ucastSig);
3967 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303968 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003969 hdd_debug("no available slot in conn_info. staId: %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970 pRoamInfo->staId);
3971 }
3972 pAdapter->tdlsAddStaStatus = status;
3973 }
3974 complete(&pAdapter->tdls_add_station_comp);
3975 break;
3976 }
3977 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3978 {
3979 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003980 hdd_err("Add Sta failed. status code: %d",
Varun Reddy Yeturued1215e2017-07-07 16:40:28 -07003981 pRoamInfo->statusCode);
3982 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3983 } else {
3984 pAdapter->tdlsAddStaStatus = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 complete(&pAdapter->tdls_add_station_comp);
3987 break;
3988 }
3989 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3990 {
3991 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003992 hdd_err("Link Establish Request failed. status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 pRoamInfo->statusCode);
3994 }
3995 complete(&pAdapter->tdls_link_establish_req_comp);
3996 break;
3997 }
3998 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3999 {
4000 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4001 staIdx++) {
4002 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4003 pRoamInfo->sessionId)
4004 && pRoamInfo->staId ==
4005 pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004006 hdd_debug("HDD: del STA IDX = %x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004007 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05304008 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004009 curr_peer =
4010 wlan_hdd_tdls_find_peer(pAdapter,
4011 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05304012 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304013 if (NULL != curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004014 hdd_debug("Current status for peer " MAC_ADDRESS_STR " is %d",
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304015 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4016 curr_peer->link_status);
4017 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05304018 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 hdd_roam_deregister_tdlssta
4020 (pAdapter,
4021 pRoamInfo->staId);
4022 wlan_hdd_tdls_decrement_peer_count
4023 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304024 } else if (eTDLS_LINK_CONNECTING ==
4025 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05304026 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304027 hdd_roam_deregister_tdlssta
4028 (pAdapter,
4029 pRoamInfo->staId);
Nitesh Shah0bf768f2017-03-31 15:01:37 +05304030 } else
4031 mutex_unlock(&pHddCtx->tdls_lock);
Nitesh Shah3dea6722017-02-01 14:35:57 +05304032 } else
4033 mutex_unlock(&pHddCtx->tdls_lock);
4034
Nitesh Shah99dd9552017-03-20 19:27:47 +05304035 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004036 wlan_hdd_tdls_reset_peer(pAdapter,
4037 pRoamInfo->
4038 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304039 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040
4041 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4042 pHddCtx->tdlsConnInfo[staIdx].
4043 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304044 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004045 tdlsConnInfo[staIdx].
4046 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304047 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304048 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 break;
4050 }
4051 }
4052 complete(&pAdapter->tdls_del_station_comp);
4053 }
4054 break;
4055 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
4056 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004057 hdd_debug("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004058 pRoamInfo->reasonCode);
4059
Nitesh Shahf1f38992017-01-31 16:40:16 +05304060 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004061 curr_peer =
4062 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304063 pRoamInfo->peerMac.bytes);
Ganesh Kondabattini9c8dc462017-04-19 10:52:54 +05304064
4065 if (!curr_peer) {
4066 mutex_unlock(&pHddCtx->tdls_lock);
4067 hdd_debug("peer doesn't exists");
4068 status = QDF_STATUS_SUCCESS;
4069 break;
4070 }
4071
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304073 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304074 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
4075 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304076 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304077 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 break;
4079 }
4080 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
4081 {
4082 /* 0 staIdx is assigned to AP we dont want to touch that */
4083 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4084 staIdx++) {
4085 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4086 pRoamInfo->sessionId)
4087 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004088 hdd_debug("hdd_tdlsStatusUpdate: staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004089 MAC_ADDRESS_STR,
4090 pHddCtx->tdlsConnInfo[staIdx].
4091 staId,
4092 MAC_ADDR_ARRAY(pHddCtx->
4093 tdlsConnInfo
4094 [staIdx].
4095 peerMac.
4096 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05304097 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 wlan_hdd_tdls_reset_peer(pAdapter,
4099 pHddCtx->
4100 tdlsConnInfo
4101 [staIdx].
4102 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304103 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 hdd_roam_deregister_tdlssta(pAdapter,
4105 pHddCtx->
4106 tdlsConnInfo
4107 [staIdx].
4108 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304109 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 sizeof
4111 (smeTdlsPeerStateParams));
4112 smeTdlsPeerStateParams.vdevId =
4113 pHddCtx->tdlsConnInfo[staIdx].
4114 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304115 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 peerMacAddr,
4117 &pHddCtx->
4118 tdlsConnInfo[staIdx].
4119 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304120 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 smeTdlsPeerStateParams.peerState =
4122 eSME_TDLS_PEER_STATE_TEARDOWN;
4123
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004124 hdd_debug("calling sme_update_tdls_peer_state for staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004125 MAC_ADDRESS_STR,
4126 pHddCtx->tdlsConnInfo[staIdx].
4127 staId,
4128 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 tdlsConnInfo
4130 [staIdx].
4131 peerMac.
4132 bytes));
4133 status =
4134 sme_update_tdls_peer_state(
4135 pHddCtx->hHal,
4136 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304137 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004138 hdd_err("sme_update_tdls_peer_state failed for "
4139 MAC_ADDRESS_STR,
4140 MAC_ADDR_ARRAY
4141 (pHddCtx->
4142 tdlsConnInfo[staIdx].
4143 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 }
4145 wlan_hdd_tdls_decrement_peer_count
4146 (pAdapter);
4147
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304148 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004149 tdlsConnInfo[staIdx].
4150 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304151 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004152 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4153 pHddCtx->tdlsConnInfo[staIdx].
4154 sessionId = 255;
4155
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304156 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004157 }
4158 }
4159 break;
4160 }
4161 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
4162 {
4163 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07004164 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
4165 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304166 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 break;
4168 }
4169
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004170 if (pHddCtx->tdls_nss_switch_in_progress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004171 hdd_debug("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004172 status = QDF_STATUS_SUCCESS;
4173 break;
4174 }
4175
Nitesh Shah8e866642017-01-31 15:43:31 +05304176 mutex_lock(&pHddCtx->tdls_lock);
4177 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4178 if (!pHddTdlsCtx) {
4179 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004180 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shah8e866642017-01-31 15:43:31 +05304181 roamResult);
4182 status = QDF_STATUS_E_FAILURE;
4183 break;
4184 }
4185
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 curr_peer =
4187 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05304188 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004189 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004190 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304191 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 } else {
4193 if (eTDLS_LINK_CONNECTED ==
4194 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004195 hdd_debug("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004196 } else {
4197 /*
4198 * If external control is enabled then initiate
4199 * TDLS only if forced peer is set otherwise
4200 * ignore should Discover trigger from fw.
4201 */
4202 if (pHddCtx->config->
4203 fTDLSExternalControl
4204 && (false ==
4205 curr_peer->isForcedPeer)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004206 hdd_debug("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304207 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004209 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004210 hdd_debug("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Jeff Johnson68755312017-02-10 11:46:55 -08004211 pHddCtx->config->
4212 fTDLSExternalControl,
4213 curr_peer->isForcedPeer,
4214 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304215 pHddTdlsCtx->curr_candidate = curr_peer;
4216 wlan_hdd_tdls_implicit_send_discovery_request(
4217 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304219 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304221 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 break;
4223 }
4224
4225 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4226 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304227 mutex_lock(&pHddCtx->tdls_lock);
4228 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4229 if (!pHddTdlsCtx) {
4230 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004231 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304232 roamResult);
4233 status = QDF_STATUS_E_FAILURE;
4234 break;
4235 }
4236
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004237 curr_peer =
4238 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304239 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004240 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004241 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304242 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004243 } else {
4244 if (eTDLS_LINK_CONNECTED ==
4245 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004246 hdd_debug("Received SHOULD_TEARDOWN for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004247 MAC_ADDRESS_STR
4248 " staId: %d, reason: %d",
4249 MAC_ADDR_ARRAY(pRoamInfo->
4250 peerMac.bytes),
4251 pRoamInfo->staId,
4252 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253
4254 if (pRoamInfo->reasonCode ==
4255 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4256 pRoamInfo->reasonCode ==
4257 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4258 pRoamInfo->reasonCode ==
4259 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4260 pRoamInfo->reasonCode ==
4261 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4262 reason =
4263 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4264 } else
4265 reason =
4266 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4267
4268 wlan_hdd_tdls_indicate_teardown
4269 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304270 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304271 hdd_send_wlan_tdls_teardown_event(
4272 eTDLS_TEARDOWN_BSS_DISCONNECT,
4273 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004274 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004275 hdd_debug("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004276 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304278 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304280 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004281 break;
4282 }
4283
4284 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4285 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304286 mutex_lock(&pHddCtx->tdls_lock);
4287 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4288 if (!pHddTdlsCtx) {
4289 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004290 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304291 roamResult);
4292 status = QDF_STATUS_E_FAILURE;
4293 break;
4294 }
4295
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004296 curr_peer =
4297 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304298 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004299 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004300 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304301 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302 } else {
4303 if (eTDLS_LINK_CONNECTED ==
4304 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004305 hdd_debug("Received SHOULD_PEER_DISCONNECTED for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004306 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004307 " staId: %d reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004308 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4309 pRoamInfo->staId,
4310 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004311
4312 if (pRoamInfo->reasonCode ==
4313 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4314 pRoamInfo->reasonCode ==
4315 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4316 pRoamInfo->reasonCode ==
4317 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4318 pRoamInfo->reasonCode ==
4319 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4320 reason =
4321 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4322 } else
4323 reason =
4324 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4325
4326 wlan_hdd_tdls_indicate_teardown
4327 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304328 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304329 hdd_send_wlan_tdls_teardown_event(
4330 eTDLS_TEARDOWN_BSS_DISCONNECT,
4331 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004333 hdd_debug("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004334 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004335 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304336 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004337 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304338 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 break;
4340 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004341
4342 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304343 mutex_lock(&pHddCtx->tdls_lock);
4344 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4345 if (!pHddTdlsCtx) {
4346 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004347 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304348 roamResult);
4349 status = QDF_STATUS_E_FAILURE;
4350 break;
4351 }
4352
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004353 status = hdd_tdls_connection_tracker_update(pAdapter,
4354 pRoamInfo,
4355 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304356 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004357 break;
4358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004359 default:
4360 {
4361 break;
4362 }
4363 }
4364
4365 return status;
4366}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004367#else
4368
Nitesh Shah99dd9552017-03-20 19:27:47 +05304369inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004370 uint8_t staId)
4371{
4372 return QDF_STATUS_SUCCESS;
4373}
4374
4375static inline QDF_STATUS
4376hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4377 tCsrRoamInfo *pRoamInfo,
4378 uint32_t roamId,
4379 eRoamCmdStatus roamStatus,
4380 eCsrRoamResult roamResult)
4381{
4382 return QDF_STATUS_SUCCESS;
4383}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384#endif
4385
4386#ifdef WLAN_FEATURE_11W
4387/**
4388 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4389 * @pAdapter: pointer to the adapter
4390 * @nFrameLength: Length of the unprotected frame being passed
4391 * @pbFrames: Pointer to the frame buffer
4392 * @frameType: 802.11 frame type
4393 *
4394 * This function forwards the unprotected management frame to the supplicant.
4395 *
4396 * Return: nothing
4397 */
4398static void
4399hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4400 uint8_t *pbFrames, uint8_t frameType)
4401{
4402 uint8_t type = 0;
4403 uint8_t subType = 0;
4404
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004405 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004406 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004407
4408 /* Sanity Checks */
4409 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004410 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 return;
4412 }
4413
4414 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004415 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004416 return;
4417 }
4418
4419 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004420 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004421 return;
4422 }
4423
4424 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004425 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004426 return;
4427 }
4428
4429 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004430 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004431 return;
4432 }
4433
4434 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4435 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4436
4437 /* Get pAdapter from Destination mac address of the frame */
4438 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4439#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4440 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4441 nFrameLength);
4442#else
4443 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4444 nFrameLength);
4445#endif
4446 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4447 } else if (type == SIR_MAC_MGMT_FRAME &&
4448 subType == SIR_MAC_MGMT_DEAUTH) {
4449#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4450 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4451 nFrameLength);
4452#else
4453 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4454 nFrameLength);
4455#endif
4456 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4457 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004458 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004459 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004460 return;
4461 }
4462}
4463#endif
4464
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004465#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004466/**
4467 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4468 * @pAdapter: pointer to adapter
4469 * @tid: traffic identifier
4470 * @state: state
4471 * @measInterval: measurement interval
4472 *
4473 * This function sends traffic stream metrics IE information to
4474 * the supplicant via wireless event.
4475 *
4476 * Return: none
4477 */
4478static void
4479hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4480 uint8_t state, uint16_t measInterval)
4481{
4482 union iwreq_data wrqu;
4483 char buf[IW_CUSTOM_MAX + 1];
4484 int nBytes = 0;
4485
4486 if (NULL == pAdapter)
4487 return;
4488
4489 /* create the event */
4490 memset(&wrqu, '\0', sizeof(wrqu));
4491 memset(buf, '\0', sizeof(buf));
4492
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004493 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004494 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004495
4496 nBytes =
4497 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4498 measInterval);
4499
4500 wrqu.data.pointer = buf;
4501 wrqu.data.length = nBytes;
4502 /* send the event */
4503 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4504}
4505
4506/**
4507 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4508 * @pAdapter: pointer to adapter
4509 * @pRoamInfo: pointer to roam info
4510 *
4511 * This function sends cckm preauth indication to the supplicant
4512 * via wireless custom event.
4513 *
4514 * Return: none
4515 */
4516static void
4517hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4518{
4519 union iwreq_data wrqu;
4520 char buf[IW_CUSTOM_MAX + 1];
4521 char *pos = buf;
4522 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4523
4524 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4525 return;
4526
4527 /* create the event */
4528 memset(&wrqu, '\0', sizeof(wrqu));
4529 memset(buf, '\0', sizeof(buf));
4530
4531 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004532 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004533 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4534 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535
4536 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4537 pos += nBytes;
4538 freeBytes -= nBytes;
4539
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304540 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304541 pos += QDF_MAC_ADDR_SIZE;
4542 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004543
4544 nBytes = snprintf(pos, freeBytes, " %u:%u",
4545 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4546 freeBytes -= nBytes;
4547
4548 wrqu.data.pointer = buf;
4549 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4550
4551 /* send the event */
4552 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4553}
4554
4555/**
4556 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4557 * @pAdapter: pointer to adapter
4558 * @pRoamInfo: pointer to roam info
4559 *
4560 * Return: none
4561 */
4562static void
4563hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4564 tCsrRoamInfo *pRoamInfo)
4565{
4566 union iwreq_data wrqu;
4567 char buf[IW_CUSTOM_MAX + 1];
4568 int nBytes = 0;
4569
4570 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4571 return;
4572
4573 /* create the event */
4574 memset(&wrqu, '\0', sizeof(wrqu));
4575 memset(buf, '\0', sizeof(buf));
4576
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004577 hdd_debug("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004578
4579 nBytes =
4580 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4581 pRoamInfo->tsmRoamDelay);
4582
4583 wrqu.data.pointer = buf;
4584 wrqu.data.length = nBytes;
4585
4586 /* send the event */
4587 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4588}
4589
4590/**
4591 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4592 * @pAdapter: pointer to adapter
4593 * @measurementToken: measurement token
4594 * @flag: flag
4595 * @numBss: number of bss
4596 *
4597 * If the measurement is none and no scan results found,
4598 * indicate the supplicant about measurement done.
4599 *
4600 * Return: none
4601 */
4602void
4603hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4604 const uint16_t measurementToken,
4605 const bool flag, const uint8_t numBss)
4606{
4607 union iwreq_data wrqu;
4608 char buf[IW_CUSTOM_MAX];
4609 char *pos = buf;
4610 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4611
4612 memset(&wrqu, '\0', sizeof(wrqu));
4613 memset(buf, '\0', sizeof(buf));
4614
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004615 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004616 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617
4618 nBytes =
4619 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4620 flag, numBss);
4621
4622 wrqu.data.pointer = buf;
4623 wrqu.data.length = nBytes;
4624 /* send the event */
4625 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4626}
4627
4628/**
4629 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4630 * @pAdapter: pointer to adapter
4631 * @pRoamInfo: pointer to roam info
4632 *
4633 * If the measurement is none and no scan results found,
4634 * indicate the supplicant about measurement done.
4635 *
4636 * Return: none
4637 */
4638static void
4639hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4640 const tCsrRoamInfo *pRoamInfo)
4641{
4642 union iwreq_data wrqu;
4643 char buf[IW_CUSTOM_MAX];
4644 char *pos = buf;
4645 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4646 uint8_t i = 0, len = 0;
4647 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4648 uint8_t lastSent = 0, sendBss = 0;
4649 int bcnRepFieldSize =
4650 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4651 bcnReportFields);
4652 uint8_t ieLenByte = 1;
4653 /*
4654 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4655 */
4656#define ESEBCNREPHEADER_LEN (18)
4657
4658 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4659 return;
4660
4661 /*
4662 * Custom event can pass maximum of 256 bytes of data,
4663 * based on the IE len we need to identify how many BSS info can
4664 * be filled in to custom event data.
4665 */
4666 /*
4667 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4668 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4669 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4670 */
4671
4672 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4673 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004674 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004675 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004676 * indicate the supplicant about measurement done
4677 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 hdd_indicate_ese_bcn_report_no_results(
4679 pAdapter,
4680 pRoamInfo->pEseBcnReportRsp->
4681 measurementToken,
4682 pRoamInfo->pEseBcnReportRsp->flag,
4683 pRoamInfo->pEseBcnReportRsp->numBss);
4684 } else {
4685 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4686 memset(&wrqu, '\0', sizeof(wrqu));
4687 memset(buf, '\0', sizeof(buf));
4688 tot_bcn_ieLen = 0;
4689 sendBss = 0;
4690 pos = buf;
4691 freeBytes = IW_CUSTOM_MAX;
4692
4693 for (i = lastSent;
4694 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4695 len =
4696 bcnRepFieldSize + ieLenByte +
4697 pRoamInfo->pEseBcnReportRsp->
4698 bcnRepBssInfo[i].ieLen;
4699 if ((len + tot_bcn_ieLen) >
4700 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4701 break;
4702 }
4703 tot_bcn_ieLen += len;
4704 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004705 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004706 i, bcnRepFieldSize, 1,
4707 pRoamInfo->pEseBcnReportRsp->
4708 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 }
4710
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004711 hdd_debug("Sending %d BSS Info", sendBss);
4712 hdd_debug("CCXBCNREP=%d %d %d %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004713 pRoamInfo->pEseBcnReportRsp->measurementToken,
4714 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4715 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004716
4717 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4718 pRoamInfo->pEseBcnReportRsp->
4719 measurementToken,
4720 pRoamInfo->pEseBcnReportRsp->flag,
4721 sendBss);
4722 pos += nBytes;
4723 freeBytes -= nBytes;
4724
4725 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304726 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004727 sizeof(tot_bcn_ieLen));
4728 pos += sizeof(tot_bcn_ieLen);
4729 freeBytes -= sizeof(tot_bcn_ieLen);
4730
4731 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004732 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004733 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4734 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4735 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4736 pRoamInfo->pEseBcnReportRsp->
4737 bcnRepBssInfo[i +
4738 lastSent].bcnReportFields.
4739 ChanNum,
4740 pRoamInfo->pEseBcnReportRsp->
4741 bcnRepBssInfo[i +
4742 lastSent].bcnReportFields.
4743 Spare,
4744 pRoamInfo->pEseBcnReportRsp->
4745 bcnRepBssInfo[i +
4746 lastSent].bcnReportFields.
4747 MeasDuration,
4748 pRoamInfo->pEseBcnReportRsp->
4749 bcnRepBssInfo[i +
4750 lastSent].bcnReportFields.
4751 PhyType,
4752 pRoamInfo->pEseBcnReportRsp->
4753 bcnRepBssInfo[i +
4754 lastSent].bcnReportFields.
4755 RecvSigPower,
4756 pRoamInfo->pEseBcnReportRsp->
4757 bcnRepBssInfo[i +
4758 lastSent].bcnReportFields.
4759 ParentTsf,
4760 pRoamInfo->pEseBcnReportRsp->
4761 bcnRepBssInfo[i +
4762 lastSent].bcnReportFields.
4763 TargetTsf[0],
4764 pRoamInfo->pEseBcnReportRsp->
4765 bcnRepBssInfo[i +
4766 lastSent].bcnReportFields.
4767 TargetTsf[1],
4768 pRoamInfo->pEseBcnReportRsp->
4769 bcnRepBssInfo[i +
4770 lastSent].bcnReportFields.
4771 BcnInterval,
4772 pRoamInfo->pEseBcnReportRsp->
4773 bcnRepBssInfo[i +
4774 lastSent].bcnReportFields.
4775 CapabilityInfo,
4776 pRoamInfo->pEseBcnReportRsp->
4777 bcnRepBssInfo[i +
4778 lastSent].bcnReportFields.
4779 Bssid[0],
4780 pRoamInfo->pEseBcnReportRsp->
4781 bcnRepBssInfo[i +
4782 lastSent].bcnReportFields.
4783 Bssid[1],
4784 pRoamInfo->pEseBcnReportRsp->
4785 bcnRepBssInfo[i +
4786 lastSent].bcnReportFields.
4787 Bssid[2],
4788 pRoamInfo->pEseBcnReportRsp->
4789 bcnRepBssInfo[i +
4790 lastSent].bcnReportFields.
4791 Bssid[3],
4792 pRoamInfo->pEseBcnReportRsp->
4793 bcnRepBssInfo[i +
4794 lastSent].bcnReportFields.
4795 Bssid[4],
4796 pRoamInfo->pEseBcnReportRsp->
4797 bcnRepBssInfo[i +
4798 lastSent].bcnReportFields.
4799 Bssid[5]);
4800
4801 /* bcn report fields are copied */
4802 len =
4803 sizeof(pRoamInfo->pEseBcnReportRsp->
4804 bcnRepBssInfo[i +
4805 lastSent].
4806 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304807 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004808 (char *)&pRoamInfo->
4809 pEseBcnReportRsp->bcnRepBssInfo[i +
4810 lastSent].
4811 bcnReportFields, len);
4812 pos += len;
4813 freeBytes -= len;
4814
4815 /* Add 1 byte of ie len */
4816 len =
4817 pRoamInfo->pEseBcnReportRsp->
4818 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304819 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 pos += sizeof(len);
4821 freeBytes -= sizeof(len);
4822
4823 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304824 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004825 (char *)pRoamInfo->
4826 pEseBcnReportRsp->bcnRepBssInfo[i +
4827 lastSent].
4828 pBuf, len);
4829 pos += len;
4830 freeBytes -= len;
4831 }
4832
4833 wrqu.data.pointer = buf;
4834 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4835
4836 /* send the event */
4837 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4838 buf);
4839 lastSent += sendBss;
4840 }
4841 }
4842}
4843
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004844#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004845
4846/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304847 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4848 * @pHddStaCtx: Station Context
4849 *
4850 * API to check if the connection authentication type is 8021x_sha256.
4851 *
4852 * Return: bool
4853 */
4854#ifdef WLAN_FEATURE_11W
4855static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4856{
4857 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4858 pHddStaCtx->conn_info.authType;
4859}
4860#else
4861static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4862{
4863 return false;
4864}
4865#endif
4866
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304867/*
4868 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4869 * @adapter: Pointer to adapter context
4870 * @roam_info: Pointer to roam info
4871 *
4872 * Return: None
4873 */
4874static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4875 tCsrRoamInfo *roam_info)
4876{
4877 struct hdd_chan_change_params chan_change;
4878 struct cfg80211_bss *bss;
4879 struct net_device *dev = adapter->dev;
4880 struct wireless_dev *wdev = dev->ieee80211_ptr;
4881 struct wiphy *wiphy = wdev->wiphy;
4882 QDF_STATUS status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004883 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304884
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004885 hdd_debug("channel switch for session:%d to channel:%d",
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304886 adapter->sessionId, roam_info->chan_info.chan_id);
4887
4888 chan_change.chan = roam_info->chan_info.chan_id;
4889 chan_change.chan_params.ch_width =
4890 roam_info->chan_info.ch_width;
4891 chan_change.chan_params.sec_ch_offset =
4892 roam_info->chan_info.sec_ch_offset;
4893 chan_change.chan_params.center_freq_seg0 =
4894 roam_info->chan_info.band_center_freq1;
4895 chan_change.chan_params.center_freq_seg1 =
4896 roam_info->chan_info.band_center_freq2;
4897
4898 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4899 if (NULL == bss)
4900 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4901 else
4902 cfg80211_put_bss(wiphy, bss);
4903
bings58ce8622017-07-10 15:55:36 +08004904 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4905 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304906 if (QDF_IS_STATUS_ERROR(status))
4907 hdd_err("channel change notification failed");
4908
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004909 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
4910 adapter->sessionId);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304911 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004912 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304913}
4914
Komal Seelam98760ba2015-12-15 11:05:18 +05304915/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916 * hdd_sme_roam_callback() - hdd sme roam callback
4917 * @pContext: pointer to adapter context
4918 * @pRoamInfo: pointer to roam info
4919 * @roamId: roam id
4920 * @roamStatus: roam status
4921 * @roamResult: roam result
4922 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304923 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304925QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4927 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4928{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304929 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004930 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4931 hdd_wext_state_t *pWextState = NULL;
4932 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304933 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304934 struct cfg80211_bss *bss_status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004935 hdd_context_t *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004936
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004937 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004938 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939
4940 /* Sanity check */
4941 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004942 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304943 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004944 }
4945
4946 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4947 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004948 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304950 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4951 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4952 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4953 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304954
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 switch (roamStatus) {
4956 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304957 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4958 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004959 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004960 break;
4961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 /*
4963 * We did pre-auth,then we attempted a 11r or ese reassoc.
4964 * reassoc failed due to failure, timeout, reject from ap
4965 * in any case tell the OS, our carrier is off and mark
4966 * interface down.
4967 */
4968 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004969 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4970 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304971 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004972 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4973 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 pHddStaCtx->ft_carrier_on = false;
4975 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004976 hdd_debug("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004977 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004978 break;
4979
4980 case eCSR_ROAM_FT_START:
4981 /*
4982 * When we roam for ESE and 11r, we dont want the OS to be
4983 * informed that the link is down. So mark the link ready for
4984 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4985 * be received. Where in we will not mark the link down
4986 * Also we want to stop tx at this point when we will be
4987 * doing disassoc at this time. This saves 30-60 msec
4988 * after reassoc.
4989 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004990 hdd_info("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004991 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004992 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004993 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304994 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004995 WLAN_CONTROL_PATH);
4996 status = hdd_roam_deregister_sta(pAdapter,
4997 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304998 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304999 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000 pHddStaCtx->ft_carrier_on = true;
5001 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005002 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
5003 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005005 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005006 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005007 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005008 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305009 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
5010 pAdapter->roam_ho_fail = true;
5011 else
5012 pAdapter->roam_ho_fail = false;
5013 complete(&pAdapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005014 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005015 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005016 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -07005017 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005018 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305019 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005020 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005021 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022 wlan_hdd_netif_queue_control(pAdapter,
5023 WLAN_NETIF_CARRIER_OFF,
5024 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005025 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005026 break;
5027 case eCSR_ROAM_LOSTLINK:
5028 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005029 hdd_debug("Roaming started due to connection lost");
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005030 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005031 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305032 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 WLAN_CONTROL_PATH);
5034 break;
5035 }
5036 case eCSR_ROAM_DISASSOCIATED:
5037 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005038 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305039 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07005040 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305041 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305042 pAdapter->roam_ho_fail = false;
5043 complete(&pAdapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305044
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005045 /* Call to clear any MC Addr List filter applied after
5046 * successful connection.
5047 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05305048 hdd_disable_and_flush_mc_addr_list(pAdapter,
5049 pmo_peer_disconnect);
5050 qdf_ret_status =
5051 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
5052 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053 }
5054 break;
5055 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005056 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305057 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
5059 roamStatus, roamResult);
5060 break;
5061 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005062 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005063 /*
5064 * To Do - address probable memory leak with WEP encryption upon
5065 * successful association.
5066 */
5067 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
5068 /* Clear saved connection information in HDD */
5069 hdd_conn_remove_connect_info(
5070 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
5071 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305072 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005073 hdd_association_completion_handler(pAdapter, pRoamInfo,
5074 roamId, roamStatus,
5075 roamResult);
5076#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5077 if (pRoamInfo)
5078 pRoamInfo->roamSynchInProgress = false;
5079#endif
5080 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07005081 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005082 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305084 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005085 pRoamInfo,
5086 roamId,
5087 roamStatus,
5088 roamResult);
5089 break;
5090 case eCSR_ROAM_IBSS_IND:
5091 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
5092 roamStatus, roamResult);
5093 break;
5094
5095 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305096 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097 roam_roam_connect_status_update_handler(pAdapter,
5098 pRoamInfo,
5099 roamId,
5100 roamStatus,
5101 roamResult);
5102 break;
5103
5104 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305105 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 hdd_roam_mic_error_indication_handler(pAdapter,
5107 pRoamInfo,
5108 roamId,
5109 roamStatus,
5110 roamResult);
5111 break;
5112
5113 case eCSR_ROAM_SET_KEY_COMPLETE:
5114 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305115 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005116 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
5117 roamId, roamStatus,
5118 roamResult);
5119 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
5120 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005121 hdd_debug("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122 pHddStaCtx->hdd_ReassocScenario,
5123 pAdapter->sessionId);
5124 }
5125 }
5126#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5127 if (pRoamInfo != NULL)
5128 pRoamInfo->roamSynchInProgress = false;
5129#endif
5130 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005131
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005132 case eCSR_ROAM_FT_RESPONSE:
5133 hdd_send_ft_event(pAdapter);
5134 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005135
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005136 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05305137 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
5138 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005139 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305140 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005141 wlan_hdd_cfg80211_pmksa_candidate_notify(
5142 pAdapter, pRoamInfo, 1, false);
5143 }
5144 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005145
5146#ifdef FEATURE_WLAN_LFR_METRICS
5147 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
5148 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305149 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
5151 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305152 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 }
5154 break;
5155 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
5156 /*
5157 * This event will notify pre-auth completion in case of success
5158 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305159 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5161 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305162 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163 }
5164 break;
5165 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
5166 /*
5167 * This event will notify pre-auth completion incase of failure.
5168 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305169 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005170 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5171 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305172 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005173 }
5174 break;
5175 case eCSR_ROAM_HANDOVER_SUCCESS:
5176 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08005177 * It will be only invoked on success
5178 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305179 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005180 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
5181 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305182 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183 }
5184 break;
5185#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005186 case eCSR_ROAM_REMAIN_CHAN_READY:
5187 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
5188 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005189#ifdef FEATURE_WLAN_TDLS
5190 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305191 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005192 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
5193 roamId,
5194 roamStatus,
5195 roamResult);
5196 break;
5197 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
5198 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
5199 pRoamInfo->reasonCode);
5200 break;
5201#endif
5202#ifdef WLAN_FEATURE_11W
5203 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
5204 hdd_indicate_unprot_mgmt_frame(pAdapter,
5205 pRoamInfo->nFrameLength,
5206 pRoamInfo->pbFrames,
5207 pRoamInfo->frameType);
5208 break;
5209#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005210#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005211 case eCSR_ROAM_TSM_IE_IND:
5212 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5213 pRoamInfo->tsmIe.state,
5214 pRoamInfo->tsmIe.msmt_interval);
5215 break;
5216
5217 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5218 {
5219 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5220 pHddStaCtx->conn_info.authType
5221 || eCSR_AUTH_TYPE_CCKM_RSN ==
5222 pHddStaCtx->conn_info.authType) {
5223 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5224 }
5225 break;
5226 }
5227
5228 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5229 {
5230 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5231 break;
5232 }
5233
5234 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5235 {
5236 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5237 break;
5238 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005239#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305240 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305241 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305242 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305243
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305244 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5245 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5246 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5247 pAdapter, pRoamInfo->pBssDesc);
5248 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005249 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305250 else
5251 cfg80211_put_bss(
5252#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5253 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5254#endif
5255 bss_status);
5256 }
5257 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005258 case eCSR_ROAM_NDP_STATUS_UPDATE:
5259 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5260 roamResult);
5261 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005262 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005263 hdd_debug("Process ROAM_START from firmware");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005264 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305265 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005266 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005267 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005268 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005269 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08005270 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005271 break;
5272 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005273 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005274 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005275 wlan_hdd_netif_queue_control(pAdapter,
5276 WLAN_WAKE_ALL_NETIF_QUEUE,
5277 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005278 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005279 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305280 pAdapter->roam_ho_fail = false;
5281 complete(&pAdapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005282 break;
5283
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005284 default:
5285 break;
5286 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305287 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288}
5289
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305290#ifdef WLAN_FEATURE_FILS_SK
5291/**
5292 * hdd_translate_fils_rsn_to_csr_auth() - Translate FILS RSN to CSR auth type
5293 * @auth_suite: auth suite
5294 * @auth_type: pointer to eCsrAuthType
5295 *
5296 * Return: None
5297 */
5298static void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
5299 eCsrAuthType *auth_type)
5300{
5301 if (!memcmp(auth_suite, ccp_rsn_oui_0e, 4))
5302 *auth_type = eCSR_AUTH_TYPE_FILS_SHA256;
5303 else if (!memcmp(auth_suite, ccp_rsn_oui_0f, 4))
5304 *auth_type = eCSR_AUTH_TYPE_FILS_SHA384;
5305 else if (!memcmp(auth_suite, ccp_rsn_oui_10, 4))
5306 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA256;
5307 else if (!memcmp(auth_suite, ccp_rsn_oui_11, 4))
5308 *auth_type = eCSR_AUTH_TYPE_FT_FILS_SHA384;
5309}
5310#else
5311static inline void hdd_translate_fils_rsn_to_csr_auth(int8_t auth_suite[4],
5312 eCsrAuthType *auth_type)
5313{
5314}
5315#endif
5316
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317/**
5318 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5319 * @auth_suite: auth suite
5320 *
5321 * Return: eCsrAuthType enumeration
5322 */
5323eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5324{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305325 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005326 /* is the auth type supported? */
5327 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5328 auth_type = eCSR_AUTH_TYPE_RSN;
5329 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5330 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005331 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005332 /* Check for 11r FT Authentication with PSK */
5333 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5334 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5335 /* Check for 11R FT Authentication with 802.1X */
5336 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5337 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005338#ifdef FEATURE_WLAN_ESE
5339 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5340 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5341 } else
5342#endif /* FEATURE_WLAN_ESE */
5343#ifdef WLAN_FEATURE_11W
5344 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5345 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5346 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5347 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5348 } else
5349#endif
5350 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305351 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005352 }
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305353 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005354 return auth_type;
5355}
5356
5357/**
5358 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5359 * @auth_suite: auth suite
5360 *
5361 * Return: eCsrAuthType enumeration
5362 */
5363eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5364{
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305365 eCsrAuthType auth_type = eCSR_AUTH_TYPE_UNKNOWN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 /* is the auth type supported? */
5367 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5368 auth_type = eCSR_AUTH_TYPE_WPA;
5369 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5370 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5371 } else
5372#ifdef FEATURE_WLAN_ESE
5373 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5374 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5375 } else
5376#endif /* FEATURE_WLAN_ESE */
5377 {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305378 hdd_translate_fils_rsn_to_csr_auth(auth_suite, &auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005379 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005380 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005381 return auth_type;
5382}
5383
5384/**
5385 * hdd_translate_rsn_to_csr_encryption_type() -
5386 * Translate RSN to CSR encryption type
5387 * @cipher_suite: cipher suite
5388 *
5389 * Return: eCsrEncryptionType enumeration
5390 */
5391eCsrEncryptionType
5392hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5393{
5394 eCsrEncryptionType cipher_type;
5395
5396 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5397 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05305398 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
5399 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
5400 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
5401 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5403 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5404 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5405 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5406 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5407 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5408 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5409 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5410 else
5411 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5412
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005413 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005414 return cipher_type;
5415}
5416
5417/**
5418 * hdd_translate_wpa_to_csr_encryption_type() -
5419 * Translate WPA to CSR encryption type
5420 * @cipher_suite: cipher suite
5421 *
5422 * Return: eCsrEncryptionType enumeration
5423 */
5424eCsrEncryptionType
5425hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5426{
5427 eCsrEncryptionType cipher_type;
5428
5429 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5430 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5431 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5432 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5433 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5434 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5435 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5436 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5437 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5438 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5439 else
5440 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5441
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005442 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 return cipher_type;
5444}
5445
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305446#ifdef WLAN_FEATURE_FILS_SK
5447/*
5448 * hdd_is_fils_connection: API to determine if connection is FILS
5449 * @adapter: hdd adapter
5450 *
5451 * Return: true if fils connection else false
5452 */
5453static inline bool hdd_is_fils_connection(hdd_adapter_t *adapter)
5454{
5455 hdd_wext_state_t *wext_state = WLAN_HDD_GET_WEXT_STATE_PTR(adapter);
5456
5457 if (wext_state->roamProfile.fils_con_info)
5458 return wext_state->roamProfile.
5459 fils_con_info->is_fils_connection;
5460}
5461#else
5462static inline bool hdd_is_fils_connection(hdd_adapter_t *adapter)
5463{
5464 return false;
5465}
5466#endif
5467
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468/**
5469 * hdd_process_genie() - process gen ie
5470 * @pAdapter: pointer to adapter
5471 * @bssid: pointer to mac address
5472 * @pEncryptType: pointer to encryption type
5473 * @mcEncryptType: pointer to multicast encryption type
5474 * @pAuthType: pointer to auth type
5475 *
5476 * Return: 0 on success, error number otherwise
5477 */
5478static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5479 u8 *bssid,
5480 eCsrEncryptionType *pEncryptType,
5481 eCsrEncryptionType *mcEncryptType,
5482 eCsrAuthType *pAuthType,
5483#ifdef WLAN_FEATURE_11W
5484 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5485#endif
5486 uint16_t gen_ie_len, uint8_t *gen_ie)
5487{
5488 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005489 tDot11fIERSN dot11RSNIE;
5490 tDot11fIEWPA dot11WPAIE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 uint8_t *pRsnIe;
5492 uint16_t RSNIeLen;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493
5494 /*
5495 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5496 * setting present flag to 0.
5497 */
5498 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5499 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5500
5501 /* Type check */
5502 if (gen_ie[0] == DOT11F_EID_RSN) {
5503 /* Validity checks */
5504 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5505 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005506 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005507 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005508 return -EINVAL;
5509 }
5510 /* Skip past the EID byte and length byte */
5511 pRsnIe = gen_ie + 2;
5512 RSNIeLen = gen_ie_len - 2;
5513 /* Unpack the RSN IE */
5514 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305515 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005516 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005517 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005518 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005519 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005520 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005521 /* dot11RSNIE.akm_suite_count */
5522 /* Just translate the FIRST one */
5523 *pAuthType =
5524 hdd_translate_rsn_to_csr_auth_type(
5525 dot11RSNIE.akm_suites[0]);
5526 /* dot11RSNIE.pwise_cipher_suite_count */
5527 *pEncryptType =
5528 hdd_translate_rsn_to_csr_encryption_type(
5529 dot11RSNIE.pwise_cipher_suites[0]);
5530 /* dot11RSNIE.gp_cipher_suite_count */
5531 *mcEncryptType =
5532 hdd_translate_rsn_to_csr_encryption_type(
5533 dot11RSNIE.gp_cipher_suite);
5534#ifdef WLAN_FEATURE_11W
5535 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
Srinivas Girigowda6519b932017-08-03 14:10:57 -07005536 *pMfpCapable = csr_is_mfpc_capable(&dot11RSNIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005537#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005538 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5539 /* Validity checks */
5540 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5541 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005542 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005543 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005544 return -EINVAL;
5545 }
5546 /* Skip past the EID and length byte - and four byte WiFi OUI */
5547 pRsnIe = gen_ie + 2 + 4;
5548 RSNIeLen = gen_ie_len - (2 + 4);
5549 /* Unpack the WPA IE */
5550 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305551 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005552 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005553 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005554 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005555 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005556 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005557 /* dot11WPAIE.auth_suite_count */
5558 /* Just translate the FIRST one */
5559 *pAuthType =
5560 hdd_translate_wpa_to_csr_auth_type(
5561 dot11WPAIE.auth_suites[0]);
5562 /* dot11WPAIE.unicast_cipher_count */
5563 *pEncryptType =
5564 hdd_translate_wpa_to_csr_encryption_type(
5565 dot11WPAIE.unicast_ciphers[0]);
5566 /* dot11WPAIE.unicast_cipher_count */
5567 *mcEncryptType =
5568 hdd_translate_wpa_to_csr_encryption_type(
5569 dot11WPAIE.multicast_cipher);
5570 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005571 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 return -EINVAL;
5573 }
5574 return 0;
5575}
5576
5577/**
5578 * hdd_set_genie_to_csr() - set genie to csr
5579 * @pAdapter: pointer to adapter
5580 * @RSNAuthType: pointer to auth type
5581 *
5582 * Return: 0 on success, error number otherwise
5583 */
5584int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5585{
5586 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5587 uint32_t status = 0;
5588 eCsrEncryptionType RSNEncryptType;
5589 eCsrEncryptionType mcRSNEncryptType;
5590#ifdef WLAN_FEATURE_11W
5591 uint8_t RSNMfpRequired = 0;
5592 uint8_t RSNMfpCapable = 0;
5593#endif
5594 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5595 /* MAC address of assoc peer */
5596 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305597 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005598 pWextState->roamProfile.BSSIDs.bssid,
5599 sizeof(bssid));
5600 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5601 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5602 /* continue */
5603 } else {
5604 return 0;
5605 }
5606 /* The actual processing may eventually be more extensive than this. */
5607 /* Right now, just consume any PMKIDs that are sent in by the app. */
5608 status = hdd_process_genie(pAdapter, bssid,
5609 &RSNEncryptType,
5610 &mcRSNEncryptType, RSNAuthType,
5611#ifdef WLAN_FEATURE_11W
5612 &RSNMfpRequired, &RSNMfpCapable,
5613#endif
5614 pWextState->WPARSNIE[1] + 2,
5615 pWextState->WPARSNIE);
5616 if (status == 0) {
5617 /*
5618 * Now copy over all the security attributes
5619 * you have parsed out.
5620 */
5621 pWextState->roamProfile.EncryptionType.numEntries = 1;
5622 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5623
5624 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5625 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5626 mcRSNEncryptType;
5627
Krunal Sonibe766b02016-03-10 13:00:44 -08005628 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005629 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05305630 (eCSR_ENCRYPT_TYPE_AES_GCMP == mcRSNEncryptType) ||
5631 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mcRSNEncryptType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5633 /*
5634 * For wpa none supplicant sends the WPA IE with unicast
5635 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5636 * multicast cipher as either AES/TKIP based on group
5637 * cipher configuration mentioned in the
5638 * wpa_supplicant.conf.
5639 */
5640
5641 /* Set the unicast cipher same as multicast cipher */
5642 pWextState->roamProfile.EncryptionType.encryptionType[0]
5643 = mcRSNEncryptType;
5644 }
5645#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005646 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005647 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5649 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5650#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005651 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005652 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005653 }
5654 return 0;
5655}
5656
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305657#ifdef WLAN_FEATURE_FILS_SK
5658/**
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305659 * hdd_check_fils_rsn_n_set_auth_type() - This API checks whether a give
5660 * auth type is fils if yes, sets it in profile.
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305661 * @rsn_auth_type: auth type
5662 *
5663 * Return: true if FILS auth else false
5664 */
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305665static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5666 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305667{
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305668 bool is_fils_rsn = false;
5669
5670 if (!roam_profile->fils_con_info)
5671 return false;
5672
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305673 if ((rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA256) ||
5674 (rsn_auth_type == eCSR_AUTH_TYPE_FILS_SHA384) ||
5675 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA256) ||
5676 (rsn_auth_type == eCSR_AUTH_TYPE_FT_FILS_SHA384))
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305677 is_fils_rsn = true;
5678 if (is_fils_rsn)
5679 roam_profile->fils_con_info->akm_type = rsn_auth_type;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305680
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305681 return is_fils_rsn;
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305682}
5683#else
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305684static bool hdd_check_fils_rsn_n_set_auth_type(tCsrRoamProfile *roam_profile,
5685 eCsrAuthType rsn_auth_type)
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305686{
5687 return false;
5688}
5689#endif
5690
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005691/**
5692 * hdd_set_csr_auth_type() - set csr auth type
5693 * @pAdapter: pointer to adapter
5694 * @RSNAuthType: auth type
5695 *
5696 * Return: 0 on success, error number otherwise
5697 */
5698int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5699{
5700 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5701 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5702 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703
5704 pRoamProfile->AuthType.numEntries = 1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005705 hdd_debug("pHddStaCtx->conn_info.authType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005706 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005707
5708 switch (pHddStaCtx->conn_info.authType) {
5709 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5710#ifdef FEATURE_WLAN_ESE
5711 case eCSR_AUTH_TYPE_CCKM_WPA:
5712 case eCSR_AUTH_TYPE_CCKM_RSN:
5713#endif
5714 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5715
5716 pRoamProfile->AuthType.authType[0] =
5717 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5718 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5719
5720#ifdef FEATURE_WLAN_ESE
5721 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5722 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5723 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005724 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005725 pRoamProfile->AuthType.authType[0] =
5726 eCSR_AUTH_TYPE_CCKM_WPA;
5727 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005728 hdd_debug("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 pRoamProfile->AuthType.authType[0] =
5730 eCSR_AUTH_TYPE_CCKM_WPA;
5731 } else
5732#endif
5733 if ((pWextState->
5734 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5735 == IW_AUTH_KEY_MGMT_802_1X) {
5736 pRoamProfile->AuthType.authType[0] =
5737 eCSR_AUTH_TYPE_WPA;
5738 } else
5739 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5740 == IW_AUTH_KEY_MGMT_PSK) {
5741 pRoamProfile->AuthType.authType[0] =
5742 eCSR_AUTH_TYPE_WPA_PSK;
5743 } else {
5744 pRoamProfile->AuthType.authType[0] =
5745 eCSR_AUTH_TYPE_WPA_NONE;
5746 }
5747 }
5748 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5749#ifdef FEATURE_WLAN_ESE
5750 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5751 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5752 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005753 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005754 pRoamProfile->AuthType.authType[0] =
5755 eCSR_AUTH_TYPE_CCKM_RSN;
5756 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005757 hdd_debug("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005758 pRoamProfile->AuthType.authType[0] =
5759 eCSR_AUTH_TYPE_CCKM_RSN;
5760 } else
5761#endif
5762
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005763 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5764 ((pWextState->
5765 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5766 == IW_AUTH_KEY_MGMT_802_1X)) {
5767 pRoamProfile->AuthType.authType[0] =
5768 eCSR_AUTH_TYPE_FT_RSN;
5769 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5770 &&
5771 ((pWextState->
5772 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5773 == IW_AUTH_KEY_MGMT_PSK)) {
5774 pRoamProfile->AuthType.authType[0] =
5775 eCSR_AUTH_TYPE_FT_RSN_PSK;
5776 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777
5778#ifdef WLAN_FEATURE_11W
5779 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5780 pRoamProfile->AuthType.authType[0] =
5781 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5782 } else if (RSNAuthType ==
5783 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5784 pRoamProfile->AuthType.authType[0] =
5785 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5786 } else
5787#endif
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305788 if (hdd_check_fils_rsn_n_set_auth_type(pRoamProfile,
5789 RSNAuthType)) {
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305790 pRoamProfile->AuthType.authType[0] =
5791 RSNAuthType;
Sridhar Selvaraj8c6f5e82017-08-21 14:53:46 +05305792 hdd_info("updated profile authtype as %d",
5793 RSNAuthType);
5794
Sridhar Selvaraj6cf642f2017-08-21 14:28:10 +05305795 } else if ((pWextState->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005796 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5797 == IW_AUTH_KEY_MGMT_802_1X) {
5798 pRoamProfile->AuthType.authType[0] =
5799 eCSR_AUTH_TYPE_RSN;
5800 } else
5801 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5802 == IW_AUTH_KEY_MGMT_PSK) {
5803 pRoamProfile->AuthType.authType[0] =
5804 eCSR_AUTH_TYPE_RSN_PSK;
5805 } else {
5806 pRoamProfile->AuthType.authType[0] =
5807 eCSR_AUTH_TYPE_UNKNOWN;
5808 }
5809 }
5810 break;
5811
5812 case eCSR_AUTH_TYPE_SHARED_KEY:
5813
5814 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5815 break;
5816 default:
5817
5818#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005819 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005820#endif /* FEATURE_WLAN_ESE */
5821 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5822 break;
5823 }
5824
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005825 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005826 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005828 return 0;
5829}
5830
5831/**
5832 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5833 * to the CSR roam profile.
5834 *
5835 * @dev: Pointer to the net device.
5836 * @info: Pointer to the iw_request_info.
5837 * @wrqu: Pointer to the iwreq_data.
5838 * @extra: Pointer to the data.
5839 *
5840 * Return: 0 for success, error number on failure
5841 */
5842static int __iw_set_essid(struct net_device *dev,
5843 struct iw_request_info *info,
5844 union iwreq_data *wrqu, char *extra)
5845{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005846 uint32_t status = 0;
5847 hdd_wext_state_t *pWextState;
5848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5849 hdd_context_t *hdd_ctx;
5850 uint32_t roamId;
5851 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 eCsrAuthType RSNAuthType;
5853 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005854 int ret;
5855
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005856 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005857
5858 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5859 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305860 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005861 return ret;
5862
Jeff Johnson441e1f72017-02-07 08:50:49 -08005863 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5864 if (0 != ret)
5865 return ret;
5866
Krunal Sonibe766b02016-03-10 13:00:44 -08005867 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005868 pAdapter->device_mode != QDF_IBSS_MODE &&
5869 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005870 hdd_warn("device mode %s(%d) is not allowed",
5871 hdd_device_mode_to_string(pAdapter->device_mode),
5872 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005873 return -EINVAL;
5874 }
5875
5876 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5877
5878 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005879 hdd_warn("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005880 return -EBUSY;
5881 }
5882 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5883 return -EINVAL;
5884
5885 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305886 /*Try disconnecting if already in connected state*/
5887 status = wlan_hdd_try_disconnect(pAdapter);
5888 if (0 > status) {
Srinivas Girigowda576b2352017-08-25 14:44:26 -07005889 hdd_err("Failed to disconnect the existing connection");
5890 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 }
5892
5893 /*
5894 * when cfg80211 defined, wpa_supplicant wext driver uses
5895 * zero-length, null-string ssid for force disconnection.
5896 * after disconnection (if previously connected) and cleaning ssid,
5897 * driver MUST return success.
5898 */
5899 if (0 == wrqu->essid.length)
5900 return 0;
5901
5902 status = hdd_wmm_get_uapsd_mask(pAdapter,
5903 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305904 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005905 pWextState->roamProfile.uapsd_mask = 0;
5906
5907 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5908
5909 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5910 wrqu->essid.length;
5911
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305912 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005913 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305914 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005915 ssId), extra, wrqu->essid.length);
5916 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5917 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5918
5919 /* set gen ie */
5920 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5921
5922 /* set auth */
5923 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5924 }
5925#ifdef FEATURE_WLAN_WAPI
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005926 hdd_debug("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005927 if (pAdapter->wapi_info.nWapiMode) {
5928 switch (pAdapter->wapi_info.wapiAuthMode) {
5929 case WAPI_AUTH_MODE_PSK:
5930 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005931 hdd_debug("WAPI AUTH TYPE: PSK: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005932 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005933 pRoamProfile->AuthType.numEntries = 1;
5934 pRoamProfile->AuthType.authType[0] =
5935 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5936 break;
5937 }
5938 case WAPI_AUTH_MODE_CERT:
5939 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005940 hdd_debug("WAPI AUTH TYPE: CERT: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005941 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005942 pRoamProfile->AuthType.numEntries = 1;
5943 pRoamProfile->AuthType.authType[0] =
5944 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5945 break;
5946 }
5947 } /* End of switch */
5948 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5949 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005950 hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005951 pRoamProfile->EncryptionType.numEntries = 1;
5952 pRoamProfile->EncryptionType.encryptionType[0] =
5953 eCSR_ENCRYPT_TYPE_WPI;
5954 pRoamProfile->mcEncryptionType.numEntries = 1;
5955 pRoamProfile->mcEncryptionType.encryptionType[0] =
5956 eCSR_ENCRYPT_TYPE_WPI;
5957 }
5958 }
5959#endif /* FEATURE_WLAN_WAPI */
5960 /* if previous genIE is not NULL, update AssocIE */
5961 if (0 != pWextState->genIE.length) {
5962 memset(&pWextState->assocAddIE, 0,
5963 sizeof(pWextState->assocAddIE));
5964 memcpy(pWextState->assocAddIE.addIEdata,
5965 pWextState->genIE.addIEdata, pWextState->genIE.length);
5966 pWextState->assocAddIE.length = pWextState->genIE.length;
5967 pWextState->roamProfile.pAddIEAssoc =
5968 pWextState->assocAddIE.addIEdata;
5969 pWextState->roamProfile.nAddIEAssocLength =
5970 pWextState->assocAddIE.length;
5971
5972 /* clear previous genIE after use it */
5973 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5974 }
5975
5976 /*
5977 * Assumes it is not WPS Association by default, except when
5978 * pAddIEAssoc has WPS IE.
5979 */
5980 pWextState->roamProfile.bWPSAssociation = false;
5981
5982 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5983 pWextState->roamProfile.
5984 nAddIEAssocLength))
5985 pWextState->roamProfile.bWPSAssociation = true;
5986
5987 /* Disable auto BMPS entry by PMC until DHCP is done */
5988 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5989 true);
5990
5991 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5992
5993 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005994 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005996 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5997 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005998 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005999
Agrawal Ashish6b015762016-05-05 11:22:18 +05306000 /*
6001 * Change conn_state to connecting before sme_roam_connect(),
6002 * because sme_roam_connect() has a direct path to call
6003 * hdd_sme_roam_callback(), which will change the conn_state
6004 * If direct path, conn_state will be accordingly changed to
6005 * NotConnected or Associated by either
6006 * hdd_association_completion_handler() or hdd_dis_connect_handler()
6007 * in sme_RoamCallback()if sme_RomConnect is to be queued,
6008 * Connecting state will remain until it is completed.
6009 *
6010 * If connection state is not changed,
6011 * connection state will remain in eConnectionState_NotConnected state.
6012 * In hdd_association_completion_handler, "hddDisconInProgress" is
6013 * set to true if conn state is eConnectionState_NotConnected.
6014 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
6015 * informed of connect result indication which is an issue.
6016 */
6017 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306018 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05306019 hdd_conn_set_connection_state(pAdapter,
6020 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05306021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022 status = sme_roam_connect(hHal, pAdapter->sessionId,
6023 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05306024 if ((QDF_STATUS_SUCCESS != status) &&
6025 (QDF_STA_MODE == pAdapter->device_mode ||
6026 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006027 hdd_err("sme_roam_connect failed session_id: %d status %d -> NotConnected",
Agrawal Ashish6b015762016-05-05 11:22:18 +05306028 pAdapter->sessionId, status);
6029 /* change back to NotAssociated */
6030 hdd_conn_set_connection_state(pAdapter,
6031 eConnectionState_NotConnected);
6032 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006033 pRoamProfile->ChannelInfo.ChannelList = NULL;
6034 pRoamProfile->ChannelInfo.numOfChannels = 0;
6035
6036 EXIT();
6037 return status;
6038}
6039
6040/**
6041 * iw_set_essid() - set essid handler function
6042 * @dev: Pointer to the net device.
6043 * @info: Pointer to the iw_request_info.
6044 * @wrqu: Pointer to the iwreq_data.
6045 * @extra: Pointer to the data.
6046 *
6047 * Return: 0 for success, error number on failure
6048 */
6049int iw_set_essid(struct net_device *dev,
6050 struct iw_request_info *info,
6051 union iwreq_data *wrqu, char *extra)
6052{
6053 int ret;
6054
6055 cds_ssr_protect(__func__);
6056 ret = __iw_set_essid(dev, info, wrqu, extra);
6057 cds_ssr_unprotect(__func__);
6058
6059 return ret;
6060}
6061
6062/**
6063 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
6064 * @dev: pointer to the net device
6065 * @info: pointer to the iw request info
6066 * @dwrq: pointer to iw_point
6067 * @extra: pointer to the data
6068 *
6069 * Return: 0 on success, error number otherwise
6070 */
6071static int __iw_get_essid(struct net_device *dev,
6072 struct iw_request_info *info,
6073 struct iw_point *dwrq, char *extra)
6074{
6075 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6076 hdd_context_t *hdd_ctx;
6077 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6078 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6079 int ret;
6080
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006081 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082
6083 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6084 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306085 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006086 return ret;
6087
Jeff Johnson441e1f72017-02-07 08:50:49 -08006088 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6089 if (0 != ret)
6090 return ret;
6091
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
6093 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
6094 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
6095 || pHddStaCtx->conn_info.connState ==
6096 eConnectionState_IbssDisconnected)
6097 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
6098 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
6099 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
6100 dwrq->length);
6101 dwrq->flags = 1;
6102 } else {
6103 memset(extra, 0, dwrq->length);
6104 dwrq->length = 0;
6105 dwrq->flags = 0;
6106 }
6107 EXIT();
6108 return 0;
6109}
6110
6111/**
6112 * iw_get_essid() - get essid handler function
6113 * @dev: Pointer to the net device.
6114 * @info: Pointer to the iw_request_info.
6115 * @wrqu: Pointer to the iwreq_data.
6116 * @extra: Pointer to the data.
6117 *
6118 * Return: 0 for success, error number on failure
6119 */
6120int iw_get_essid(struct net_device *dev,
6121 struct iw_request_info *info,
6122 struct iw_point *wrqu, char *extra)
6123{
6124 int ret;
6125
6126 cds_ssr_protect(__func__);
6127 ret = __iw_get_essid(dev, info, wrqu, extra);
6128 cds_ssr_unprotect(__func__);
6129
6130 return ret;
6131}
6132
6133/**
6134 * __iw_set_auth() -
6135 * This function sets the auth type received from the wpa_supplicant
6136 * @dev: pointer to the net device
6137 * @info: pointer to the iw request info
6138 * @wrqu: pointer to iwreq_data
6139 * @extra: pointer to the data
6140 *
6141 * Return: 0 on success, error number otherwise
6142 */
6143static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6144 union iwreq_data *wrqu, char *extra)
6145{
6146 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6147 hdd_context_t *hdd_ctx;
6148 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6149 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6150 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6151 eCsrEncryptionType mcEncryptionType;
6152 eCsrEncryptionType ucEncryptionType;
6153 int ret;
6154
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006155 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006156
6157 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6158 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306159 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006160 return ret;
6161
Jeff Johnson441e1f72017-02-07 08:50:49 -08006162 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6163 if (0 != ret)
6164 return ret;
6165
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006166 switch (wrqu->param.flags & IW_AUTH_INDEX) {
6167 case IW_AUTH_WPA_VERSION:
6168 pWextState->wpaVersion = wrqu->param.value;
6169 break;
6170
6171 case IW_AUTH_CIPHER_PAIRWISE:
6172 {
6173 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6174 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6175 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6176 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6177 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6178 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6179 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6180 if ((IW_AUTH_KEY_MGMT_802_1X
6181 ==
6182 (pWextState->
6183 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6184 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6185 pHddStaCtx->conn_info.authType))
6186 /*Dynamic WEP key */
6187 ucEncryptionType =
6188 eCSR_ENCRYPT_TYPE_WEP40;
6189 else
6190 /*Static WEP key */
6191 ucEncryptionType =
6192 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6193 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6194 if ((IW_AUTH_KEY_MGMT_802_1X
6195 ==
6196 (pWextState->
6197 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6198 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6199 pHddStaCtx->conn_info.authType))
6200 /*Dynamic WEP key */
6201 ucEncryptionType =
6202 eCSR_ENCRYPT_TYPE_WEP104;
6203 else
6204 /*Static WEP key */
6205 ucEncryptionType =
6206 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6207 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006208 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
6209 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 return -EINVAL;
6211 }
6212
6213 pRoamProfile->EncryptionType.numEntries = 1;
6214 pRoamProfile->EncryptionType.encryptionType[0] =
6215 ucEncryptionType;
6216 }
6217 break;
6218 case IW_AUTH_CIPHER_GROUP:
6219 {
6220 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6221 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6222 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6223 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6224 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6225 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6226 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6227 if ((IW_AUTH_KEY_MGMT_802_1X
6228 ==
6229 (pWextState->
6230 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6231 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6232 pHddStaCtx->conn_info.authType))
6233 mcEncryptionType =
6234 eCSR_ENCRYPT_TYPE_WEP40;
6235 else
6236 mcEncryptionType =
6237 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6238 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6239 /* Dynamic WEP keys won't work with shared keys */
6240 if ((IW_AUTH_KEY_MGMT_802_1X
6241 ==
6242 (pWextState->
6243 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6244 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6245 pHddStaCtx->conn_info.authType)) {
6246 mcEncryptionType =
6247 eCSR_ENCRYPT_TYPE_WEP104;
6248 } else {
6249 mcEncryptionType =
6250 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6251 }
6252 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006253 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006254 wrqu->param.value);
6255 return -EINVAL;
6256 }
6257
6258 pRoamProfile->mcEncryptionType.numEntries = 1;
6259 pRoamProfile->mcEncryptionType.encryptionType[0] =
6260 mcEncryptionType;
6261 }
6262 break;
6263
6264 case IW_AUTH_80211_AUTH_ALG:
6265 {
Jeff Johnson5a062372017-01-12 09:51:25 -08006266 /* Save the auth algo here and set auth type to SME
6267 * Roam profile in the iw_set_ap_address
6268 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006269 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6270 pHddStaCtx->conn_info.authType =
6271 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6272
6273 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6274 pHddStaCtx->conn_info.authType =
6275 eCSR_AUTH_TYPE_SHARED_KEY;
6276
6277 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6278 /*Not supported */
6279 pHddStaCtx->conn_info.authType =
6280 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6281 pWextState->roamProfile.AuthType.authType[0] =
6282 pHddStaCtx->conn_info.authType;
6283 }
6284 break;
6285
6286 case IW_AUTH_KEY_MGMT:
6287 {
6288#ifdef FEATURE_WLAN_ESE
6289#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6290 /*Check for CCKM AKM type */
6291 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006292 hdd_debug("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006293 /* Set the CCKM bit in authKeyMgmt */
6294 /*
6295 * Right now, this breaks all ref to authKeyMgmt because
6296 * our code doesn't realize it is a "bitfield"
6297 */
Jeff Johnsond084adb2017-08-16 11:19:52 -07006298 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006299 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6300 /* Save the key management */
6301 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006302 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006303 /* Save the key management anyway */
6304 pWextState->authKeyMgmt = wrqu->param.value;
6305 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6306 /* Save the key management */
6307 pWextState->authKeyMgmt |=
6308 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006309 }
6310#else
6311 /* Save the key management */
6312 pWextState->authKeyMgmt = wrqu->param.value;
6313#endif /* FEATURE_WLAN_ESE */
6314 }
6315 break;
6316
6317 case IW_AUTH_TKIP_COUNTERMEASURES:
6318 {
6319 if (wrqu->param.value) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006320 hdd_debug("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006321 wrqu->param.value);
6322 pWextState->mTKIPCounterMeasures =
6323 TKIP_COUNTER_MEASURE_STARTED;
6324 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006325 hdd_debug("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006326 wrqu->param.value);
6327 pWextState->mTKIPCounterMeasures =
6328 TKIP_COUNTER_MEASURE_STOPED;
6329 }
6330 }
6331 break;
6332 case IW_AUTH_DROP_UNENCRYPTED:
6333 case IW_AUTH_WPA_ENABLED:
6334 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6335 case IW_AUTH_ROAMING_CONTROL:
6336 case IW_AUTH_PRIVACY_INVOKED:
6337
6338 default:
6339
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006340 hdd_warn("called with unsupported auth type %d",
6341 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006342 break;
6343 }
6344
6345 EXIT();
6346 return 0;
6347}
6348
6349/**
6350 * iw_set_auth() - set auth callback function
6351 * @dev: Pointer to the net device.
6352 * @info: Pointer to the iw_request_info.
6353 * @wrqu: Pointer to the iwreq_data.
6354 * @extra: Pointer to the data.
6355 *
6356 * Return: 0 for success, error number on failure.
6357 */
6358int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6359 union iwreq_data *wrqu, char *extra)
6360{
6361 int ret;
6362
6363 cds_ssr_protect(__func__);
6364 ret = __iw_set_auth(dev, info, wrqu, extra);
6365 cds_ssr_unprotect(__func__);
6366
6367 return ret;
6368}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006369/**
6370 * __iw_get_auth() -
6371 * This function returns the auth type to the wpa_supplicant
6372 * @dev: pointer to the net device
6373 * @info: pointer to the iw request info
6374 * @wrqu: pointer to iwreq_data
6375 * @extra: pointer to the data
6376 *
6377 * Return: 0 on success, error number otherwise
6378 */
6379static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6380 union iwreq_data *wrqu, char *extra)
6381{
6382 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6383 hdd_context_t *hdd_ctx;
6384 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6385 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6386 int ret;
6387
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006388 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006389
6390 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6391 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306392 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006393 return ret;
6394
Jeff Johnson441e1f72017-02-07 08:50:49 -08006395 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6396 if (0 != ret)
6397 return ret;
6398
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006399 switch (pRoamProfile->negotiatedAuthType) {
6400 case eCSR_AUTH_TYPE_WPA_NONE:
6401 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6402 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6403 break;
6404 case eCSR_AUTH_TYPE_WPA:
6405 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6406 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6407 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006408
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006409 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006410 case eCSR_AUTH_TYPE_RSN:
6411 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6412 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6413 break;
6414 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6415 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6416 break;
6417 case eCSR_AUTH_TYPE_SHARED_KEY:
6418 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6419 break;
6420 case eCSR_AUTH_TYPE_UNKNOWN:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006421 hdd_debug("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006422 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6423 break;
6424 case eCSR_AUTH_TYPE_AUTOSWITCH:
6425 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6426 break;
6427 case eCSR_AUTH_TYPE_WPA_PSK:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006428 hdd_debug("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006429 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6430 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006431
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006432 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006433 case eCSR_AUTH_TYPE_RSN_PSK:
6434#ifdef WLAN_FEATURE_11W
6435 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6436 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6437#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006438 hdd_debug("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006439 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6440 return -EIO;
6441 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006442 hdd_warn("Unknown auth type: %d",
6443 pRoamProfile->negotiatedAuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006444 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6445 return -EIO;
6446 }
6447 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6448 switch (pRoamProfile->negotiatedUCEncryptionType) {
6449 case eCSR_ENCRYPT_TYPE_NONE:
6450 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6451 break;
6452 case eCSR_ENCRYPT_TYPE_WEP40:
6453 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6454 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6455 break;
6456 case eCSR_ENCRYPT_TYPE_TKIP:
6457 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6458 break;
6459 case eCSR_ENCRYPT_TYPE_WEP104:
6460 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6461 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6462 break;
6463 case eCSR_ENCRYPT_TYPE_AES:
6464 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6465 break;
6466 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006467 hdd_warn("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006468 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006469 return -EIO;
6470 }
6471 }
6472
6473 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6474 switch (pRoamProfile->negotiatedMCEncryptionType) {
6475 case eCSR_ENCRYPT_TYPE_NONE:
6476 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6477 break;
6478 case eCSR_ENCRYPT_TYPE_WEP40:
6479 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6480 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6481 break;
6482 case eCSR_ENCRYPT_TYPE_TKIP:
6483 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6484 break;
6485 case eCSR_ENCRYPT_TYPE_WEP104:
6486 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6487 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6488 break;
6489 case eCSR_ENCRYPT_TYPE_AES:
6490 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6491 break;
6492 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006493 hdd_err("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006494 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006495 return -EIO;
6496 }
6497 }
6498
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006499 hdd_debug("called with auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006500 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006501 EXIT();
6502 return 0;
6503}
6504
6505/**
6506 * iw_get_auth() - get auth callback function
6507 * @dev: Pointer to the net device.
6508 * @info: Pointer to the iw_request_info.
6509 * @wrqu: Pointer to the iwreq_data.
6510 * @extra: Pointer to the data.
6511 *
6512 * Return: 0 for success, error number on failure.
6513 */
6514int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6515 union iwreq_data *wrqu, char *extra)
6516{
6517 int ret;
6518
6519 cds_ssr_protect(__func__);
6520 ret = __iw_get_auth(dev, info, wrqu, extra);
6521 cds_ssr_unprotect(__func__);
6522
6523 return ret;
6524}
6525
6526/**
6527 * __iw_set_ap_address() - set ap address
6528 * @dev: pointer to the net device
6529 * @info: pointer to the iw request info
6530 * @wrqu: pointer to iwreq_data
6531 * @extra: pointer to the data
6532 *
6533 * This function updates the HDD global station context connection info
6534 * BSSID with the MAC address received from the wpa_supplicant.
6535 *
6536 * Return: 0 on success, error number otherwise
6537 */
6538static int __iw_set_ap_address(struct net_device *dev,
6539 struct iw_request_info *info,
6540 union iwreq_data *wrqu, char *extra)
6541{
6542
6543 hdd_adapter_t *adapter;
6544 hdd_context_t *hdd_ctx;
6545 hdd_station_ctx_t *pHddStaCtx =
6546 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6547 uint8_t *pMacAddress = NULL;
6548 int ret;
6549
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006550 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006551
6552 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6553
6554 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6555 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306556 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006557 return ret;
6558
Jeff Johnson441e1f72017-02-07 08:50:49 -08006559 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6560 if (0 != ret)
6561 return ret;
6562
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006563 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006564 hdd_debug(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306565 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306566 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006567 EXIT();
6568
6569 return 0;
6570}
6571
6572/**
6573 * iw_set_ap_address() - set ap addresses callback function
6574 * @dev: Pointer to the net device.
6575 * @info: Pointer to the iw_request_info.
6576 * @wrqu: Pointer to the iwreq_data.
6577 * @extra: Pointer to the data.
6578 *
6579 * Return: 0 for success, error number on failure.
6580 */
6581int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6582 union iwreq_data *wrqu, char *extra)
6583{
6584 int ret;
6585
6586 cds_ssr_protect(__func__);
6587 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6588 cds_ssr_unprotect(__func__);
6589
6590 return ret;
6591}
6592
6593/**
6594 * __iw_get_ap_address() - get ap address
6595 * @dev: pointer to the net device
6596 * @info: pointer to the iw request info
6597 * @wrqu: pointer to iwreq_data
6598 * @extra: pointer to the data
6599 *
6600 * This function returns currently associated BSSID.
6601 *
6602 * Return: 0 on success, error number otherwise
6603 */
6604static int __iw_get_ap_address(struct net_device *dev,
6605 struct iw_request_info *info,
6606 union iwreq_data *wrqu, char *extra)
6607{
6608 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6609 hdd_context_t *hdd_ctx;
6610 hdd_station_ctx_t *pHddStaCtx =
6611 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6612 int ret;
6613
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006614 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006615
6616 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6617 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306618 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006619 return ret;
6620
Jeff Johnson441e1f72017-02-07 08:50:49 -08006621 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6622 if (0 != ret)
6623 return ret;
6624
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006625 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6626 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306627 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006628 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306629 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006630 } else {
6631 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6632 }
6633 EXIT();
6634 return 0;
6635}
6636
6637/**
6638 * iw_get_ap_address() - get ap addresses callback function
6639 * @dev: Pointer to the net device.
6640 * @info: Pointer to the iw_request_info.
6641 * @wrqu: Pointer to the iwreq_data.
6642 * @extra: Pointer to the data.
6643 *
6644 * Return: 0 for success, error number on failure.
6645 */
6646int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6647 union iwreq_data *wrqu, char *extra)
6648{
6649 int ret;
6650
6651 cds_ssr_protect(__func__);
6652 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6653 cds_ssr_unprotect(__func__);
6654
6655 return ret;
6656}