blob: 73195c10b13782db2ff8185d5f4b5a646ebc9bb2 [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
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800112/* Offset where the EID-Len-IE, start. */
113#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
114#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800115
116#define BEACON_FRAME_IES_OFFSET 12
117#define HDD_PEER_AUTHORIZE_WAIT 10
118
119/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700120 * beacon_filter_table - table of IEs used for beacon filtering
121 */
122static const int beacon_filter_table[] = {
123 SIR_MAC_DS_PARAM_SET_EID,
124 SIR_MAC_ERP_INFO_EID,
125 SIR_MAC_EDCA_PARAM_SET_EID,
126 SIR_MAC_QOS_CAPABILITY_EID,
127 SIR_MAC_HT_INFO_EID,
128 SIR_MAC_VHT_OPMODE_EID,
129 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700130#ifdef WLAN_FEATURE_11AX_BSS_COLOR
131 /*
132 * EID: 221 vendor IE is being used temporarily by 11AX
133 * bss-color-change IE till it gets any fixed number. This
134 * vendor EID needs to be replaced with bss-color-change IE
135 * number.
136 */
137 SIR_MAC_EID_VENDOR,
138#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700139};
140
141/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800142 * hdd_conn_set_authenticated() - set authentication state
143 * @pAdapter: pointer to the adapter
144 * @authState: authentication state
145 *
146 * This function updates the global HDD station context
147 * authentication state.
148 *
149 * Return: none
150 */
151static void
152hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
153{
154 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
155 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
156
157 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700158 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700159 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800160 pHddStaCtx->conn_info.uIsAuthenticated = authState;
161
162 /* Check is pending ROC request or not when auth state changed */
163 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
164}
165
166/**
167 * hdd_conn_set_connection_state() - set connection state
168 * @pAdapter: pointer to the adapter
169 * @connState: connection state
170 *
171 * This function updates the global HDD station context connection state.
172 *
173 * Return: none
174 */
175void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
176 eConnectionState connState)
177{
178 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
179 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
180
181 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700182 hdd_debug("%pS Changed connectionState Changed from oldState:%d to State:%d",
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530183 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
184 connState);
Yu Wang000dc2f2017-05-26 17:38:48 +0800185
186 hdd_tsf_notify_wlan_state_change(pAdapter,
187 pHddStaCtx->conn_info.connState,
188 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800189 pHddStaCtx->conn_info.connState = connState;
190
191 /* Check is pending ROC request or not when connection state changed */
192 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
193}
194
195/**
196 * hdd_conn_get_connection_state() - get connection state
197 * @pAdapter: pointer to the adapter
198 * @pConnState: pointer to connection state
199 *
200 * This function updates the global HDD station context connection state.
201 *
202 * Return: true if (Infra Associated or IBSS Connected)
203 * and sets output parameter pConnState;
204 * false otherwise
205 */
206static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
207 eConnectionState *pConnState)
208{
209 bool fConnected = false;
210 eConnectionState connState;
211
212 /* get the connection state. */
213 connState = pHddStaCtx->conn_info.connState;
214
215 if (eConnectionState_Associated == connState ||
216 eConnectionState_IbssConnected == connState ||
217 eConnectionState_IbssDisconnected == connState) {
218 fConnected = true;
219 }
220
221 if (pConnState)
222 *pConnState = connState;
223
224 return fConnected;
225}
226
227/**
228 * hdd_is_connecting() - Function to check connection progress
229 * @hdd_sta_ctx: pointer to global HDD Station context
230 *
231 * Return: true if connecting, false otherwise
232 */
233bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
234{
235 return hdd_sta_ctx->conn_info.connState ==
236 eConnectionState_Connecting;
237}
238
239/**
240 * hdd_conn_is_connected() - Function to check connection status
241 * @pHddStaCtx: pointer to global HDD Station context
242 *
243 * Return: false if any errors encountered, true otherwise
244 */
245bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
246{
247 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
248}
249
250/**
251 * hdd_conn_get_connected_band() - get current connection radio band
252 * @pHddStaCtx: pointer to global HDD Station context
253 *
254 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
255 * eCSR_BAND_ALL if not connected
256 */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700257enum band_info hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800258{
259 uint8_t staChannel = 0;
260
261 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
262 staChannel = pHddStaCtx->conn_info.operationChannel;
263
264 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700265 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800266 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700267 return BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800268 else /* If station is not connected return as eCSR_BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700269 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800270}
271
272/**
273 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
274 * @pHddStaCtx: pointer to global HDD Station context
275 * @pConnectedCipherAlgo: pointer to connected cipher algo
276 *
277 * Return: false if any errors encountered, true otherwise
278 */
279static inline bool
280hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
281 eCsrEncryptionType *pConnectedCipherAlgo)
282{
283 bool fConnected = false;
284
285 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
286
287 if (pConnectedCipherAlgo)
288 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
289
290 return fConnected;
291}
292
293/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700294 * hdd_remove_beacon_filter() - remove beacon filter
295 * @adapter: Pointer to the hdd adapter
296 *
297 * Return: 0 on success and errno on failure
298 */
299static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
300{
301 QDF_STATUS status;
302 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
303
304 status = sme_remove_beacon_filter(hdd_ctx->hHal,
305 adapter->sessionId);
306 if (!QDF_IS_STATUS_SUCCESS(status)) {
307 hdd_err("sme_remove_beacon_filter() failed");
308 return -EFAULT;
309 }
310
311 return 0;
312}
313
314/**
315 * hdd_add_beacon_filter() - add beacon filter
316 * @adapter: Pointer to the hdd adapter
317 *
318 * Return: 0 on success and errno on failure
319 */
320static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
321{
322 int i;
323 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
324 QDF_STATUS status;
325 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
326
327 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530328 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700329 (unsigned long int *)ie_map);
330
331 status = sme_add_beacon_filter(hdd_ctx->hHal,
332 adapter->sessionId, ie_map);
333 if (!QDF_IS_STATUS_SUCCESS(status)) {
334 hdd_err("sme_add_beacon_filter() failed");
335 return -EFAULT;
336 }
337 return 0;
338}
339
340/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530341 * hdd_copy_vht_caps()- copy vht caps info from roam info to
342 * hdd station context.
343 * @hdd_sta_ctx: pointer to hdd station context
344 * @roam_info: pointer to roam info
345 *
346 * Return: None
347 */
348static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
349 tCsrRoamInfo *roam_info)
350{
351 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
352 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
353 uint32_t i, temp_ht_cap;
354
355 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
356
357 if (roam_ht_cap->advCodingCap)
358 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
359 if (roam_ht_cap->supportedChannelWidthSet)
360 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
361 temp_ht_cap = roam_ht_cap->mimoPowerSave &
362 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
363 if (temp_ht_cap)
364 hdd_ht_cap->cap_info |=
365 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
366 if (roam_ht_cap->greenField)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
368 if (roam_ht_cap->shortGI20MHz)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
370 if (roam_ht_cap->shortGI40MHz)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
372 if (roam_ht_cap->txSTBC)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
374 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
375 IEEE80211_HT_CAP_RX_STBC_SHIFT);
376 if (temp_ht_cap)
377 hdd_ht_cap->cap_info |=
378 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
379 if (roam_ht_cap->delayedBA)
380 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
381 if (roam_ht_cap->maximalAMSDUsize)
382 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
383 if (roam_ht_cap->dsssCckMode40MHz)
384 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
385 if (roam_ht_cap->psmp)
386 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
387 if (roam_ht_cap->stbcControlFrame)
388 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
389 if (roam_ht_cap->lsigTXOPProtection)
390 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
391
392 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
393 if (roam_ht_cap->maxRxAMPDUFactor)
394 hdd_ht_cap->ampdu_params_info |=
395 IEEE80211_HT_AMPDU_PARM_FACTOR;
396 temp_ht_cap = roam_ht_cap->mpduDensity &
397 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
398 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
399 if (temp_ht_cap)
400 hdd_ht_cap->ampdu_params_info |=
401 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
402
403 /* 802.11n HT extended capabilities masks */
404 if (roam_ht_cap->pco)
405 hdd_ht_cap->extended_ht_cap_info |=
406 IEEE80211_HT_EXT_CAP_PCO;
407 temp_ht_cap = roam_ht_cap->transitionTime &
408 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
409 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
410 if (temp_ht_cap)
411 hdd_ht_cap->extended_ht_cap_info |=
412 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
413 temp_ht_cap = roam_ht_cap->mcsFeedback &
414 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
415 if (temp_ht_cap)
416 hdd_ht_cap->extended_ht_cap_info |=
417 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
418
419 /* tx_bf_cap_info capabilities */
420 if (roam_ht_cap->txBF)
421 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
422 if (roam_ht_cap->rxStaggeredSounding)
423 hdd_ht_cap->tx_BF_cap_info |=
424 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
425 if (roam_ht_cap->txStaggeredSounding)
426 hdd_ht_cap->tx_BF_cap_info |=
427 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
428 if (roam_ht_cap->rxZLF)
429 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
430 if (roam_ht_cap->txZLF)
431 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
432 if (roam_ht_cap->implicitTxBF)
433 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
434 temp_ht_cap = roam_ht_cap->calibration &
435 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
436 if (temp_ht_cap)
437 hdd_ht_cap->tx_BF_cap_info |=
438 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
439 if (roam_ht_cap->explicitCSITxBF)
440 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
441 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
442 hdd_ht_cap->tx_BF_cap_info |=
443 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
444 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
445 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
446 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
447 if (temp_ht_cap)
448 hdd_ht_cap->tx_BF_cap_info |=
449 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
450 temp_ht_cap =
451 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
452 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
453 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->tx_BF_cap_info |=
456 temp_ht_cap <<
457 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
458 temp_ht_cap =
459 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
460 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
461 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
462 if (temp_ht_cap)
463 hdd_ht_cap->tx_BF_cap_info |=
464 temp_ht_cap <<
465 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
466 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
467 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
468 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
469 if (temp_ht_cap)
470 hdd_ht_cap->tx_BF_cap_info |=
471 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
472 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
473 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
474 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
475 if (temp_ht_cap)
476 hdd_ht_cap->tx_BF_cap_info |=
477 temp_ht_cap <<
478 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
479 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
480 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
481 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
482 if (temp_ht_cap)
483 hdd_ht_cap->tx_BF_cap_info |=
484 temp_ht_cap <<
485 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
486
487 /* antenna selection */
488 if (roam_ht_cap->antennaSelection)
489 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
490 if (roam_ht_cap->explicitCSIFeedbackTx)
491 hdd_ht_cap->antenna_selection_info |=
492 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
493 if (roam_ht_cap->antennaIndicesFeedbackTx)
494 hdd_ht_cap->antenna_selection_info |=
495 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
496 if (roam_ht_cap->explicitCSIFeedback)
497 hdd_ht_cap->antenna_selection_info |=
498 ANTENNA_SEL_INFO_EXP_CSI_FB;
499 if (roam_ht_cap->antennaIndicesFeedback)
500 hdd_ht_cap->antenna_selection_info |=
501 ANTENNA_SEL_INFO_ANT_ID_FB;
502 if (roam_ht_cap->rxAS)
503 hdd_ht_cap->antenna_selection_info |=
504 ANTENNA_SEL_INFO_RX_AS;
505 if (roam_ht_cap->txSoundingPPDUs)
506 hdd_ht_cap->antenna_selection_info |=
507 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
508
509 /* mcs data rate */
510 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
511 hdd_ht_cap->mcs.rx_mask[i] =
512 roam_ht_cap->supportedMCSSet[i];
513 hdd_ht_cap->mcs.rx_highest =
514 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
515 ((short) (roam_ht_cap->supportedMCSSet[10]));
516 hdd_ht_cap->mcs.tx_params =
517 roam_ht_cap->supportedMCSSet[12];
518}
519
520#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
521#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
522#define VHT_CAP_RXSTBC_MASK_SHIFT 8
523#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
524#define VHT_CAP_BEAMFORMEE_STS_MASK \
525 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
526#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
527#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
528 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
529#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
530#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
531 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
532#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
533
534/**
535 * hdd_copy_ht_caps()- copy ht caps info from roam info to
536 * hdd station context.
537 * @hdd_sta_ctx: pointer to hdd station context
538 * @roam_info: pointer to roam info
539 *
540 * Return: None
541 */
542static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
543 tCsrRoamInfo *roam_info)
544{
545 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
546 struct ieee80211_vht_cap *hdd_vht_cap =
547 &hdd_sta_ctx->conn_info.vht_caps;
548 uint32_t temp_vht_cap;
549
550 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
551
552 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
553 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
554 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
555 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
556 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
557 if (temp_vht_cap)
558 if (roam_vht_cap->supportedChannelWidthSet &
559 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
560 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
561 hdd_vht_cap->vht_cap_info |=
562 temp_vht_cap <<
563 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
564 if (roam_vht_cap->supportedChannelWidthSet &
565 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
566 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
567 hdd_vht_cap->vht_cap_info |=
568 temp_vht_cap <<
569 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
570 if (roam_vht_cap->ldpcCodingCap)
571 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
572 if (roam_vht_cap->shortGI80MHz)
573 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
574 if (roam_vht_cap->shortGI160and80plus80MHz)
575 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
576 if (roam_vht_cap->txSTBC)
577 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
578 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
579 VHT_CAP_RXSTBC_MASK_SHIFT);
580 if (temp_vht_cap)
581 hdd_vht_cap->vht_cap_info |=
582 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
583 if (roam_vht_cap->suBeamFormerCap)
584 hdd_vht_cap->vht_cap_info |=
585 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
586 if (roam_vht_cap->suBeamformeeCap)
587 hdd_vht_cap->vht_cap_info |=
588 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
589 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
590 (VHT_CAP_BEAMFORMEE_STS_MASK);
591 if (temp_vht_cap)
592 hdd_vht_cap->vht_cap_info |=
593 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
594 temp_vht_cap = roam_vht_cap->numSoundingDim &
595 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
596 if (temp_vht_cap)
597 hdd_vht_cap->vht_cap_info |=
598 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
599 if (roam_vht_cap->muBeamformerCap)
600 hdd_vht_cap->vht_cap_info |=
601 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
602 if (roam_vht_cap->muBeamformeeCap)
603 hdd_vht_cap->vht_cap_info |=
604 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
605 if (roam_vht_cap->vhtTXOPPS)
606 hdd_vht_cap->vht_cap_info |=
607 IEEE80211_VHT_CAP_VHT_TXOP_PS;
608 if (roam_vht_cap->htcVHTCap)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_HTC_VHT;
611 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
612 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
613 if (temp_vht_cap)
614 hdd_vht_cap->vht_cap_info |=
615 temp_vht_cap <<
616 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
617 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
618 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
619 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
620 if (temp_vht_cap)
621 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
622 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
623 if (roam_vht_cap->rxAntPattern)
624 hdd_vht_cap->vht_cap_info |=
625 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
626 if (roam_vht_cap->txAntPattern)
627 hdd_vht_cap->vht_cap_info |=
628 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
629 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
630 hdd_vht_cap->supp_mcs.rx_highest =
631 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
632 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
633 hdd_vht_cap->supp_mcs.tx_highest =
634 ((uint16_t)roam_vht_cap->txSupDataRate);
635}
636
637/* ht param */
638#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
639#define HT_PARAM_SERVICE_INT_GRAN 0xe0
640#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
641
642/* operatinon mode */
643#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
644
645/* stbc_param */
646#define HT_STBC_PARAM_MCS 0x007f
647
648/**
649 * hdd_copy_ht_operation()- copy HT operation element from roam info to
650 * hdd station context.
651 * @hdd_sta_ctx: pointer to hdd station context
652 * @roam_info: pointer to roam info
653 *
654 * Return: None
655 */
656static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
657 tCsrRoamInfo *roam_info)
658{
659 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
660 struct ieee80211_ht_operation *hdd_ht_ops =
661 &hdd_sta_ctx->conn_info.ht_operation;
662 uint32_t i, temp_ht_ops;
663
664 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
665
666 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
667
668 /* HT_PARAMS */
669 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
670 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
671 if (temp_ht_ops)
672 hdd_ht_ops->ht_param |= temp_ht_ops;
673 else
674 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
675 if (roam_ht_ops->recommendedTxWidthSet)
676 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
677 if (roam_ht_ops->rifsMode)
678 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
679 if (roam_ht_ops->controlledAccessOnly)
680 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
681 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
682 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
683 if (temp_ht_ops)
684 hdd_ht_ops->ht_param |= temp_ht_ops <<
685 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
686
687 /* operation mode */
688 temp_ht_ops = roam_ht_ops->opMode &
689 IEEE80211_HT_OP_MODE_PROTECTION;
690 switch (temp_ht_ops) {
691 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
692 hdd_ht_ops->operation_mode |=
693 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
694 break;
695 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
696 hdd_ht_ops->operation_mode |=
697 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
698 break;
699 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
702 break;
703 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
704 default:
705 hdd_ht_ops->operation_mode |=
706 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
707 }
708 if (roam_ht_ops->nonGFDevicesPresent)
709 hdd_ht_ops->operation_mode |=
710 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
711 if (roam_ht_ops->transmitBurstLimit)
712 hdd_ht_ops->operation_mode |=
713 HT_OP_MODE_TX_BURST_LIMIT;
714 if (roam_ht_ops->obssNonHTStaPresent)
715 hdd_ht_ops->operation_mode |=
716 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
717
718 /* stbc_param */
719 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
720 HT_STBC_PARAM_MCS;
721 if (temp_ht_ops)
722 hdd_ht_ops->stbc_param |= temp_ht_ops;
723 if (roam_ht_ops->dualCTSProtection)
724 hdd_ht_ops->stbc_param |=
725 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
726 if (roam_ht_ops->secondaryBeacon)
727 hdd_ht_ops->stbc_param |=
728 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
729 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
730 hdd_ht_ops->stbc_param |=
731 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
732 if (roam_ht_ops->pcoActive)
733 hdd_ht_ops->stbc_param |=
734 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
735 if (roam_ht_ops->pcoPhase)
736 hdd_ht_ops->stbc_param |=
737 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
738
739 /* basic MCs set */
740 for (i = 0; i < 16; ++i)
741 hdd_ht_ops->basic_set[i] =
742 roam_ht_ops->basicMCSSet[i];
743}
744
745/**
746 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
747 * hdd station context.
748 * @hdd_sta_ctx: pointer to hdd station context
749 * @roam_info: pointer to roam info
750 *
751 * Return: None
752 */
753static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
754 tCsrRoamInfo *roam_info)
755{
756 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
757 struct ieee80211_vht_operation *hdd_vht_ops =
758 &hdd_sta_ctx->conn_info.vht_operation;
759
760 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
761
762 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
763 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
764 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
765 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
766}
767
768
769/**
770 * hdd_save_bss_info() - save connection info in hdd sta ctx
771 * @adapter: Pointer to adapter
772 * @roam_info: pointer to roam info
773 *
774 * Return: None
775 */
776static void hdd_save_bss_info(hdd_adapter_t *adapter,
777 tCsrRoamInfo *roam_info)
778{
779 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
780
781 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
782 hdd_sta_ctx->conn_info.operationChannel);
783 if (roam_info->vht_caps.present) {
784 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
785 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
786 } else {
787 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
788 }
789 if (roam_info->ht_caps.present) {
790 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
791 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
792 } else {
793 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
794 }
795 if (roam_info->reassoc)
796 hdd_sta_ctx->conn_info.roam_count++;
797 if (roam_info->hs20vendor_ie.present) {
798 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
799 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
800 &roam_info->hs20vendor_ie,
801 sizeof(roam_info->hs20vendor_ie));
802 } else {
803 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
804 }
805 if (roam_info->ht_operation.present) {
806 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
807 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
808 } else {
809 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
810 }
811 if (roam_info->vht_operation.present) {
812 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
813 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
814 } else {
815 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
816 }
817}
818
819/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820 * hdd_conn_save_connect_info() - save current connection information
821 * @pAdapter: pointer to adapter
822 * @pRoamInfo: pointer to roam info
823 * @eBssType: bss type
824 *
825 * Return: none
826 */
827static void
828hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
829 eCsrRoamBssType eBssType)
830{
831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
832 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
833
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530834 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800835
836 if (pRoamInfo) {
837 /* Save the BSSID for the connection */
838 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530839 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530840 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841 &pRoamInfo->bssid);
842
843 /*
844 * Save the Station ID for this station from
845 * the 'Roam Info'. For IBSS mode, staId is
846 * assigned in NEW_PEER_IND. For reassoc,
847 * the staID doesn't change and it may be invalid
848 * in this structure so no change here.
849 */
850 if (!pRoamInfo->fReassocReq) {
851 pHddStaCtx->conn_info.staId[0] =
852 pRoamInfo->staId;
853 }
854 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530855 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800856 &pRoamInfo->bssid);
857 } else {
858 /*
859 * can't happen. We need a valid IBSS or Infra setting
860 * in the BSSDescription or we can't function.
861 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530862 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800863 }
864
865 /* notify WMM */
866 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
867
868 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530869 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 } else {
871 /* Get Multicast Encryption Type */
872 encryptType =
873 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
874 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
875 /* Get Unicast Encryption Type */
876 encryptType =
877 pRoamInfo->u.pConnectedProfile->EncryptionType;
878 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
879
880 pHddStaCtx->conn_info.authType =
881 pRoamInfo->u.pConnectedProfile->AuthType;
882
883 pHddStaCtx->conn_info.operationChannel =
884 pRoamInfo->u.pConnectedProfile->operationChannel;
885
886 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530887 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888 &pRoamInfo->u.pConnectedProfile->SSID,
889 sizeof(tSirMacSSid));
890
891 /* Save dot11mode in which STA associated to AP */
892 pHddStaCtx->conn_info.dot11Mode =
893 pRoamInfo->u.pConnectedProfile->dot11Mode;
894
895 pHddStaCtx->conn_info.proxyARPService =
896 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530897
898 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
899
900 pHddStaCtx->conn_info.rate_flags =
901 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800902 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530903 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800904 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905}
906
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800907/**
908 * hdd_send_ft_assoc_response() - send fast transition assoc response
909 * @dev: pointer to net device
910 * @pAdapter: pointer to adapter
911 * @pCsrRoamInfo: pointer to roam info
912 *
913 * Send the 11R key information to the supplicant. Only then can the supplicant
914 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
915 * for the same purpose.)
916 *
917 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
918 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
919 * This is the Assoc Response.
920 *
921 * Return: none
922 */
923static void
924hdd_send_ft_assoc_response(struct net_device *dev,
925 hdd_adapter_t *pAdapter,
926 tCsrRoamInfo *pCsrRoamInfo)
927{
928 union iwreq_data wrqu;
929 char *buff;
930 unsigned int len = 0;
931 u8 *pFTAssocRsp = NULL;
932
933 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700934 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800935 return;
936 }
937
938 pFTAssocRsp =
939 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
940 pCsrRoamInfo->nAssocReqLength);
941 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700942 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800943 return;
944 }
945 /* pFTAssocRsp needs to point to the IEs */
946 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700947 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700948 (unsigned int)pFTAssocRsp[0],
949 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950
951 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700952 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800953 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700954 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800955 return;
956 }
957 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
958 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
959 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800960 memcpy(buff, pFTAssocRsp, len);
961 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
962
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700963 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800965
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966/**
967 * hdd_send_ft_event() - send fast transition event
968 * @pAdapter: pointer to adapter
969 *
970 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
971 * FT events to the supplicant. At the reception of Auth2 we send the RIC
972 * followed by the auth response IEs to the supplicant.
973 * Once both are received in the supplicant, an FT event is generated
974 * to the supplicant.
975 *
976 * Return: none
977 */
978static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
979{
980 uint16_t auth_resp_len = 0;
981 uint32_t ric_ies_length = 0;
982 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
983
984#if defined(KERNEL_SUPPORT_11R_CFG80211)
985 struct cfg80211_ft_event_params ftEvent;
986 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
987 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
988 struct net_device *dev = pAdapter->dev;
989#else
990 char *buff;
991 union iwreq_data wrqu;
992 uint16_t str_len;
993#endif
994
995#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530996 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
997 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800998
999 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
1000 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001001 if (ric_ies_length == 0)
1002 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001003
1004 ftEvent.ric_ies = ricIe;
1005 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001006 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001007
1008 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1009 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1010 &auth_resp_len);
1011
1012 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001013 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 return;
1015 }
1016
1017 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1018
1019 ftEvent.target_ap = ftIe;
1020
Anurag Chouhan6d760662016-02-20 16:05:43 +05301021 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1022 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001024 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1025 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1026 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027 ftEvent.target_ap[0], ftEvent.target_ap[1],
1028 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1029 ftEvent.target_ap[5]);
1030
1031 (void)cfg80211_ft_event(dev, &ftEvent);
1032
1033#else
1034 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001035 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001036 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001037 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 return;
1039 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040
1041 /* Sme needs to send the RIC IEs first */
1042 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1043 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1044 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1045 &ric_ies_length);
1046 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001047 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 } else {
1049 wrqu.data.length = str_len + ric_ies_length;
1050 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1051 }
1052
1053 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301054 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1056 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1057 (u8 *) &buff[str_len],
1058 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1059
1060 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001061 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001062 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001063 return;
1064 }
1065
1066 wrqu.data.length = str_len + auth_resp_len;
1067 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1068
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001069 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001070#endif
1071}
1072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001073#ifdef FEATURE_WLAN_ESE
1074/**
1075 * hdd_send_new_ap_channel_info() - send new ap channel info
1076 * @dev: pointer to net device
1077 * @pAdapter: pointer to adapter
1078 * @pCsrRoamInfo: pointer to roam info
1079 *
1080 * Send the ESE required "new AP Channel info" to the supplicant.
1081 * (This keeps the supplicant "up to date" on the current channel.)
1082 *
1083 * The current (new AP) channel information is passed in.
1084 *
1085 * Return: none
1086 */
1087static void
1088hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1089 tCsrRoamInfo *pCsrRoamInfo)
1090{
1091 union iwreq_data wrqu;
1092 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1093
1094 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001095 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001096 return;
1097 }
1098 /*
1099 * Send the Channel event, the supplicant needs this to generate
1100 * the Adjacent AP report.
1101 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001102 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001103 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001104 memset(&wrqu, '\0', sizeof(wrqu));
1105 wrqu.freq.m = descriptor->channelId;
1106 wrqu.freq.e = 0;
1107 wrqu.freq.i = 0;
1108 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1109}
1110
1111#endif /* FEATURE_WLAN_ESE */
1112
1113/**
1114 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1115 * @pAdapter: pointer to adapter
1116 * @pCsrRoamInfo: pointer to roam info
1117 *
1118 * Return: none
1119 */
1120static void
1121hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1122 tCsrRoamInfo *pCsrRoamInfo)
1123{
1124 union iwreq_data wrqu;
1125 u8 *pBeaconIes;
1126 u8 currentLen = 0;
1127 char *buff;
1128 int totalIeLen = 0, currentOffset = 0, strLen;
1129
1130 memset(&wrqu, '\0', sizeof(wrqu));
1131
1132 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001133 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134 return;
1135 }
1136 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1137 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001138 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 return;
1140 }
1141 /* pBeaconIes needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001142 hdd_debug("Beacon IEs is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001143 (unsigned int)pBeaconIes[0],
1144 (unsigned int)pBeaconIes[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001145 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001146 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147
1148 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001149 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001151 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001152 return;
1153 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154
1155 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1156 currentLen = strLen + 1;
1157
1158 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1159 do {
1160 /*
1161 * If the beacon size exceeds max CUSTOM event size, break it
1162 * into chunks of CUSTOM event max size and send it to
1163 * supplicant. Changes are done in supplicant to handle this.
1164 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301165 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001166 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301167 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301168 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169 currentLen);
1170 currentOffset += currentLen;
1171 totalIeLen -= currentLen;
1172 wrqu.data.length = strLen + 1 + currentLen;
1173 if (totalIeLen)
1174 buff[strLen] = 1; /* more chunks pending */
1175 else
1176 buff[strLen] = 0; /* last chunk */
1177
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001178 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001179 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1181 } while (totalIeLen > 0);
1182
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001183 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184}
1185
1186/**
1187 * hdd_send_association_event() - send association event
1188 * @dev: pointer to net device
1189 * @pCsrRoamInfo: pointer to roam info
1190 *
1191 * Return: none
1192 */
1193static void hdd_send_association_event(struct net_device *dev,
1194 tCsrRoamInfo *pCsrRoamInfo)
1195{
Rajeev Kumar78427682017-01-13 16:13:11 -08001196 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1199 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1200 union iwreq_data wrqu;
1201 int we_event;
1202 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301203 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001204
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205 /* Added to find the auth type on the fly at run time */
1206 /* rather than with cfg to see if FT is enabled */
1207 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1208 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209
1210 memset(&wrqu, '\0', sizeof(wrqu));
1211 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1212 we_event = SIOCGIWAP;
1213#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1214 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301215 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001217 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301218 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001219 hdd_notify_sta_disconnect(pAdapter->sessionId,
1220 true, pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301221 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301222 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223#endif
1224 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001225 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301226
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001228 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001229 return;
1230 }
1231
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001232 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001233 policy_mgr_incr_active_session(pHddCtx->hdd_psoc,
1234 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1236 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1237
1238#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001239 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 if (global_p2p_connection_status ==
1241 P2P_CLIENT_CONNECTING_STATE_1) {
1242 global_p2p_connection_status =
1243 P2P_CLIENT_CONNECTED_STATE_1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001244 hdd_debug("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001245 } else if (global_p2p_connection_status ==
1246 P2P_CLIENT_CONNECTING_STATE_2) {
1247 global_p2p_connection_status =
1248 P2P_CLIENT_COMPLETED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001249 hdd_debug("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 }
1251 }
1252#endif
1253 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1254 MAC_ADDRESS_STR "\n",
1255 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1256 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1257 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1258
1259 /*
1260 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1261 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001262 * fFTEnable is true.
1263 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001264 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 if ((pRoamProfile->AuthType.authType[0] ==
1266 eCSR_AUTH_TYPE_FT_RSN_PSK)
1267 || (pRoamProfile->AuthType.authType[0] ==
1268 eCSR_AUTH_TYPE_FT_RSN)
1269#ifdef FEATURE_WLAN_ESE
1270 || (pRoamProfile->AuthType.authType[0] ==
1271 eCSR_AUTH_TYPE_CCKM_RSN)
1272 || (pRoamProfile->AuthType.authType[0] ==
1273 eCSR_AUTH_TYPE_CCKM_WPA)
1274#endif
1275 ) {
1276 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1277 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301278 qdf_copy_macaddr(&peerMacAddr,
1279 &pHddStaCtx->conn_info.bssId);
1280 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1281 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1282 chan_info.info = pCsrRoamInfo->chan_info.info;
1283 chan_info.band_center_freq1 =
1284 pCsrRoamInfo->chan_info.band_center_freq1;
1285 chan_info.band_center_freq2 =
1286 pCsrRoamInfo->chan_info.band_center_freq2;
1287 chan_info.reg_info_1 =
1288 pCsrRoamInfo->chan_info.reg_info_1;
1289 chan_info.reg_info_2 =
1290 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301291
Dustin Brown7d043f62017-03-27 12:07:36 -07001292 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1293 pAdapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301294 peerMacAddr.bytes,
1295 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001296 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301297 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1298 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001299 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1300 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301301 if (ret)
1302 hdd_err("Peer object %pM fail to set associated state",
1303 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301304
Abhishek Singh1c676222016-05-09 14:20:28 +05301305 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001306 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1307 ePeerConnected,
1308 pCsrRoamInfo->timingMeasCap,
1309 pAdapter->sessionId, &chan_info,
1310 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001311 /* Update tdls module about connection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001312 hdd_notify_sta_connect(pAdapter->sessionId,
1313 pCsrRoamInfo->tdls_chan_swit_prohibited,
1314 pCsrRoamInfo->tdls_prohibited,
1315 pAdapter->hdd_vdev);
1316
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001317 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001318
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001319
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001321#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 /* start timer in sta/p2p_cli */
1323 spin_lock_bh(&pHddCtx->bus_bw_lock);
1324 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1325 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001326 cdp_get_intra_bss_fwd_pkts_count(
1327 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301328 &pAdapter->prev_fwd_tx_packets,
1329 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001330 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001331 hdd_bus_bw_compute_timer_start(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332#endif
1333#endif
1334 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1335 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001336 policy_mgr_update_connection_info(pHddCtx->hdd_psoc,
1337 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001339 ETH_ALEN);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001340 hdd_info("wlan: new IBSS connection to " MAC_ADDRESS_STR,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001341 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301342
Dustin Brown7d043f62017-03-27 12:07:36 -07001343 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1344 QDF_IBSS_MODE,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301345 pCsrRoamInfo->bssid.bytes,
1346 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001347 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301348 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1349 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001350 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1351 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301352 if (ret)
1353 hdd_err("Peer object %pM fail to set associated state",
1354 peerMacAddr.bytes);
1355
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001356 } else { /* Not Associated */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001357 hdd_info("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001358 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001359 policy_mgr_decr_session_set_pcl(pHddCtx->hdd_psoc,
1360 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361
1362#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1363 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1364#endif
1365
Abhishek Singh1c676222016-05-09 14:20:28 +05301366 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1367 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301368 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 &pHddStaCtx->conn_info.bssId);
1370
1371 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001372 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301373 ePeerDisconnected, 0,
1374 pAdapter->sessionId,
1375 NULL,
1376 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301378
Dustin Brown7d043f62017-03-27 12:07:36 -07001379 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1380 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001381 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301382 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1383 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1384
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001385 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001386 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001387 hdd_notify_sta_disconnect(pAdapter->sessionId,
1388 false,
1389 pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301390 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001391
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001392#ifdef MSM_PLATFORM
1393 /* stop timer in sta/p2p_cli */
1394 spin_lock_bh(&pHddCtx->bus_bw_lock);
1395 pAdapter->prev_tx_packets = 0;
1396 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301397 pAdapter->prev_fwd_tx_packets = 0;
1398 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001399 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001400 hdd_bus_bw_compute_timer_try_stop(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401#endif
1402 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001403 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001404 /* Send SCC/MCC Switching event to IPA */
1405 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1406
1407 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001408 /* During the WLAN uninitialization,supplicant is stopped before the
1409 * driver so not sending the status of the connection to supplicant
1410 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001411 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 wireless_send_event(dev, we_event, &wrqu, msg);
1413#ifdef FEATURE_WLAN_ESE
1414 if (eConnectionState_Associated ==
1415 pHddStaCtx->conn_info.connState) {
1416 if ((pRoamProfile->AuthType.authType[0] ==
1417 eCSR_AUTH_TYPE_CCKM_RSN) ||
1418 (pRoamProfile->AuthType.authType[0] ==
1419 eCSR_AUTH_TYPE_CCKM_WPA))
1420 hdd_send_new_ap_channel_info(dev, pAdapter,
1421 pCsrRoamInfo);
1422 }
1423#endif
1424 }
1425}
1426
1427/**
1428 * hdd_conn_remove_connect_info() - remove connection info
1429 * @pHddStaCtx: pointer to global HDD station context
1430 * @pCsrRoamInfo: pointer to roam info
1431 *
1432 * Return: none
1433 */
1434static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1435{
1436 /* Remove staId, bssId and peerMacAddress */
1437 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301438 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1439 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301440 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441
1442 /* Clear all security settings */
1443 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1444 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1445 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1446
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301447 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1448 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001449
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001450 pHddStaCtx->conn_info.proxyARPService = 0;
1451
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301452 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453}
1454
1455/**
1456 * hdd_roam_deregister_sta() - deregister station
1457 * @pAdapter: pointer to adapter
1458 * @staId: station identifier
1459 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301460 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301462QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001463{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301464 QDF_STATUS qdf_status;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301465 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1466 int ret = 0;
1467 uint8_t *peer_mac = NULL;
1468 struct qdf_mac_addr broadcastMacAddr =
1469 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001470 if (eConnectionState_IbssDisconnected ==
1471 pHddStaCtx->conn_info.connState) {
1472 /*
1473 * Do not set the carrier off when the last peer leaves.
1474 * We will set the carrier off while stopping the IBSS.
1475 */
1476 }
1477
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001478 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001479 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301480 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301481 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301482 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1483 staid, qdf_status, qdf_status);
1484 }
1485
1486 if (adapter->device_mode == QDF_STA_MODE) {
1487 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1488 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1489 if (pHddStaCtx->broadcast_staid == staid)
1490 peer_mac = broadcastMacAddr.bytes;
1491 else
1492 peer_mac = pHddStaCtx->conn_info.
1493 peerMacAddress[staid].bytes;
1494 }
1495
Dustin Brown7d043f62017-03-27 12:07:36 -07001496 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301497 if (ret) {
1498 hdd_err("Peer obj %pM delete fails", peer_mac);
1499 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001500 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301501 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502}
1503
1504/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301505 * hdd_print_bss_info() - print bss info
1506 * @hdd_sta_ctx: pointer to hdd station context
1507 *
1508 * Return: None
1509 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001510static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301511{
1512 uint32_t *cap_info;
1513
1514 hdd_info("WIFI DATA LOGGER");
1515 hdd_info("channel: %d",
1516 hdd_sta_ctx->conn_info.freq);
1517 hdd_info("dot11mode: %d",
1518 hdd_sta_ctx->conn_info.dot11Mode);
1519 hdd_info("AKM: %d",
1520 hdd_sta_ctx->conn_info.authType);
1521 hdd_info("ssid: %.*s",
1522 hdd_sta_ctx->conn_info.SSID.SSID.length,
1523 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1524 hdd_info("roam count: %d",
1525 hdd_sta_ctx->conn_info.roam_count);
1526 hdd_info("ant_info: %d",
1527 hdd_sta_ctx->conn_info.txrate.nss);
1528 hdd_info("datarate legacy %d",
1529 hdd_sta_ctx->conn_info.txrate.legacy);
1530 hdd_info("datarate mcs: %d",
1531 hdd_sta_ctx->conn_info.txrate.mcs);
1532 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1533 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1534 hdd_info("ht caps: %x", *cap_info);
1535 }
1536 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1537 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1538 hdd_info("vht caps: %x", *cap_info);
1539 }
1540 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1541 hdd_info("hs20 info: %x",
1542 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1543 hdd_info("signal: %d",
1544 hdd_sta_ctx->conn_info.signal);
1545 hdd_info("noise: %d",
1546 hdd_sta_ctx->conn_info.noise);
1547}
1548
1549/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 * hdd_dis_connect_handler() - disconnect event handler
1551 * @pAdapter: pointer to adapter
1552 * @pRoamInfo: pointer to roam info
1553 * @roamId: roam identifier
1554 * @roamStatus: roam status
1555 * @roamResult: roam result
1556 *
1557 * This function handles disconnect event:
1558 * 1. Disable transmit queues;
1559 * 2. Clean up internal connection states and data structures;
1560 * 3. Send disconnect indication to supplicant.
1561 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301562 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301564static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565 tCsrRoamInfo *pRoamInfo,
1566 uint32_t roamId,
1567 eRoamCmdStatus roamStatus,
1568 eCsrRoamResult roamResult)
1569{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301570 QDF_STATUS status = QDF_STATUS_SUCCESS;
1571 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572 struct net_device *dev = pAdapter->dev;
1573 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1574 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1575 uint8_t sta_id;
1576 bool sendDisconInd = true;
1577
1578 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001579 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301580 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001581 }
1582 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001583 hdd_notice("Disabling queues");
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301584 wlan_hdd_netif_queue_control(pAdapter,
1585 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1586 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001587
1588 if (hdd_ipa_is_enabled(pHddCtx))
1589 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001590 HDD_IPA_STA_DISCONNECT,
1591 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592
1593#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1594 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1595#endif
1596
Nirav Shah1da77682016-05-03 20:16:39 +05301597 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1598 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001599 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301600 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001601
1602 /* HDD has initiated disconnect, do not send disconnect indication
1603 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301604 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 * to cfg80211_disconnected.
1606 */
1607 if ((eConnectionState_Disconnecting ==
1608 pHddStaCtx->conn_info.connState) ||
1609 (eConnectionState_NotConnected ==
1610 pHddStaCtx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001611 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612 sendDisconInd = false;
1613 }
1614
1615 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1616 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001617 hdd_conn_set_connection_state(pAdapter,
1618 eConnectionState_Disconnecting);
1619 }
1620
1621 hdd_clear_roam_profile_ie(pAdapter);
1622 hdd_wmm_init(pAdapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001623 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301624 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001625
1626 /* indicate 'disconnect' status to wpa_supplicant... */
1627 hdd_send_association_event(dev, pRoamInfo);
1628 /* indicate disconnected event to nl80211 */
1629 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1630 /*
1631 * Only send indication to kernel if not initiated
1632 * by kernel
1633 */
1634 if (sendDisconInd) {
1635 /*
1636 * To avoid wpa_supplicant sending "HANGED" CMD
1637 * to ICS UI.
1638 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001639 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1640 if (pRoamInfo->reasonCode ==
1641 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1642 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301643 wlan_hdd_cfg80211_indicate_disconnect(
1644 dev, false,
1645 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001646 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301647 wlan_hdd_cfg80211_indicate_disconnect(
1648 dev, false,
1649 WLAN_REASON_UNSPECIFIED
1650 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001651 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001652
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301653 hdd_info("sent disconnected event to nl80211, reason code %d",
1654 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1655 pRoamInfo->reasonCode :
1656 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001657 }
1658 /*
1659 * During the WLAN uninitialization,supplicant is stopped
1660 * before the driver so not sending the status of the
1661 * connection to supplicant.
1662 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001663 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001664#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001665 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 if (global_p2p_connection_status ==
1667 P2P_CLIENT_CONNECTED_STATE_1) {
1668 global_p2p_connection_status =
1669 P2P_CLIENT_DISCONNECTED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001670 hdd_debug("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001671 } else if (global_p2p_connection_status ==
1672 P2P_CLIENT_COMPLETED_STATE) {
1673 global_p2p_connection_status =
1674 P2P_NOT_ACTIVE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001675 hdd_debug("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001676 }
1677 }
1678#endif
1679
1680 }
1681 }
1682
1683 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001684 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001685 if (hdd_remove_beacon_filter(pAdapter) != 0)
1686 hdd_err("hdd_remove_beacon_filter() failed");
1687
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001688 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301689 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001690
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001691 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001692 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301693 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001694 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301695 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301696 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001697 }
1698 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301699 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001700 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001701 if (HDD_WLAN_INVALID_STA_ID ==
1702 pHddStaCtx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301703 continue;
1704 sta_id = pHddStaCtx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001705 hdd_debug("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301706 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301707 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001708 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301709 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301710 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301711 }
1712 /* set the staid and peer mac as 0, all other
1713 * reset are done in hdd_connRemoveConnectInfo.
1714 */
1715 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301716 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301717 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301718 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1719 pHddCtx->sta_to_adapter[sta_id] = NULL;
1720 }
1721 } else {
1722 sta_id = pHddStaCtx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001723 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301724
1725 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001726 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1727 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301728 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301729 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1730 pHddStaCtx->conn_info.bssId.bytes);
1731 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1732 pHddStaCtx->conn_info.bssId.bytes);
1733 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301734 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 /* Clear saved connection information in HDD */
1737 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301739 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001740
1741#ifdef FEATURE_WLAN_TDLS
1742 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1743 wlan_hdd_tdls_disconnection_callback(pAdapter);
1744#endif
1745
Krunal Sonibe766b02016-03-10 13:00:44 -08001746 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1747 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1749 (pAdapter),
1750 pAdapter->sessionId);
1751 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301752 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001753 /* Unblock anyone waiting for disconnect to complete */
1754 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301755 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 return status;
1757}
1758
1759/**
1760 * hdd_set_peer_authorized_event() - set peer_authorized_event
1761 * @vdev_id: vdevid
1762 *
1763 * Return: None
1764 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001765static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001766{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301767 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 hdd_adapter_t *adapter = NULL;
1769
1770 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1771 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001772 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001773 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 }
1775 complete(&adapter->sta_authorized_event);
1776}
1777
1778/**
1779 * hdd_change_peer_state() - change peer state
1780 * @pAdapter: HDD adapter
1781 * @sta_state: peer state
1782 * @roam_synch_in_progress: roam synch in progress
1783 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301784 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301786QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001787 uint8_t sta_id,
1788 enum ol_txrx_peer_state sta_state,
1789 bool roam_synch_in_progress)
1790{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301791 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001792 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001793 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1794 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1795 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796
1797 if (!pdev) {
1798 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301799 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001800 }
1801
1802 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001803 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 }
1806
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001807 peer = cdp_peer_find_by_local_id(soc,
1808 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001809 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301810 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811
Leo Changfdb45c32016-10-28 11:09:23 -07001812 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001813 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001814 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001815 return QDF_STATUS_E_FAULT;
1816 }
1817
Leo Changfdb45c32016-10-28 11:09:23 -07001818 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301819 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001820 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301821 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 }
1823#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1824 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301825 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826#endif
1827
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001828 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1830 /* make sure event is reset */
1831 INIT_COMPLETION(pAdapter->sta_authorized_event);
1832#endif
1833
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001834 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835 hdd_set_peer_authorized_event,
1836 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001838 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301839 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 }
1841
Krunal Sonibe766b02016-03-10 13:00:44 -08001842 if (pAdapter->device_mode == QDF_STA_MODE ||
1843 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001844#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001845 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001846 unsigned long rc;
1847
1848 /* wait for event from firmware to set the event */
1849 rc = wait_for_completion_timeout(
1850 &pAdapter->sta_authorized_event,
1851 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001852 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001853 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001854
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001855 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1856 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001857 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858#endif
1859 }
1860 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301861 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001862}
1863
1864/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001865 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1866 * @cbk_data: callback data
1867 * @sta_id: station id
1868 * @vdev_param: vdev parameter
1869 * @is_link_up: link state up or down
1870 *
1871 * Return: QDF status
1872 */
1873QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1874 uint8_t sta_id,
1875 uint32_t vdev_param,
1876 bool is_link_up)
1877{
1878 struct cdp_vdev *data_vdev;
1879 QDF_STATUS status = QDF_STATUS_SUCCESS;
1880 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1881 hdd_context_t *hdd_ctx;
1882 struct wlan_objmgr_psoc **psoc;
1883
1884 if (!cbk_data)
1885 return status;
1886
1887 psoc = cbk_data;
1888 hdd_ctx = container_of(psoc, hdd_context_t, hdd_psoc);
1889
1890 if (!hdd_ctx->tdls_nap_active)
1891 return status;
1892
1893 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, sta_id);
1894 if (NULL == data_vdev) {
1895 status = QDF_STATUS_E_FAILURE;
1896 return status;
1897 }
1898
1899 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1900
1901 return status;
1902}
1903
1904/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905 * hdd_roam_register_sta() - register station
1906 * @pAdapter: pointer to adapter
1907 * @pRoamInfo: pointer to roam info
1908 * @staId: station identifier
1909 * @pPeerMacAddress: peer MAC address
1910 * @pBssDesc: pointer to BSS description
1911 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301912 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001914QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915 tCsrRoamInfo *pRoamInfo,
1916 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301917 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001918 tSirBssDescription *pBssDesc)
1919{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301920 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001921 struct ol_txrx_desc_type staDesc = { 0 };
1922 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001923 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001924 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1925 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926
1927 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301928 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001929
1930 /* Get the Station ID from the one saved during the association */
1931 staDesc.sta_id = staId;
1932
1933 /* set the QoS field appropriately */
1934 if (hdd_wmm_is_active(pAdapter))
1935 staDesc.is_qos_enabled = 1;
1936 else
1937 staDesc.is_qos_enabled = 0;
1938
1939#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001940 hdd_notice("WAPI STA Registered: %d",
1941 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 if (pAdapter->wapi_info.fIsWapiSta)
1943 staDesc.is_wapi_supported = 1;
1944 else
1945 staDesc.is_wapi_supported = 0;
1946#endif /* FEATURE_WLAN_WAPI */
1947
Dhanashri Atre50141c52016-04-07 13:15:29 -07001948 /* Register the vdev transmit and receive functions */
1949 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1950 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001951
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001952 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1953 (struct cdp_pdev *)pdev,
1954 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001955 if (!pAdapter->txrx_vdev) {
1956 hdd_err("%s find vdev fail", __func__);
1957 return QDF_STATUS_E_FAILURE;
1958 }
1959
1960 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001961 cdp_vdev_register(soc,
1962 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001963 if (!txrx_ops.tx.tx) {
1964 hdd_err("%s vdev register fail", __func__);
1965 return QDF_STATUS_E_FAILURE;
1966 }
1967
Dhanashri Atre50141c52016-04-07 13:15:29 -07001968 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001969 qdf_status = cdp_peer_register(soc,
1970 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301971 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001972 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001973 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301974 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975 }
1976
1977 if (!pRoamInfo->fAuthRequired) {
1978 /*
1979 * Connections that do not need Upper layer auth, transition
1980 * TLSHIM directly to 'Authenticated' state
1981 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301982 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001983 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001984 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001985#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1986 pRoamInfo->roamSynchInProgress
1987#else
1988 false
1989#endif
1990 );
1991
1992 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07001993 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001995 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301997 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001998 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001999 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2001 pRoamInfo->roamSynchInProgress
2002#else
2003 false
2004#endif
2005 );
2006 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002007 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302009 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010}
2011
2012/**
2013 * hdd_send_re_assoc_event() - send reassoc event
2014 * @dev: pointer to net device
2015 * @pAdapter: pointer to adapter
2016 * @pCsrRoamInfo: pointer to roam info
2017 * @reqRsnIe: pointer to RSN Information element
2018 * @reqRsnLength: length of RSN IE
2019 *
2020 * Return: none
2021 */
2022static void hdd_send_re_assoc_event(struct net_device *dev,
2023 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
2024 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2025{
2026 unsigned int len = 0;
2027 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002028 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2029 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002030 uint32_t rspRsnLength = 0;
2031 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2033 uint8_t *buf_ptr, ssid_ie_len;
2034 struct cfg80211_bss *bss = NULL;
2035 uint8_t *final_req_ie = NULL;
2036 tCsrRoamConnectedProfile roam_profile;
2037 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002038 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002039
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002040 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2041
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002042 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002043 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002044 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002045 }
2046
Naveen Rawat14298b92015-11-25 16:27:41 -08002047 if (!assoc_req_ies) {
2048 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002049 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002052 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053 goto done;
2054 }
2055
2056 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002057 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002058 goto done;
2059 }
2060
2061 pFTAssocRsp =
2062 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2063 pCsrRoamInfo->nAssocReqLength);
2064 if (pFTAssocRsp == NULL)
2065 goto done;
2066
2067 /* pFTAssocRsp needs to point to the IEs */
2068 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002069 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002070 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002071
2072 /*
2073 * Active session count is decremented upon disconnection, but during
2074 * roaming, there is no disconnect indication and hence active session
2075 * count is not decremented.
2076 * After roaming is completed, active session count is incremented
2077 * as a part of connect indication but effectively after roaming the
2078 * active session count should still be the same and hence upon
2079 * successful reassoc decrement the active session count here.
2080 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002081 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002082 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
2083 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002084
2085 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2086 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2087 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302088 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2089 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090
2091 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302092 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2094 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302095
2096 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2097 chan, pCsrRoamInfo->bssid.bytes,
2098 &roam_profile.SSID.ssId[0],
2099 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002100
2101 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002102 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002103 buf_ptr = buf_ssid_ie;
2104 *buf_ptr = SIR_MAC_SSID_EID;
2105 buf_ptr++;
2106 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2107 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302108 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 roam_profile.SSID.length);
2110 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002111 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302112 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002113 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002114 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002115 if (final_req_ie == NULL)
2116 goto done;
2117 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302118 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302120 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2121 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2122 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002123 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002124 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302125 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002126 final_req_ie, (ssid_ie_len + reqRsnLength));
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002127 cfg80211_roamed_bss(dev, bss,
2128 final_req_ie, (ssid_ie_len + reqRsnLength),
2129 rspRsnIe, rspRsnLength, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302131 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002132 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2133 pCsrRoamInfo->nAssocReqLength);
2134
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002135 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302136 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002137 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2138
Prakash Dhavali989127d2016-11-29 14:56:44 +05302139 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002140 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2141 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002142 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002143done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002144 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002145 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002146 qdf_mem_free(final_req_ie);
2147 qdf_mem_free(rspRsnIe);
2148 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002149}
2150
2151/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302152 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002153 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302154 *
2155 * Return: roam sync status if roaming offloaded else false
2156 */
2157#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002158bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302159{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002160 if (roaminfo)
2161 return roaminfo->roamSynchInProgress;
2162 else
2163 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302164}
2165#endif
2166
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002167/**
2168 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2169 * @hddstactx: pointer to HDD sta context
2170 * @roaminfo: pointer to roaminfo structure
2171 *
2172 * This function returns staid for IBSS peer. If peer is broadcast
2173 * MAC address return self staid(0) else find the peer sta id of
2174 * the peer.
2175 *
2176 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2177 */
2178static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2179 tCsrRoamInfo *roaminfo)
2180{
2181 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2182 QDF_STATUS status;
2183
2184 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2185 staid = 0;
2186 } else {
2187 status = hdd_get_peer_sta_id(hddstactx,
2188 &roaminfo->peerMac, &staid);
2189 if (status != QDF_STATUS_SUCCESS) {
2190 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2191 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2192 }
2193 }
2194
2195 return staid;
2196}
Govind Singhedc5cda2015-10-23 17:11:35 +05302197
2198/**
2199 * hdd_change_sta_state_authenticated()-
2200 * This function changes STA state to authenticated
2201 * @adapter: pointer to the adapter structure.
2202 * @roaminfo: pointer to the RoamInfo structure.
2203 *
2204 * This is called from hdd_RoamSetKeyCompleteHandler
2205 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2206 *
2207 * Return: 0 on success and errno on failure
2208 */
2209static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2210 tCsrRoamInfo *roaminfo)
2211{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002212 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002213 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002214 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302215 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002216 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302217
Dustin Brownf660fb42016-09-09 12:04:00 -07002218 timeout = hddstactx->hdd_ReassocScenario ?
2219 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002220 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002221
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002222 if (QDF_IBSS_MODE == adapter->device_mode)
2223 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2224 else
2225 staid = hddstactx->conn_info.staId[0];
2226
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002227 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302228
2229 /* Connections that do not need Upper layer authentication,
2230 * transition TL to 'Authenticated' state after the keys are set
2231 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002232 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302233 hdd_is_roam_sync_in_progress(roaminfo));
2234 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002235 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2236
Krunal Sonibe766b02016-03-10 13:00:44 -08002237 if ((QDF_STA_MODE == adapter->device_mode) ||
2238 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302239 sme_ps_enable_auto_ps_timer(
2240 WLAN_HDD_GET_HAL_CTX(adapter),
2241 adapter->sessionId,
Krunal Soni364e0872017-05-10 21:24:34 -07002242 timeout, false);
Govind Singhedc5cda2015-10-23 17:11:35 +05302243 }
2244
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002245 return qdf_status_to_os_return(status);
2246}
2247
2248/**
2249 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2250 * if key installation is required
2251 * @encr_type: encryption type
2252 *
2253 * Return: true if key installation is required and false otherwise.
2254 */
2255static inline bool hdd_is_key_install_required_for_ibss(
2256 eCsrEncryptionType encr_type)
2257{
2258 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2259 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2260 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
2261 eCSR_ENCRYPT_TYPE_AES == encr_type)
2262 return true;
2263 else
2264 return false;
2265}
2266
2267/**
2268 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2269 * complete
2270 * @adapter: pointer to HDD adapter
2271 * @roaminfo: pointer to roam info
2272 * @roam_result: roam result
2273 *
2274 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2275 * This function checks for the successful set key completion and update
2276 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2277 *
2278 * Return: None
2279 */
2280static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2281 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2282{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002283 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2284 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2285
2286 /*
2287 * If the security mode is one of the following, IBSS peer will be
2288 * waiting in CONN state and we will move the peer state to AUTH
2289 * here. For non-secure connection, no need to wait for set-key complete
2290 * peer will be moved to AUTH in hdd_roam_register_sta.
2291 */
2292 if (QDF_IBSS_MODE == adapter->device_mode) {
2293 if (hdd_is_key_install_required_for_ibss(encr_type))
2294 hdd_change_sta_state_authenticated(adapter, roaminfo);
2295
2296 return;
2297 }
2298
2299 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2300 hdd_sta_ctx->conn_info.gtk_installed = true;
2301 /*
2302 * PTK exchange happens in preauthentication itself if key_mgmt
2303 * is FT-PSK, ptk_installed was false as there is no set PTK
2304 * after roaming. STA TL state moves to authenticated only if
2305 * ptk_installed is true. So, make ptk_installed to true in
2306 * case of 11R roaming.
2307 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302308 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2309 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002310 hdd_sta_ctx->conn_info.ptk_installed = true;
2311 } else {
2312 hdd_sta_ctx->conn_info.ptk_installed = true;
2313 }
2314
2315 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2316 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2317 * unicast key and it was resulting in sending few un-encrypted packet.
2318 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2319 * set the unicast and broadcast key.
2320 */
2321 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2322 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2323 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2324 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2325 if (hdd_sta_ctx->conn_info.gtk_installed &&
2326 hdd_sta_ctx->conn_info.ptk_installed)
2327 hdd_change_sta_state_authenticated(adapter, roaminfo);
2328 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2329 hdd_change_sta_state_authenticated(adapter, roaminfo);
2330 }
2331
2332 if (hdd_sta_ctx->conn_info.gtk_installed &&
2333 hdd_sta_ctx->conn_info.ptk_installed) {
2334 hdd_sta_ctx->conn_info.gtk_installed = false;
2335 hdd_sta_ctx->conn_info.ptk_installed = false;
2336 }
2337
2338 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2339
2340 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302341}
2342
2343/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002344 * hdd_roam_set_key_complete_handler() - Update the security parameters
2345 * @pAdapter: pointer to adapter
2346 * @pRoamInfo: pointer to roam info
2347 * @roamId: roam id
2348 * @roamStatus: roam status
2349 * @roamResult: roam result
2350 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302351 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002352 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302353static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002354 tCsrRoamInfo *pRoamInfo,
2355 uint32_t roamId,
2356 eRoamCmdStatus roamStatus,
2357 eCsrRoamResult roamResult)
2358{
2359 eCsrEncryptionType connectedCipherAlgo;
2360 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302362
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 ENTER();
2364
2365 if (NULL == pRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002366 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302367 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002368 }
2369 /*
2370 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2371 * then go to 'authenticated'. For all other authentication types
2372 * (those that do not require upper layer authentication) we can put TL
2373 * directly into 'authenticated' state.
2374 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002375 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002376 MAC_ADDRESS_STR, roamStatus, roamResult,
2377 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2378
2379 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2380 &connectedCipherAlgo);
2381 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002382 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2383 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384 } else {
2385 /*
2386 * possible disassoc after issuing set key and waiting
2387 * set key complete.
2388 */
2389 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2390 }
2391
2392 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302393 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002394}
2395
2396/**
2397 * hdd_perform_roam_set_key_complete() - perform set key complete
2398 * @pAdapter: pointer to adapter
2399 *
2400 * Return: none
2401 */
2402void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2403{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302404 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002405 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2406 tCsrRoamInfo roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002407
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302409 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302410 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302411 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302412 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302414 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002415 hdd_roam_set_key_complete_handler(pAdapter,
2416 &roamInfo,
2417 pHddStaCtx->roam_info.roamId,
2418 pHddStaCtx->roam_info.roamStatus,
2419 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302420 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002421 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002422
2423 pHddStaCtx->roam_info.deferKeyComplete = false;
2424}
2425
2426/**
2427 * hdd_association_completion_handler() - association completion handler
2428 * @pAdapter: pointer to adapter
2429 * @pRoamInfo: pointer to roam info
2430 * @roamId: roam id
2431 * @roamStatus: roam status
2432 * @roamResult: roam result
2433 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302434 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002435 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302436static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002437 tCsrRoamInfo *pRoamInfo,
2438 uint32_t roamId,
2439 eRoamCmdStatus roamStatus,
2440 eCsrRoamResult roamResult)
2441{
2442 struct net_device *dev = pAdapter->dev;
2443 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2444 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302445 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002447 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 bool hddDisconInProgress = false;
2450 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302451 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302452 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002453
2454 if (!pHddCtx) {
2455 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302456 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002457 }
2458
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302459 /* validate config */
2460 if (!pHddCtx->config) {
2461 hdd_err("config is NULL");
2462 return QDF_STATUS_E_NULL_VALUE;
2463 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 /* HDD has initiated disconnect, do not send connect result indication
2465 * to kernel as it will be handled by __cfg80211_disconnect.
2466 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302467 if (((eConnectionState_Disconnecting ==
2468 pHddStaCtx->conn_info.connState) ||
2469 (eConnectionState_NotConnected ==
2470 pHddStaCtx->conn_info.connState)) &&
2471 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2472 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002473 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 hddDisconInProgress = true;
2475 }
2476
2477 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2478 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002479 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302480 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002481 }
2482 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002483 hdd_conn_set_connection_state(pAdapter,
2484 eConnectionState_Associated);
2485 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302486
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002487 /* Save the connection info from CSR... */
2488 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2489 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002490
2491 if (hdd_add_beacon_filter(pAdapter) != 0)
2492 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493#ifdef FEATURE_WLAN_WAPI
2494 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2495 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2496 || pRoamInfo->u.pConnectedProfile->AuthType ==
2497 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2498 pAdapter->wapi_info.fIsWapiSta = 1;
2499 } else {
2500 pAdapter->wapi_info.fIsWapiSta = 0;
2501 }
2502#endif /* FEATURE_WLAN_WAPI */
Krunal Soni364e0872017-05-10 21:24:34 -07002503 hdd_debug("bss_descr[%d] devicemode[%d]", !!pRoamInfo->pBssDesc,
2504 pAdapter->device_mode);
2505 if ((QDF_STA_MODE == pAdapter->device_mode) &&
2506 pRoamInfo->pBssDesc) {
2507 ie_len = GET_IE_LEN_IN_BSS(pRoamInfo->pBssDesc->length);
2508 pHddStaCtx->ap_supports_immediate_power_save =
2509 wlan_hdd_is_ap_supports_immediate_power_save(
2510 (uint8_t *) pRoamInfo->pBssDesc->ieFields,
2511 ie_len);
2512 hdd_debug("ap_supports_immediate_power_save flag [%d]",
2513 pHddStaCtx->ap_supports_immediate_power_save);
2514 }
2515
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 /* Indicate 'connect' status to user space */
2517 hdd_send_association_event(dev, pRoamInfo);
2518
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002519 if (policy_mgr_is_mcc_in_24G(pHddCtx->hdd_psoc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 if (pHddCtx->miracast_value)
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002521 wlan_hdd_set_mas(pAdapter,
2522 pHddCtx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 }
2524
2525 /* Initialize the Linkup event completion variable */
2526 INIT_COMPLETION(pAdapter->linkup_event_var);
2527
2528 /*
2529 * Sometimes Switching ON the Carrier is taking time to activate
2530 * the device properly. Before allowing any packet to go up to
2531 * the application, device activation has to be ensured for
2532 * proper queue mapping by the kernel. we have registered net
2533 * device notifier for device change notification. With this we
2534 * will come to know that the device is getting
2535 * activated properly.
2536 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002537 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002538 /*
2539 * Enable Linkup Event Servicing which allows the net
2540 * device notifier to set the linkup event variable.
2541 */
2542 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002543
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002544 /* Switch on the Carrier to activate the device */
2545 wlan_hdd_netif_queue_control(pAdapter,
2546 WLAN_NETIF_CARRIER_ON,
2547 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002548
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002549 /*
2550 * Wait for the Link to up to ensure all the queues
2551 * are set properly by the kernel.
2552 */
2553 rc = wait_for_completion_timeout(
2554 &pAdapter->linkup_event_var,
2555 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2556 );
2557 if (!rc)
2558 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002559
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002560 /*
2561 * Disable Linkup Event Servicing - no more service
2562 * required from the net device notifier call.
2563 */
2564 pAdapter->isLinkUpSvcNeeded = false;
2565 } else {
2566 pHddStaCtx->ft_carrier_on = false;
2567 ft_carrier_on = true;
2568 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2570 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2571 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002572 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573
2574 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2575
2576 if (hdd_ipa_is_enabled(pHddCtx))
2577 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002578 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002579 pRoamInfo->bssid.bytes);
2580
2581#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2582 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2583#endif
2584
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302585 hdd_debug("check if STA chan ok for DNBS");
2586 if (policy_mgr_is_chan_ok_for_dnbs(pHddCtx->hdd_psoc,
2587 pHddStaCtx->conn_info.operationChannel,
2588 &ok)) {
2589 hdd_err("Unable to check DNBS eligibility for chan:%d",
2590 pHddStaCtx->conn_info.operationChannel);
2591 return QDF_STATUS_E_FAILURE;
2592 }
2593
2594 if (!ok) {
2595 hdd_err("Chan:%d not suitable for DNBS",
2596 pHddStaCtx->conn_info.operationChannel);
2597 wlan_hdd_netif_queue_control(pAdapter,
2598 WLAN_NETIF_CARRIER_OFF,
2599 WLAN_CONTROL_PATH);
2600 if (!hddDisconInProgress) {
2601 hdd_err("Disconnecting...");
2602 sme_roam_disconnect(
2603 WLAN_HDD_GET_HAL_CTX(pAdapter),
2604 pAdapter->sessionId,
2605 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2606 }
2607 return QDF_STATUS_E_FAILURE;
2608 }
2609
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002610 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002611 policy_mgr_check_concurrent_intf_and_restart_sap(
2612 pHddCtx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002613
Nirav Shah1da77682016-05-03 20:16:39 +05302614 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2615 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002616 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302617 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2618
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 /*
2620 * For reassoc, the station is already registered, all we need
2621 * is to change the state of the STA in TL.
2622 * If authentication is required (WPA/WPA2/DWEP), change TL to
2623 * CONNECTED instead of AUTHENTICATED.
2624 */
2625 if (!pRoamInfo->fReassocReq) {
2626 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 u8 *pFTAssocRsp = NULL;
2628 unsigned int assocRsplen = 0;
2629 u8 *pFTAssocReq = NULL;
2630 unsigned int assocReqlen = 0;
2631 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2633 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2634
2635 /* add bss_id to cfg80211 data base */
2636 bss =
2637 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2638 pRoamInfo);
2639 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302640 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002641 wlan_hdd_netif_queue_control(pAdapter,
2642 WLAN_NETIF_CARRIER_OFF,
2643 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302644 if (!hddDisconInProgress) {
2645 /*
2646 * Here driver was not able to add bss
2647 * in cfg80211 database this can happen
2648 * if connected channel is not valid,
2649 * i.e reg domain was changed during
2650 * connection. Queue disconnect for the
2651 * session if disconnect is not in
2652 * progress.
2653 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002654 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302655 sme_roam_disconnect(
2656 WLAN_HDD_GET_HAL_CTX(pAdapter),
2657 pAdapter->sessionId,
2658 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2659 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302660 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002662 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2663 eCSR_AUTH_TYPE_FT_RSN
2664 || pRoamInfo->u.pConnectedProfile->AuthType ==
2665 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2666
2667 /* Association Response */
2668 pFTAssocRsp =
2669 (u8 *) (pRoamInfo->pbFrames +
2670 pRoamInfo->nBeaconLength +
2671 pRoamInfo->nAssocReqLength);
2672 if (pFTAssocRsp != NULL) {
2673 /*
2674 * pFTAssocRsp needs to point to the IEs
2675 */
2676 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002677 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002678 (unsigned int)pFTAssocRsp[0],
2679 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 assocRsplen =
2681 pRoamInfo->nAssocRspLength -
2682 FT_ASSOC_RSP_IES_OFFSET;
2683 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002684 hdd_debug("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 assocRsplen = 0;
2686 }
2687
2688 /* Association Request */
2689 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2690 pRoamInfo->nBeaconLength);
2691 if (pFTAssocReq != NULL) {
2692 if (!ft_carrier_on) {
2693 /*
2694 * pFTAssocReq needs to point to
2695 * the IEs
2696 */
2697 pFTAssocReq +=
2698 FT_ASSOC_REQ_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002699 hdd_debug("pFTAssocReq is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002700 (unsigned int)
2701 pFTAssocReq[0],
2702 (unsigned int)
2703 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 assocReqlen =
2705 pRoamInfo->nAssocReqLength -
2706 FT_ASSOC_REQ_IES_OFFSET;
2707 } else {
2708 /*
2709 * This should contain only the
2710 * FTIEs
2711 */
2712 assocReqlen =
2713 pRoamInfo->nAssocReqLength;
2714 }
2715 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002716 hdd_debug("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002717 assocReqlen = 0;
2718 }
2719
2720 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08002721 if (!hddDisconInProgress &&
2722 pRoamInfo->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302723 struct cfg80211_bss *roam_bss;
2724
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002725 /*
2726 * After roaming is completed,
2727 * active session count is
2728 * incremented as a part of
2729 * connect indication but
2730 * effectively the active
2731 * session count should still
2732 * be the same and hence upon
2733 * successful reassoc
2734 * decrement the active session
2735 * count here.
2736 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002737 if (!hdd_is_roam_sync_in_progress
2738 (pRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002739 policy_mgr_decr_session_set_pcl(
2740 pHddCtx->hdd_psoc,
2741 pAdapter->device_mode,
2742 pAdapter->sessionId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002743 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002744 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745 chan =
2746 ieee80211_get_channel
2747 (pAdapter->wdev.wiphy,
2748 (int)pRoamInfo->pBssDesc->
2749 channelId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002750 hdd_debug(
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002751 "assocReqlen %d assocRsplen %d",
2752 assocReqlen,
2753 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002754
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002755 hdd_debug(
Naveen Rawat14298b92015-11-25 16:27:41 -08002756 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302757 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302758 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302759 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002760 pFTAssocReq,
2761 assocReqlen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302762 roam_bss =
2763 hdd_cfg80211_get_bss(
2764 pAdapter->wdev.wiphy,
2765 chan,
2766 pRoamInfo->bssid.bytes,
2767 pRoamInfo->u.
2768 pConnectedProfile->SSID.ssId,
2769 pRoamInfo->u.
2770 pConnectedProfile->SSID.length);
2771 cfg80211_roamed_bss(dev,
2772 roam_bss,
2773 pFTAssocReq,
2774 assocReqlen,
2775 pFTAssocRsp,
2776 assocRsplen,
2777 GFP_KERNEL);
2778 wlan_hdd_send_roam_auth_event(
2779 pAdapter,
2780 pRoamInfo->bssid.bytes,
2781 pFTAssocReq,
2782 assocReqlen,
2783 pFTAssocRsp,
2784 assocRsplen,
2785 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002786 }
2787 if (sme_get_ftptk_state
2788 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2789 pAdapter->sessionId)) {
2790 sme_set_ftptk_state
2791 (WLAN_HDD_GET_HAL_CTX
2792 (pAdapter),
2793 pAdapter->sessionId,
2794 false);
2795 pRoamInfo->fAuthRequired =
2796 false;
2797
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302798 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799 roam_info.bssid,
2800 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302801 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302802 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 roam_info.peerMac,
2804 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302805 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002806 pHddStaCtx->roam_info.roamId =
2807 roamId;
2808 pHddStaCtx->roam_info.
2809 roamStatus = roamStatus;
2810 pHddStaCtx->roam_info.
2811 deferKeyComplete = true;
2812 }
2813 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002814 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002815 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302816 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302817 pRoamInfo->
2818 bssid.bytes,
2819 pRoamInfo,
2820 pFTAssocReq,
2821 assocReqlen,
2822 pFTAssocRsp,
2823 assocRsplen,
2824 WLAN_STATUS_SUCCESS,
2825 GFP_KERNEL,
2826 false,
2827 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002828 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002829 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002830 /*
2831 * wpa supplicant expecting WPA/RSN IE in
2832 * connect result.
2833 */
2834 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2835 (pAdapter),
2836 pAdapter->sessionId,
2837 &reqRsnLength,
2838 reqRsnIe);
2839
2840 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2841 (pAdapter),
2842 pAdapter->sessionId,
2843 &rspRsnLength,
2844 rspRsnIe);
2845 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 if (ft_carrier_on)
2847 hdd_send_re_assoc_event(dev,
2848 pAdapter,
2849 pRoamInfo,
2850 reqRsnIe,
2851 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002852 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002853 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002854 MAC_ADDRESS_STR
2855 " result:%d and Status:%d",
2856 MAC_ADDR_ARRAY
2857 (pRoamInfo->bssid.bytes),
2858 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859
2860 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302861 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302862 pRoamInfo->
2863 bssid.bytes,
2864 pRoamInfo,
2865 reqRsnIe,
2866 reqRsnLength,
2867 rspRsnIe,
2868 rspRsnLength,
2869 WLAN_STATUS_SUCCESS,
2870 GFP_KERNEL,
2871 false,
2872 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002873 }
2874 }
2875 }
2876 if (!hddDisconInProgress) {
2877 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002878 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 bss);
2880
2881 /*
2882 * Perform any WMM-related association
2883 * processing.
2884 */
2885 hdd_wmm_assoc(pAdapter, pRoamInfo,
2886 eCSR_BSS_TYPE_INFRASTRUCTURE);
2887
2888 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002889 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002890 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002891 qdf_status = hdd_roam_register_sta(pAdapter,
2892 pRoamInfo,
2893 pHddStaCtx->conn_info.staId[0],
2894 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002895 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002896 wlan_hdd_netif_queue_control(pAdapter,
2897 WLAN_WAKE_ALL_NETIF_QUEUE,
2898 WLAN_CONTROL_PATH);
2899
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002900 }
2901 } else {
2902 /*
2903 * wpa supplicant expecting WPA/RSN IE in connect result
2904 * in case of reassociation also need to indicate it to
2905 * supplicant.
2906 */
2907 csr_roam_get_wpa_rsn_req_ie(
2908 WLAN_HDD_GET_HAL_CTX(pAdapter),
2909 pAdapter->sessionId,
2910 &reqRsnLength, reqRsnIe);
2911
2912 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2913 reqRsnIe, reqRsnLength);
2914 /* Reassoc successfully */
2915 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302916 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 hdd_change_peer_state(pAdapter,
2918 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002919 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002920#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2921 pRoamInfo->roamSynchInProgress
2922#else
2923 false
2924#endif
2925 );
2926 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002927 hdd_objmgr_set_peer_mlme_auth_state(
2928 pAdapter->hdd_vdev,
2929 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002931 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002932 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302933 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 hdd_change_peer_state(pAdapter,
2935 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002936 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2938 pRoamInfo->roamSynchInProgress
2939#else
2940 false
2941#endif
2942 );
2943 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002944 hdd_objmgr_set_peer_mlme_auth_state(
2945 pAdapter->hdd_vdev,
2946 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947 }
2948
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302949 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002950 /*
2951 * Perform any WMM-related association
2952 * processing
2953 */
2954 hdd_wmm_assoc(pAdapter, pRoamInfo,
2955 eCSR_BSS_TYPE_INFRASTRUCTURE);
2956 }
2957
2958 /* Start the tx queues */
2959#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2960 if (pRoamInfo->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002961 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002962#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002963 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964 wlan_hdd_netif_queue_control(pAdapter,
2965 WLAN_WAKE_ALL_NETIF_QUEUE,
2966 WLAN_CONTROL_PATH);
2967 }
2968
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302969#ifdef FEATURE_WLAN_TDLS
2970 wlan_hdd_tdls_connection_callback(pAdapter);
2971#endif
2972
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302973 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002974 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302975 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 }
2977#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302978 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 sizeof(pAdapter->hdd_stats.hddPmfStats));
2980#endif
2981 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302982 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983 hdd_wext_state_t *pWextState =
2984 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2985 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302986 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002987 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302988 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2989 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302991 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002992 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302993 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2994 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302995
2996 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2997 (pRoamInfo &&
2998 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2999 pRoamInfo->statusCode) ||
3000 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
3001 pRoamInfo->statusCode) ||
3002 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
3003 pRoamInfo->statusCode)))) {
3004 wlan_hdd_cfg80211_update_bss_list(pAdapter,
3005 pRoamInfo ?
3006 pRoamInfo->bssid.bytes :
3007 pWextState->req_bssId.bytes);
3008 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
3009 pRoamInfo ?
3010 pRoamInfo->bssid.bytes :
3011 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303012 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303013 }
3014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003015 /*
3016 * CR465478: Only send up a connection failure result when CSR
3017 * has completed operation - with a ASSOCIATION_FAILURE status.
3018 */
3019 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3020 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303021 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003022 hdd_err("send connect failure to nl80211: for bssid "
3023 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003024 " result: %d and Status: %d reasoncode: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003025 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3026 roamResult, roamStatus,
3027 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303028 pHddStaCtx->conn_info.assoc_status_code =
3029 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003030 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003031 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003032 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003033 " result: %d and status: %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3035 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003036 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003037 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303038 wlan_deregister_txrx_packetdump();
3039
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 /* inform association failure event to nl80211 */
3041 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3042 roamResult) {
3043 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303044 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003045 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303046 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303048 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303049 connect_timeout,
3050 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303052 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003053 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303054 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003055 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303056 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303057 connect_timeout,
3058 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 } else {
Wu Gao77d28352016-11-23 17:50:56 +08003060 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303061 hdd_connect_result(dev,
3062 pRoamInfo->bssid.bytes,
3063 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08003064 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05303065 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003066 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303067 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303068 connect_timeout,
3069 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003070 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303071 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003072 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303073 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303075 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303076 connect_timeout,
3077 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003078 }
Abhishek Singhac2be142015-12-03 16:16:25 +05303079 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003080 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3081 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05303082 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003083 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05303084 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003085 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303086 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303087 connect_timeout,
3088 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 }
3090
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 /*
3092 * Set connection state to eConnectionState_NotConnected only
3093 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003094 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003095 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003096 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3097 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003099 hdd_conn_set_connection_state(pAdapter,
3100 eConnectionState_NotConnected);
3101 }
3102 hdd_wmm_init(pAdapter);
3103
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003104 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303106 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003107 WLAN_CONTROL_PATH);
3108 }
3109
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303110 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111}
3112
3113/**
3114 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3115 * @pAdapter: pointer to adapter
3116 * @pRoamInfo: pointer to roam info
3117 * @roamId: roam id
3118 * @roamStatus: roam status
3119 * @roamResult: roam result
3120 *
3121 * Here we update the status of the Ibss when we receive information that we
3122 * have started/joined an ibss session.
3123 *
3124 * Return: none
3125 */
3126static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3127 tCsrRoamInfo *pRoamInfo,
3128 uint32_t roamId,
3129 eRoamCmdStatus roamStatus,
3130 eCsrRoamResult roamResult)
3131{
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003132 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3133
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003134 hdd_debug("%s: id %d, status %d, result %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003135 pAdapter->dev->name, roamId,
3136 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003137
3138 switch (roamResult) {
3139 /* both IBSS Started and IBSS Join should come in here. */
3140 case eCSR_ROAM_RESULT_IBSS_STARTED:
3141 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3142 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3143 {
3144 hdd_context_t *pHddCtx =
3145 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303146 hdd_station_ctx_t *hdd_sta_ctx =
3147 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303148 struct qdf_mac_addr broadcastMacAddr =
3149 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003150
3151 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303152 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 return;
3154 }
3155
3156 /* When IBSS Started comes from CSR, we need to move
3157 * connection state to IBSS Disconnected (meaning no peers
3158 * are in the IBSS).
3159 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 hdd_conn_set_connection_state(pAdapter,
3161 eConnectionState_IbssDisconnected);
3162 /* notify wmm */
3163 hdd_wmm_connect(pAdapter, pRoamInfo,
3164 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303165
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003166 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303167
3168 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169 pAdapter;
3170 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303171 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 &broadcastMacAddr,
3173 pRoamInfo->pBssDesc);
3174
3175 if (pRoamInfo->pBssDesc) {
3176 struct cfg80211_bss *bss;
3177#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3178 struct ieee80211_channel *chan;
3179 int chan_no;
3180 unsigned int freq;
3181#endif
3182 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003183 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3184 pAdapter->dev->name,
3185 MAC_ADDR_ARRAY(
3186 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003187
3188 /* we must first give cfg80211 the BSS information */
3189 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3190 pRoamInfo);
3191 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003192 hdd_err("%s: unable to create IBSS entry",
3193 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 return;
3195 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003196 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003197 wlan_hdd_netif_queue_control(pAdapter,
3198 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3199 WLAN_CONTROL_PATH);
3200
3201#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3202 chan_no = pRoamInfo->pBssDesc->channelId;
3203
3204 if (chan_no <= 14)
3205 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003206 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003207 else
3208 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003209 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003210
3211 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3212
3213 if (chan)
3214 cfg80211_ibss_joined(pAdapter->dev,
3215 bss->bssid, chan,
3216 GFP_KERNEL);
3217 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003218 hdd_warn("%s: chanId: %d, can't find channel",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003219 pAdapter->dev->name,
3220 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221#else
3222 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3223 GFP_KERNEL);
3224#endif
3225 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 bss);
3228 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003229 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003230 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
3231 pAdapter->device_mode, pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003232 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3233 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003234 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
3235 pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003236 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 break;
3238 }
3239
3240 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3241 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003242 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003243 break;
3244 }
3245
3246 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003247 hdd_err("%s: unexpected result %d",
3248 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 break;
3250 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251}
3252
3253/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003254 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3255 * @sta_ctx: pointer to hdd station context
3256 * @sta_id: station ID
3257 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003258 *
3259 * This information is passed to iwconfig later. The peer that joined
3260 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003261
3262 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003263 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003264bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3265 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003266{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003267 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003269 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3270 if (0 == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003271 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003272 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003273 sta_ctx->conn_info.staId[idx] = sta_id;
3274 qdf_copy_macaddr(
3275 &sta_ctx->conn_info.peerMacAddress[idx],
3276 peer_mac_addr);
3277 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003278 }
3279 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003280 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003281}
3282
3283/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003284 * hdd_delete_peer() - removes peer from hdd station context peer table
3285 * @sta_ctx: pointer to hdd station context
3286 * @sta_id: station ID
3287 *
3288 * Return: None
3289 */
3290void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3291{
3292 int i;
3293
3294 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3295 if (sta_id == sta_ctx->conn_info.staId[i]) {
3296 sta_ctx->conn_info.staId[i] = 0;
3297 return;
3298 }
3299 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003300}
3301
3302/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3304 * @pAdapter: pointer to adapter
3305 * @staId: station id
3306 *
3307 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003308 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309 * false otherwise.
3310 */
3311static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3312{
3313 bool fSuccess = false;
3314 int idx = 0;
3315 uint8_t valid_idx = 0;
3316 uint8_t del_idx = 0;
3317 uint8_t empty_slots = 0;
3318 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3319
Naveen Rawatc45d1622016-07-05 12:20:09 -07003320 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3322 pHddStaCtx->conn_info.staId[idx] = 0;
3323
Anurag Chouhanc5548422016-02-24 18:33:27 +05303324 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 peerMacAddress[idx]);
3326
3327 fSuccess = true;
3328
3329 /*
3330 * Note the deleted Index, if its 0 we need special
3331 * handling.
3332 */
3333 del_idx = idx;
3334
3335 empty_slots++;
3336 } else {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003337 if (pHddStaCtx->conn_info.staId[idx] !=
3338 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 valid_idx = idx;
3340 } else {
3341 /* Found an empty slot */
3342 empty_slots++;
3343 }
3344 }
3345 }
3346
Naveen Rawatc45d1622016-07-05 12:20:09 -07003347 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348 /* Last peer departed, set the IBSS state appropriately */
3349 pHddStaCtx->conn_info.connState =
3350 eConnectionState_IbssDisconnected;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003351 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003352 }
3353 /* Find next active staId, to have a valid sta trigger for TL. */
3354 if (fSuccess == true) {
3355 if (del_idx == 0) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003356 if (pHddStaCtx->conn_info.staId[valid_idx] !=
3357 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 pHddStaCtx->conn_info.staId[0] =
3359 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303360 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 peerMacAddress[0],
3362 &pHddStaCtx->conn_info.
3363 peerMacAddress[valid_idx]);
3364
3365 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303366 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 peerMacAddress[valid_idx]);
3368 }
3369 }
3370 }
3371 return fSuccess;
3372}
3373
3374/**
3375 * roam_ibss_connect_handler() - IBSS connection handler
3376 * @pAdapter: pointer to adapter
3377 * @pRoamInfo: pointer to roam info
3378 *
3379 * We update the status of the IBSS to connected in this function.
3380 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303381 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303383static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 tCsrRoamInfo *pRoamInfo)
3385{
3386 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003387 /*
3388 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3389 * a partner stations).
3390 */
3391 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3392
3393 /* Save the connection info from CSR... */
3394 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3395
3396 /* Send the bssid address to the wext. */
3397 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3398 /* add bss_id to cfg80211 data base */
3399 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3400 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003401 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303403 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404 }
3405 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003406 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 bss);
3408
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303409 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003410}
3411
3412/**
3413 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3414 * @pAdapter: pointer to adapter
3415 * @pRoamInfo: pointer to roam info
3416 * @roamId: roam id
3417 * @roamStatus: roam status
3418 * @roamResult: roam result
3419 *
3420 * This function indicates the Mic failure to the supplicant
3421 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303422 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303424static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003425hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3426 tCsrRoamInfo *pRoamInfo,
3427 uint32_t roamId,
3428 eRoamCmdStatus roamStatus,
3429 eCsrRoamResult roamResult)
3430{
3431 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3432
3433 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3434 TKIP_COUNTER_MEASURE_STOPED ==
3435 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3436 struct iw_michaelmicfailure msg;
3437 union iwreq_data wreq;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003438
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 memset(&msg, '\0', sizeof(msg));
3440 msg.src_addr.sa_family = ARPHRD_ETHER;
3441 memcpy(msg.src_addr.sa_data,
3442 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3443 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003444 hdd_debug("MIC MAC " MAC_ADDRESS_STR,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003445 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446
3447 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3448 msg.flags = IW_MICFAILURE_GROUP;
3449 else
3450 msg.flags = IW_MICFAILURE_PAIRWISE;
3451 memset(&wreq, 0, sizeof(wreq));
3452 wreq.data.length = sizeof(msg);
3453 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3454 (char *)&msg);
3455 /* inform mic failure to nl80211 */
3456 cfg80211_michael_mic_failure(pAdapter->dev,
3457 pRoamInfo->u.pMICFailureInfo->
3458 taMacAddr,
3459 ((pRoamInfo->u.pMICFailureInfo->
3460 multicast ==
3461 eSIR_TRUE) ?
3462 NL80211_KEYTYPE_GROUP :
3463 NL80211_KEYTYPE_PAIRWISE),
3464 pRoamInfo->u.pMICFailureInfo->
3465 keyId,
3466 pRoamInfo->u.pMICFailureInfo->TSC,
3467 GFP_KERNEL);
3468
3469 }
3470
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303471 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003472}
3473
3474/**
3475 * roam_roam_connect_status_update_handler() - IBSS connect status update
3476 * @pAdapter: pointer to adapter
3477 * @pRoamInfo: pointer to roam info
3478 * @roamId: roam id
3479 * @roamStatus: roam status
3480 * @roamResult: roam result
3481 *
3482 * The Ibss connection status is updated regularly here in this function.
3483 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303484 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303486static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003487roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3488 tCsrRoamInfo *pRoamInfo,
3489 uint32_t roamId,
3490 eRoamCmdStatus roamStatus,
3491 eCsrRoamResult roamResult)
3492{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003493 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003494 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303495
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003496 switch (roamResult) {
3497 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3498 {
3499 hdd_station_ctx_t *pHddStaCtx =
3500 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003501 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003502 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003503
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003504 hdd_info("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303505 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3506 MAC_ADDRESS_STR " and stationID= %d",
3507 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3508 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3509 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003510
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003511 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003512 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3513 pRoamInfo->staId,
3514 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003515 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 break;
3517 }
3518
3519 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3520
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003521 if (hdd_is_key_install_required_for_ibss(encr_type))
3522 pRoamInfo->fAuthRequired = true;
3523
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003524 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303525 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526 pRoamInfo,
3527 pRoamInfo->staId,
3528 &pRoamInfo->peerMac,
3529 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303530 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003531 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303532 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003533 }
3534 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003535 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3536 if (stainfo == NULL) {
3537 hdd_err("memory allocation for station_info failed");
3538 return QDF_STATUS_E_NOMEM;
3539 }
3540 stainfo->filled = 0;
3541 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542
3543 cfg80211_new_sta(pAdapter->dev,
3544 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003545 stainfo, GFP_KERNEL);
3546 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003548 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003549 pHddStaCtx->ibss_enc_key.keyDirection =
3550 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303551 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003552 &pRoamInfo->peerMac);
3553
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003554 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003555 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303557 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003558 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3559 (pAdapter),
3560 pAdapter->sessionId,
3561 &pHddStaCtx->ibss_enc_key,
3562 &roamId);
3563
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303564 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003565 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003566 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303567 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 }
3569 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003570 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 wlan_hdd_netif_queue_control(pAdapter,
3572 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3573 WLAN_CONTROL_PATH);
3574 break;
3575 }
3576
3577 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3578 {
3579
3580 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3581
3582 break;
3583 }
3584 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3585 {
3586 hdd_station_ctx_t *pHddStaCtx =
3587 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3588
3589 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003590 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003592 hdd_info("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303593 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3594 MAC_ADDRESS_STR " and stationID= %d",
3595 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3596 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3597 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598
3599 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3600
3601 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3602 pHddStaCtx->ibss_sta_generation++;
3603
3604 cfg80211_del_sta(pAdapter->dev,
3605 (const u8 *)&pRoamInfo->peerMac.bytes,
3606 GFP_KERNEL);
3607 break;
3608 }
3609 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3610 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003611 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003613 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003614 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303615 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003617 hdd_conn_set_connection_state(pAdapter,
3618 eConnectionState_NotConnected);
3619
3620 /* Send the bssid address to the wext. */
3621 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3622 break;
3623 }
3624 default:
3625 break;
3626
3627 }
3628
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303629 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003630}
3631
3632#ifdef FEATURE_WLAN_TDLS
3633/**
3634 * hdd_roam_register_tdlssta() - register new TDLS station
3635 * @pAdapter: pointer to adapter
3636 * @peerMac: pointer to peer MAC address
3637 * @staId: station identifier
3638 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303639 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003640 *
3641 * Construct the staDesc and register with TL the new STA.
3642 * This is called as part of ADD_STA in the TDLS setup.
3643 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303644 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003645 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303646QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303648 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003649{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303650 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003652 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003653 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3654 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003655
3656 /*
3657 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3658 * be peer MAC, here we are working on direct Link
3659 */
3660 staDesc.sta_id = staId;
3661
3662 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303663 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003664
Dhanashri Atre50141c52016-04-07 13:15:29 -07003665 /* Register the vdev transmit and receive functions */
3666 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3667 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003668 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003669 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3670 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003671 pAdapter, &txrx_ops);
3672 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003673
3674 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003675 qdf_status = cdp_peer_register(soc,
3676 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303677 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003678 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303679 qdf_status, qdf_status);
3680 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003681 }
3682
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303683 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684}
3685
3686/**
3687 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3688 * @pAdapter: pointer to adapter
3689 * @staId: station identifier
3690 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303691 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003692 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303693QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003694{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303695 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003696 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003697 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3698 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303699 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003700 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003701 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303703 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003704}
3705
3706/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003707 * hdd_tdls_connection_tracker_update() - update connection tracker state
3708 * @adapter: pointer to adapter
3709 * @roam_info: pointer to roam info
3710 * @hdd_tdls_ctx: tdls context
3711 *
3712 * Return: QDF_STATUS enumeration
3713 */
3714static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3715 tCsrRoamInfo *roam_info,
3716 tdlsCtx_t *hdd_tdls_ctx)
3717{
3718 hddTdlsPeer_t *curr_peer;
3719 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3720
3721 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303722 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003723
3724 if (!curr_peer) {
3725 hdd_err("curr_peer is null");
3726 return QDF_STATUS_E_FAILURE;
3727 }
3728
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003729 if (eTDLS_LINK_CONNECTED ==
3730 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003731 hdd_debug("Received CONNECTION_TRACKER_NOTIFICATION "
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003732 MAC_ADDRESS_STR
3733 " staId: %d, reason: %d",
3734 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3735 roam_info->staId,
3736 roam_info->reasonCode);
3737
3738 if (roam_info->reasonCode ==
3739 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3740 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003741 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3742 roam_info->reasonCode ==
3743 eWMI_TDLS_SCAN_STARTED_EVENT)
3744 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003745 else if (roam_info->reasonCode ==
3746 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3747 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003748 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3749 roam_info->reasonCode ==
3750 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3751 hdd_ctx->enable_tdls_connection_tracker = true;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003752 hdd_debug("hdd_ctx->enable_tdls_connection_tracker %d",
Nitesh Shahc549dd52017-02-23 16:45:44 +05303753 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003754 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003755 hdd_debug("TDLS not connected, ignore notification, reason: %d",
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003756 roam_info->reasonCode);
3757 }
3758
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003759 return QDF_STATUS_SUCCESS;
3760}
3761
3762
3763
3764
3765/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003766 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3767 * @pAdapter: pointer to adapter
3768 * @pRoamInfo: pointer to roam info
3769 * @roamId: roam id
3770 * @roamStatus: roam status
3771 * @roamResult: roam result
3772 *
3773 * HDD interface between SME and TL to ensure TDLS client registration with
3774 * TL in case of new TDLS client is added and deregistration at the time
3775 * TDLS client is deleted.
3776 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303777 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003778 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303779static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003780hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3781 tCsrRoamInfo *pRoamInfo,
3782 uint32_t roamId,
3783 eRoamCmdStatus roamStatus,
3784 eCsrRoamResult roamResult)
3785{
3786 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303787 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303789 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 uint8_t staIdx;
3791 hddTdlsPeer_t *curr_peer;
3792 uint32_t reason;
3793
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003794 hdd_debug("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003795 roamResult ==
3796 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3797 ==
3798 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3799 roamResult ==
3800 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3801 : roamResult ==
3802 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3803 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3804 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3805 roamResult ==
3806 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3807 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3808 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3809 : roamResult ==
3810 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3811 : roamResult ==
3812 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3813 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3814 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816 switch (roamResult) {
3817 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3818 {
3819 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003820 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003821 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303822 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003823 } else {
3824 /*
3825 * Check if there is available index for this new TDLS
3826 * STA.
3827 */
3828 for (staIdx = 0;
3829 staIdx < pHddCtx->max_num_tdls_sta;
3830 staIdx++) {
3831 if (0 ==
3832 pHddCtx->tdlsConnInfo[staIdx].
3833 staId) {
3834 pHddCtx->tdlsConnInfo[staIdx].
3835 sessionId =
3836 pRoamInfo->sessionId;
3837 pHddCtx->tdlsConnInfo[staIdx].
3838 staId = pRoamInfo->staId;
3839
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003840 hdd_debug("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003842 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843 staIdx,
3844 pHddCtx->
3845 tdlsConnInfo[staIdx].
3846 staId,
3847 MAC_ADDR_ARRAY
3848 (pRoamInfo->peerMac.bytes));
3849
Anurag Chouhanc5548422016-02-24 18:33:27 +05303850 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003851 tdlsConnInfo
3852 [staIdx].
3853 peerMac,
3854 &pRoamInfo->
3855 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303856 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003857 break;
3858 }
3859 }
3860 if (staIdx < pHddCtx->max_num_tdls_sta) {
3861 if (-1 ==
3862 wlan_hdd_tdls_set_sta_id(pAdapter,
3863 pRoamInfo->
3864 peerMac.bytes,
3865 pRoamInfo->
3866 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003867 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303868 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 }
3870
3871 (WLAN_HDD_GET_CTX(pAdapter))->
3872 sta_to_adapter[pRoamInfo->staId] =
3873 pAdapter;
3874 /*
3875 * store the ucast signature,
3876 * if required for further reference.
3877 */
3878
3879 wlan_hdd_tdls_set_signature(pAdapter,
3880 pRoamInfo->
3881 peerMac.bytes,
3882 pRoamInfo->
3883 ucastSig);
3884 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303885 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003886 hdd_debug("no available slot in conn_info. staId: %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003887 pRoamInfo->staId);
3888 }
3889 pAdapter->tdlsAddStaStatus = status;
3890 }
3891 complete(&pAdapter->tdls_add_station_comp);
3892 break;
3893 }
3894 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3895 {
3896 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003897 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003898 pRoamInfo->statusCode);
3899 }
3900 /* store the ucast signature which will be used later when
3901 * registering to TL
3902 */
3903 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3904 complete(&pAdapter->tdls_add_station_comp);
3905 break;
3906 }
3907 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3908 {
3909 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003910 hdd_err("Link Establish Request failed. status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 pRoamInfo->statusCode);
3912 }
3913 complete(&pAdapter->tdls_link_establish_req_comp);
3914 break;
3915 }
3916 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3917 {
3918 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3919 staIdx++) {
3920 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3921 pRoamInfo->sessionId)
3922 && pRoamInfo->staId ==
3923 pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003924 hdd_debug("HDD: del STA IDX = %x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003925 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303926 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003927 curr_peer =
3928 wlan_hdd_tdls_find_peer(pAdapter,
3929 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05303930 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303931 if (NULL != curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003932 hdd_debug("Current status for peer " MAC_ADDRESS_STR " is %d",
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303933 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3934 curr_peer->link_status);
3935 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303936 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 hdd_roam_deregister_tdlssta
3938 (pAdapter,
3939 pRoamInfo->staId);
3940 wlan_hdd_tdls_decrement_peer_count
3941 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303942 } else if (eTDLS_LINK_CONNECTING ==
3943 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303944 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303945 hdd_roam_deregister_tdlssta
3946 (pAdapter,
3947 pRoamInfo->staId);
Nitesh Shah0bf768f2017-03-31 15:01:37 +05303948 } else
3949 mutex_unlock(&pHddCtx->tdls_lock);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303950 } else
3951 mutex_unlock(&pHddCtx->tdls_lock);
3952
Nitesh Shah99dd9552017-03-20 19:27:47 +05303953 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954 wlan_hdd_tdls_reset_peer(pAdapter,
3955 pRoamInfo->
3956 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05303957 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003958
3959 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3960 pHddCtx->tdlsConnInfo[staIdx].
3961 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303962 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963 tdlsConnInfo[staIdx].
3964 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303965 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303966 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003967 break;
3968 }
3969 }
3970 complete(&pAdapter->tdls_del_station_comp);
3971 }
3972 break;
3973 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3974 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003975 hdd_debug("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003976 pRoamInfo->reasonCode);
3977
Nitesh Shahf1f38992017-01-31 16:40:16 +05303978 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 curr_peer =
3980 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303981 pRoamInfo->peerMac.bytes);
Ganesh Kondabattini9c8dc462017-04-19 10:52:54 +05303982
3983 if (!curr_peer) {
3984 mutex_unlock(&pHddCtx->tdls_lock);
3985 hdd_debug("peer doesn't exists");
3986 status = QDF_STATUS_SUCCESS;
3987 break;
3988 }
3989
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003990 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05303991 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303992 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3993 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303994 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303995 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 break;
3997 }
3998 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3999 {
4000 /* 0 staIdx is assigned to AP we dont want to touch that */
4001 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4002 staIdx++) {
4003 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4004 pRoamInfo->sessionId)
4005 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004006 hdd_debug("hdd_tdlsStatusUpdate: staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004007 MAC_ADDRESS_STR,
4008 pHddCtx->tdlsConnInfo[staIdx].
4009 staId,
4010 MAC_ADDR_ARRAY(pHddCtx->
4011 tdlsConnInfo
4012 [staIdx].
4013 peerMac.
4014 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05304015 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004016 wlan_hdd_tdls_reset_peer(pAdapter,
4017 pHddCtx->
4018 tdlsConnInfo
4019 [staIdx].
4020 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304021 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 hdd_roam_deregister_tdlssta(pAdapter,
4023 pHddCtx->
4024 tdlsConnInfo
4025 [staIdx].
4026 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304027 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004028 sizeof
4029 (smeTdlsPeerStateParams));
4030 smeTdlsPeerStateParams.vdevId =
4031 pHddCtx->tdlsConnInfo[staIdx].
4032 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304033 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 peerMacAddr,
4035 &pHddCtx->
4036 tdlsConnInfo[staIdx].
4037 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304038 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 smeTdlsPeerStateParams.peerState =
4040 eSME_TDLS_PEER_STATE_TEARDOWN;
4041
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004042 hdd_debug("calling sme_update_tdls_peer_state for staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004043 MAC_ADDRESS_STR,
4044 pHddCtx->tdlsConnInfo[staIdx].
4045 staId,
4046 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004047 tdlsConnInfo
4048 [staIdx].
4049 peerMac.
4050 bytes));
4051 status =
4052 sme_update_tdls_peer_state(
4053 pHddCtx->hHal,
4054 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304055 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004056 hdd_err("sme_update_tdls_peer_state failed for "
4057 MAC_ADDRESS_STR,
4058 MAC_ADDR_ARRAY
4059 (pHddCtx->
4060 tdlsConnInfo[staIdx].
4061 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 }
4063 wlan_hdd_tdls_decrement_peer_count
4064 (pAdapter);
4065
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304066 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 tdlsConnInfo[staIdx].
4068 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304069 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004070 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4071 pHddCtx->tdlsConnInfo[staIdx].
4072 sessionId = 255;
4073
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304074 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 }
4076 }
4077 break;
4078 }
4079 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
4080 {
4081 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07004082 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
4083 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304084 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004085 break;
4086 }
4087
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004088 if (pHddCtx->tdls_nss_switch_in_progress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004089 hdd_debug("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004090 status = QDF_STATUS_SUCCESS;
4091 break;
4092 }
4093
Nitesh Shah8e866642017-01-31 15:43:31 +05304094 mutex_lock(&pHddCtx->tdls_lock);
4095 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4096 if (!pHddTdlsCtx) {
4097 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004098 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shah8e866642017-01-31 15:43:31 +05304099 roamResult);
4100 status = QDF_STATUS_E_FAILURE;
4101 break;
4102 }
4103
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004104 curr_peer =
4105 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05304106 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004107 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004108 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304109 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004110 } else {
4111 if (eTDLS_LINK_CONNECTED ==
4112 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004113 hdd_debug("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004114 } else {
4115 /*
4116 * If external control is enabled then initiate
4117 * TDLS only if forced peer is set otherwise
4118 * ignore should Discover trigger from fw.
4119 */
4120 if (pHddCtx->config->
4121 fTDLSExternalControl
4122 && (false ==
4123 curr_peer->isForcedPeer)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004124 hdd_debug("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304125 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004127 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004128 hdd_debug("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Jeff Johnson68755312017-02-10 11:46:55 -08004129 pHddCtx->config->
4130 fTDLSExternalControl,
4131 curr_peer->isForcedPeer,
4132 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304133 pHddTdlsCtx->curr_candidate = curr_peer;
4134 wlan_hdd_tdls_implicit_send_discovery_request(
4135 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304137 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004138 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304139 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004140 break;
4141 }
4142
4143 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4144 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304145 mutex_lock(&pHddCtx->tdls_lock);
4146 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4147 if (!pHddTdlsCtx) {
4148 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004149 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304150 roamResult);
4151 status = QDF_STATUS_E_FAILURE;
4152 break;
4153 }
4154
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004155 curr_peer =
4156 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304157 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004159 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304160 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004161 } else {
4162 if (eTDLS_LINK_CONNECTED ==
4163 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004164 hdd_debug("Received SHOULD_TEARDOWN for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004165 MAC_ADDRESS_STR
4166 " staId: %d, reason: %d",
4167 MAC_ADDR_ARRAY(pRoamInfo->
4168 peerMac.bytes),
4169 pRoamInfo->staId,
4170 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004171
4172 if (pRoamInfo->reasonCode ==
4173 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4174 pRoamInfo->reasonCode ==
4175 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4176 pRoamInfo->reasonCode ==
4177 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4178 pRoamInfo->reasonCode ==
4179 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4180 reason =
4181 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4182 } else
4183 reason =
4184 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4185
4186 wlan_hdd_tdls_indicate_teardown
4187 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304188 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304189 hdd_send_wlan_tdls_teardown_event(
4190 eTDLS_TEARDOWN_BSS_DISCONNECT,
4191 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004192 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004193 hdd_debug("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004194 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304196 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304198 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 break;
4200 }
4201
4202 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4203 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304204 mutex_lock(&pHddCtx->tdls_lock);
4205 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4206 if (!pHddTdlsCtx) {
4207 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004208 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304209 roamResult);
4210 status = QDF_STATUS_E_FAILURE;
4211 break;
4212 }
4213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 curr_peer =
4215 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304216 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004218 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304219 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 } else {
4221 if (eTDLS_LINK_CONNECTED ==
4222 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004223 hdd_debug("Received SHOULD_PEER_DISCONNECTED for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004224 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004225 " staId: %d reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004226 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4227 pRoamInfo->staId,
4228 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004229
4230 if (pRoamInfo->reasonCode ==
4231 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4232 pRoamInfo->reasonCode ==
4233 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4234 pRoamInfo->reasonCode ==
4235 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4236 pRoamInfo->reasonCode ==
4237 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4238 reason =
4239 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4240 } else
4241 reason =
4242 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4243
4244 wlan_hdd_tdls_indicate_teardown
4245 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304246 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304247 hdd_send_wlan_tdls_teardown_event(
4248 eTDLS_TEARDOWN_BSS_DISCONNECT,
4249 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004250 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004251 hdd_debug("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004252 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004253 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304254 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004255 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304256 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 break;
4258 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004259
4260 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304261 mutex_lock(&pHddCtx->tdls_lock);
4262 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4263 if (!pHddTdlsCtx) {
4264 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004265 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304266 roamResult);
4267 status = QDF_STATUS_E_FAILURE;
4268 break;
4269 }
4270
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004271 status = hdd_tdls_connection_tracker_update(pAdapter,
4272 pRoamInfo,
4273 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304274 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004275 break;
4276
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 default:
4278 {
4279 break;
4280 }
4281 }
4282
4283 return status;
4284}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004285#else
4286
Nitesh Shah99dd9552017-03-20 19:27:47 +05304287inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004288 uint8_t staId)
4289{
4290 return QDF_STATUS_SUCCESS;
4291}
4292
4293static inline QDF_STATUS
4294hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4295 tCsrRoamInfo *pRoamInfo,
4296 uint32_t roamId,
4297 eRoamCmdStatus roamStatus,
4298 eCsrRoamResult roamResult)
4299{
4300 return QDF_STATUS_SUCCESS;
4301}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302#endif
4303
4304#ifdef WLAN_FEATURE_11W
4305/**
4306 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4307 * @pAdapter: pointer to the adapter
4308 * @nFrameLength: Length of the unprotected frame being passed
4309 * @pbFrames: Pointer to the frame buffer
4310 * @frameType: 802.11 frame type
4311 *
4312 * This function forwards the unprotected management frame to the supplicant.
4313 *
4314 * Return: nothing
4315 */
4316static void
4317hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4318 uint8_t *pbFrames, uint8_t frameType)
4319{
4320 uint8_t type = 0;
4321 uint8_t subType = 0;
4322
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004323 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004324 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004325
4326 /* Sanity Checks */
4327 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004328 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004329 return;
4330 }
4331
4332 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004333 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004334 return;
4335 }
4336
4337 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004338 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004339 return;
4340 }
4341
4342 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004343 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004344 return;
4345 }
4346
4347 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004348 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004349 return;
4350 }
4351
4352 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4353 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4354
4355 /* Get pAdapter from Destination mac address of the frame */
4356 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4357#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4358 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4359 nFrameLength);
4360#else
4361 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4362 nFrameLength);
4363#endif
4364 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4365 } else if (type == SIR_MAC_MGMT_FRAME &&
4366 subType == SIR_MAC_MGMT_DEAUTH) {
4367#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4368 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4369 nFrameLength);
4370#else
4371 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4372 nFrameLength);
4373#endif
4374 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4375 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004376 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004377 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004378 return;
4379 }
4380}
4381#endif
4382
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004383#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384/**
4385 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4386 * @pAdapter: pointer to adapter
4387 * @tid: traffic identifier
4388 * @state: state
4389 * @measInterval: measurement interval
4390 *
4391 * This function sends traffic stream metrics IE information to
4392 * the supplicant via wireless event.
4393 *
4394 * Return: none
4395 */
4396static void
4397hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4398 uint8_t state, uint16_t measInterval)
4399{
4400 union iwreq_data wrqu;
4401 char buf[IW_CUSTOM_MAX + 1];
4402 int nBytes = 0;
4403
4404 if (NULL == pAdapter)
4405 return;
4406
4407 /* create the event */
4408 memset(&wrqu, '\0', sizeof(wrqu));
4409 memset(buf, '\0', sizeof(buf));
4410
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004411 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004412 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004413
4414 nBytes =
4415 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4416 measInterval);
4417
4418 wrqu.data.pointer = buf;
4419 wrqu.data.length = nBytes;
4420 /* send the event */
4421 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4422}
4423
4424/**
4425 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4426 * @pAdapter: pointer to adapter
4427 * @pRoamInfo: pointer to roam info
4428 *
4429 * This function sends cckm preauth indication to the supplicant
4430 * via wireless custom event.
4431 *
4432 * Return: none
4433 */
4434static void
4435hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4436{
4437 union iwreq_data wrqu;
4438 char buf[IW_CUSTOM_MAX + 1];
4439 char *pos = buf;
4440 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4441
4442 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4443 return;
4444
4445 /* create the event */
4446 memset(&wrqu, '\0', sizeof(wrqu));
4447 memset(buf, '\0', sizeof(buf));
4448
4449 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004450 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004451 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4452 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453
4454 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4455 pos += nBytes;
4456 freeBytes -= nBytes;
4457
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304458 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304459 pos += QDF_MAC_ADDR_SIZE;
4460 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004461
4462 nBytes = snprintf(pos, freeBytes, " %u:%u",
4463 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4464 freeBytes -= nBytes;
4465
4466 wrqu.data.pointer = buf;
4467 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4468
4469 /* send the event */
4470 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4471}
4472
4473/**
4474 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4475 * @pAdapter: pointer to adapter
4476 * @pRoamInfo: pointer to roam info
4477 *
4478 * Return: none
4479 */
4480static void
4481hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4482 tCsrRoamInfo *pRoamInfo)
4483{
4484 union iwreq_data wrqu;
4485 char buf[IW_CUSTOM_MAX + 1];
4486 int nBytes = 0;
4487
4488 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4489 return;
4490
4491 /* create the event */
4492 memset(&wrqu, '\0', sizeof(wrqu));
4493 memset(buf, '\0', sizeof(buf));
4494
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004495 hdd_debug("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004496
4497 nBytes =
4498 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4499 pRoamInfo->tsmRoamDelay);
4500
4501 wrqu.data.pointer = buf;
4502 wrqu.data.length = nBytes;
4503
4504 /* send the event */
4505 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4506}
4507
4508/**
4509 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4510 * @pAdapter: pointer to adapter
4511 * @measurementToken: measurement token
4512 * @flag: flag
4513 * @numBss: number of bss
4514 *
4515 * If the measurement is none and no scan results found,
4516 * indicate the supplicant about measurement done.
4517 *
4518 * Return: none
4519 */
4520void
4521hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4522 const uint16_t measurementToken,
4523 const bool flag, const uint8_t numBss)
4524{
4525 union iwreq_data wrqu;
4526 char buf[IW_CUSTOM_MAX];
4527 char *pos = buf;
4528 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4529
4530 memset(&wrqu, '\0', sizeof(wrqu));
4531 memset(buf, '\0', sizeof(buf));
4532
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004533 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004534 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004535
4536 nBytes =
4537 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4538 flag, numBss);
4539
4540 wrqu.data.pointer = buf;
4541 wrqu.data.length = nBytes;
4542 /* send the event */
4543 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4544}
4545
4546/**
4547 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4548 * @pAdapter: pointer to adapter
4549 * @pRoamInfo: pointer to roam info
4550 *
4551 * If the measurement is none and no scan results found,
4552 * indicate the supplicant about measurement done.
4553 *
4554 * Return: none
4555 */
4556static void
4557hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4558 const tCsrRoamInfo *pRoamInfo)
4559{
4560 union iwreq_data wrqu;
4561 char buf[IW_CUSTOM_MAX];
4562 char *pos = buf;
4563 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4564 uint8_t i = 0, len = 0;
4565 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4566 uint8_t lastSent = 0, sendBss = 0;
4567 int bcnRepFieldSize =
4568 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4569 bcnReportFields);
4570 uint8_t ieLenByte = 1;
4571 /*
4572 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4573 */
4574#define ESEBCNREPHEADER_LEN (18)
4575
4576 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4577 return;
4578
4579 /*
4580 * Custom event can pass maximum of 256 bytes of data,
4581 * based on the IE len we need to identify how many BSS info can
4582 * be filled in to custom event data.
4583 */
4584 /*
4585 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4586 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4587 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4588 */
4589
4590 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4591 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004592 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004593 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004594 * indicate the supplicant about measurement done
4595 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004596 hdd_indicate_ese_bcn_report_no_results(
4597 pAdapter,
4598 pRoamInfo->pEseBcnReportRsp->
4599 measurementToken,
4600 pRoamInfo->pEseBcnReportRsp->flag,
4601 pRoamInfo->pEseBcnReportRsp->numBss);
4602 } else {
4603 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4604 memset(&wrqu, '\0', sizeof(wrqu));
4605 memset(buf, '\0', sizeof(buf));
4606 tot_bcn_ieLen = 0;
4607 sendBss = 0;
4608 pos = buf;
4609 freeBytes = IW_CUSTOM_MAX;
4610
4611 for (i = lastSent;
4612 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4613 len =
4614 bcnRepFieldSize + ieLenByte +
4615 pRoamInfo->pEseBcnReportRsp->
4616 bcnRepBssInfo[i].ieLen;
4617 if ((len + tot_bcn_ieLen) >
4618 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4619 break;
4620 }
4621 tot_bcn_ieLen += len;
4622 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004623 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004624 i, bcnRepFieldSize, 1,
4625 pRoamInfo->pEseBcnReportRsp->
4626 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004627 }
4628
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004629 hdd_debug("Sending %d BSS Info", sendBss);
4630 hdd_debug("CCXBCNREP=%d %d %d %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004631 pRoamInfo->pEseBcnReportRsp->measurementToken,
4632 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4633 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634
4635 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4636 pRoamInfo->pEseBcnReportRsp->
4637 measurementToken,
4638 pRoamInfo->pEseBcnReportRsp->flag,
4639 sendBss);
4640 pos += nBytes;
4641 freeBytes -= nBytes;
4642
4643 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304644 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004645 sizeof(tot_bcn_ieLen));
4646 pos += sizeof(tot_bcn_ieLen);
4647 freeBytes -= sizeof(tot_bcn_ieLen);
4648
4649 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004650 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4652 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4653 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4654 pRoamInfo->pEseBcnReportRsp->
4655 bcnRepBssInfo[i +
4656 lastSent].bcnReportFields.
4657 ChanNum,
4658 pRoamInfo->pEseBcnReportRsp->
4659 bcnRepBssInfo[i +
4660 lastSent].bcnReportFields.
4661 Spare,
4662 pRoamInfo->pEseBcnReportRsp->
4663 bcnRepBssInfo[i +
4664 lastSent].bcnReportFields.
4665 MeasDuration,
4666 pRoamInfo->pEseBcnReportRsp->
4667 bcnRepBssInfo[i +
4668 lastSent].bcnReportFields.
4669 PhyType,
4670 pRoamInfo->pEseBcnReportRsp->
4671 bcnRepBssInfo[i +
4672 lastSent].bcnReportFields.
4673 RecvSigPower,
4674 pRoamInfo->pEseBcnReportRsp->
4675 bcnRepBssInfo[i +
4676 lastSent].bcnReportFields.
4677 ParentTsf,
4678 pRoamInfo->pEseBcnReportRsp->
4679 bcnRepBssInfo[i +
4680 lastSent].bcnReportFields.
4681 TargetTsf[0],
4682 pRoamInfo->pEseBcnReportRsp->
4683 bcnRepBssInfo[i +
4684 lastSent].bcnReportFields.
4685 TargetTsf[1],
4686 pRoamInfo->pEseBcnReportRsp->
4687 bcnRepBssInfo[i +
4688 lastSent].bcnReportFields.
4689 BcnInterval,
4690 pRoamInfo->pEseBcnReportRsp->
4691 bcnRepBssInfo[i +
4692 lastSent].bcnReportFields.
4693 CapabilityInfo,
4694 pRoamInfo->pEseBcnReportRsp->
4695 bcnRepBssInfo[i +
4696 lastSent].bcnReportFields.
4697 Bssid[0],
4698 pRoamInfo->pEseBcnReportRsp->
4699 bcnRepBssInfo[i +
4700 lastSent].bcnReportFields.
4701 Bssid[1],
4702 pRoamInfo->pEseBcnReportRsp->
4703 bcnRepBssInfo[i +
4704 lastSent].bcnReportFields.
4705 Bssid[2],
4706 pRoamInfo->pEseBcnReportRsp->
4707 bcnRepBssInfo[i +
4708 lastSent].bcnReportFields.
4709 Bssid[3],
4710 pRoamInfo->pEseBcnReportRsp->
4711 bcnRepBssInfo[i +
4712 lastSent].bcnReportFields.
4713 Bssid[4],
4714 pRoamInfo->pEseBcnReportRsp->
4715 bcnRepBssInfo[i +
4716 lastSent].bcnReportFields.
4717 Bssid[5]);
4718
4719 /* bcn report fields are copied */
4720 len =
4721 sizeof(pRoamInfo->pEseBcnReportRsp->
4722 bcnRepBssInfo[i +
4723 lastSent].
4724 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304725 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004726 (char *)&pRoamInfo->
4727 pEseBcnReportRsp->bcnRepBssInfo[i +
4728 lastSent].
4729 bcnReportFields, len);
4730 pos += len;
4731 freeBytes -= len;
4732
4733 /* Add 1 byte of ie len */
4734 len =
4735 pRoamInfo->pEseBcnReportRsp->
4736 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304737 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004738 pos += sizeof(len);
4739 freeBytes -= sizeof(len);
4740
4741 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304742 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743 (char *)pRoamInfo->
4744 pEseBcnReportRsp->bcnRepBssInfo[i +
4745 lastSent].
4746 pBuf, len);
4747 pos += len;
4748 freeBytes -= len;
4749 }
4750
4751 wrqu.data.pointer = buf;
4752 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4753
4754 /* send the event */
4755 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4756 buf);
4757 lastSent += sendBss;
4758 }
4759 }
4760}
4761
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004762#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004763
4764/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304765 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4766 * @pHddStaCtx: Station Context
4767 *
4768 * API to check if the connection authentication type is 8021x_sha256.
4769 *
4770 * Return: bool
4771 */
4772#ifdef WLAN_FEATURE_11W
4773static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4774{
4775 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4776 pHddStaCtx->conn_info.authType;
4777}
4778#else
4779static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4780{
4781 return false;
4782}
4783#endif
4784
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304785/*
4786 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4787 * @adapter: Pointer to adapter context
4788 * @roam_info: Pointer to roam info
4789 *
4790 * Return: None
4791 */
4792static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4793 tCsrRoamInfo *roam_info)
4794{
4795 struct hdd_chan_change_params chan_change;
4796 struct cfg80211_bss *bss;
4797 struct net_device *dev = adapter->dev;
4798 struct wireless_dev *wdev = dev->ieee80211_ptr;
4799 struct wiphy *wiphy = wdev->wiphy;
4800 QDF_STATUS status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004801 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304802
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004803 hdd_debug("channel switch for session:%d to channel:%d",
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304804 adapter->sessionId, roam_info->chan_info.chan_id);
4805
4806 chan_change.chan = roam_info->chan_info.chan_id;
4807 chan_change.chan_params.ch_width =
4808 roam_info->chan_info.ch_width;
4809 chan_change.chan_params.sec_ch_offset =
4810 roam_info->chan_info.sec_ch_offset;
4811 chan_change.chan_params.center_freq_seg0 =
4812 roam_info->chan_info.band_center_freq1;
4813 chan_change.chan_params.center_freq_seg1 =
4814 roam_info->chan_info.band_center_freq2;
4815
4816 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4817 if (NULL == bss)
4818 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4819 else
4820 cfg80211_put_bss(wiphy, bss);
4821
4822 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4823 if (QDF_IS_STATUS_ERROR(status))
4824 hdd_err("channel change notification failed");
4825
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004826 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
4827 adapter->sessionId);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304828 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004829 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304830}
4831
Komal Seelam98760ba2015-12-15 11:05:18 +05304832/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004833 * hdd_sme_roam_callback() - hdd sme roam callback
4834 * @pContext: pointer to adapter context
4835 * @pRoamInfo: pointer to roam info
4836 * @roamId: roam id
4837 * @roamStatus: roam status
4838 * @roamResult: roam result
4839 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304840 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304842QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4844 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4845{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304846 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4848 hdd_wext_state_t *pWextState = NULL;
4849 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304850 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304851 struct cfg80211_bss *bss_status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004852 hdd_context_t *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004853
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004854 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004855 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856
4857 /* Sanity check */
4858 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004859 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304860 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861 }
4862
4863 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4864 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004865 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304867 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4868 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4869 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4870 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304871
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004872 switch (roamStatus) {
4873 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304874 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4875 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004876 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877 break;
4878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004879 /*
4880 * We did pre-auth,then we attempted a 11r or ese reassoc.
4881 * reassoc failed due to failure, timeout, reject from ap
4882 * in any case tell the OS, our carrier is off and mark
4883 * interface down.
4884 */
4885 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004886 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4887 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304888 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4890 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004891 pHddStaCtx->ft_carrier_on = false;
4892 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004893 hdd_debug("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004894 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004895 break;
4896
4897 case eCSR_ROAM_FT_START:
4898 /*
4899 * When we roam for ESE and 11r, we dont want the OS to be
4900 * informed that the link is down. So mark the link ready for
4901 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4902 * be received. Where in we will not mark the link down
4903 * Also we want to stop tx at this point when we will be
4904 * doing disassoc at this time. This saves 30-60 msec
4905 * after reassoc.
4906 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004907 hdd_info("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004908 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004909 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004910 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304911 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004912 WLAN_CONTROL_PATH);
4913 status = hdd_roam_deregister_sta(pAdapter,
4914 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304915 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304916 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004917 pHddStaCtx->ft_carrier_on = true;
4918 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004919 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4920 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004922 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004923 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004924 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004925 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304926 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
4927 pAdapter->roam_ho_fail = true;
4928 else
4929 pAdapter->roam_ho_fail = false;
4930 complete(&pAdapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004931 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004934 hdd_debug("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304936 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 wlan_hdd_netif_queue_control(pAdapter,
4940 WLAN_NETIF_CARRIER_OFF,
4941 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004942 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004943 break;
4944 case eCSR_ROAM_LOSTLINK:
4945 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004946 hdd_debug("Roaming started due to connection lost");
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004947 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304949 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004950 WLAN_CONTROL_PATH);
4951 break;
4952 }
4953 case eCSR_ROAM_DISASSOCIATED:
4954 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004955 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304956 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07004957 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304958 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304959 pAdapter->roam_ho_fail = false;
4960 complete(&pAdapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304961
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004962 /* Call to clear any MC Addr List filter applied after
4963 * successful connection.
4964 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304965 hdd_disable_and_flush_mc_addr_list(pAdapter,
4966 pmo_peer_disconnect);
4967 qdf_ret_status =
4968 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4969 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004970 }
4971 break;
4972 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004973 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304974 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004975 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4976 roamStatus, roamResult);
4977 break;
4978 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004979 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 /*
4981 * To Do - address probable memory leak with WEP encryption upon
4982 * successful association.
4983 */
4984 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4985 /* Clear saved connection information in HDD */
4986 hdd_conn_remove_connect_info(
4987 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4988 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304989 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004990 hdd_association_completion_handler(pAdapter, pRoamInfo,
4991 roamId, roamStatus,
4992 roamResult);
4993#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4994 if (pRoamInfo)
4995 pRoamInfo->roamSynchInProgress = false;
4996#endif
4997 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004998 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004999 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305001 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002 pRoamInfo,
5003 roamId,
5004 roamStatus,
5005 roamResult);
5006 break;
5007 case eCSR_ROAM_IBSS_IND:
5008 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
5009 roamStatus, roamResult);
5010 break;
5011
5012 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305013 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 roam_roam_connect_status_update_handler(pAdapter,
5015 pRoamInfo,
5016 roamId,
5017 roamStatus,
5018 roamResult);
5019 break;
5020
5021 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305022 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005023 hdd_roam_mic_error_indication_handler(pAdapter,
5024 pRoamInfo,
5025 roamId,
5026 roamStatus,
5027 roamResult);
5028 break;
5029
5030 case eCSR_ROAM_SET_KEY_COMPLETE:
5031 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305032 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005033 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
5034 roamId, roamStatus,
5035 roamResult);
5036 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
5037 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005038 hdd_debug("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005039 pHddStaCtx->hdd_ReassocScenario,
5040 pAdapter->sessionId);
5041 }
5042 }
5043#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5044 if (pRoamInfo != NULL)
5045 pRoamInfo->roamSynchInProgress = false;
5046#endif
5047 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005049 case eCSR_ROAM_FT_RESPONSE:
5050 hdd_send_ft_event(pAdapter);
5051 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005052
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005053 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05305054 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
5055 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005056 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305057 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058 wlan_hdd_cfg80211_pmksa_candidate_notify(
5059 pAdapter, pRoamInfo, 1, false);
5060 }
5061 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062
5063#ifdef FEATURE_WLAN_LFR_METRICS
5064 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
5065 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305066 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005067 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
5068 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305069 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005070 }
5071 break;
5072 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
5073 /*
5074 * This event will notify pre-auth completion in case of success
5075 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305076 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5078 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305079 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005080 }
5081 break;
5082 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
5083 /*
5084 * This event will notify pre-auth completion incase of failure.
5085 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305086 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005087 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5088 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305089 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005090 }
5091 break;
5092 case eCSR_ROAM_HANDOVER_SUCCESS:
5093 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08005094 * It will be only invoked on success
5095 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305096 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005097 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
5098 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305099 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 }
5101 break;
5102#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005103 case eCSR_ROAM_REMAIN_CHAN_READY:
5104 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
5105 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106#ifdef FEATURE_WLAN_TDLS
5107 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305108 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
5110 roamId,
5111 roamStatus,
5112 roamResult);
5113 break;
5114 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
5115 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
5116 pRoamInfo->reasonCode);
5117 break;
5118#endif
5119#ifdef WLAN_FEATURE_11W
5120 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
5121 hdd_indicate_unprot_mgmt_frame(pAdapter,
5122 pRoamInfo->nFrameLength,
5123 pRoamInfo->pbFrames,
5124 pRoamInfo->frameType);
5125 break;
5126#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005127#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005128 case eCSR_ROAM_TSM_IE_IND:
5129 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5130 pRoamInfo->tsmIe.state,
5131 pRoamInfo->tsmIe.msmt_interval);
5132 break;
5133
5134 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5135 {
5136 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5137 pHddStaCtx->conn_info.authType
5138 || eCSR_AUTH_TYPE_CCKM_RSN ==
5139 pHddStaCtx->conn_info.authType) {
5140 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5141 }
5142 break;
5143 }
5144
5145 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5146 {
5147 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5148 break;
5149 }
5150
5151 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5152 {
5153 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5154 break;
5155 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005156#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305157 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305158 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305159 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305160
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305161 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5162 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5163 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5164 pAdapter, pRoamInfo->pBssDesc);
5165 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005166 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305167 else
5168 cfg80211_put_bss(
5169#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5170 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5171#endif
5172 bss_status);
5173 }
5174 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005175 case eCSR_ROAM_NDP_STATUS_UPDATE:
5176 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5177 roamResult);
5178 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005179 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005180 hdd_debug("Process ROAM_START from firmware");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005181 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305182 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005183 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005184 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005185 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005186 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08005187 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005188 break;
5189 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005190 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005191 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005192 wlan_hdd_netif_queue_control(pAdapter,
5193 WLAN_WAKE_ALL_NETIF_QUEUE,
5194 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005195 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005196 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305197 pAdapter->roam_ho_fail = false;
5198 complete(&pAdapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005199 break;
5200
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005201 default:
5202 break;
5203 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305204 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205}
5206
5207/**
5208 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5209 * @auth_suite: auth suite
5210 *
5211 * Return: eCsrAuthType enumeration
5212 */
5213eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5214{
5215 eCsrAuthType auth_type;
5216 /* is the auth type supported? */
5217 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5218 auth_type = eCSR_AUTH_TYPE_RSN;
5219 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5220 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005221 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005222 /* Check for 11r FT Authentication with PSK */
5223 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5224 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5225 /* Check for 11R FT Authentication with 802.1X */
5226 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5227 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005228#ifdef FEATURE_WLAN_ESE
5229 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5230 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5231 } else
5232#endif /* FEATURE_WLAN_ESE */
5233#ifdef WLAN_FEATURE_11W
5234 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5235 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5236 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5237 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5238 } else
5239#endif
5240 {
5241 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5242 }
5243 return auth_type;
5244}
5245
5246/**
5247 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5248 * @auth_suite: auth suite
5249 *
5250 * Return: eCsrAuthType enumeration
5251 */
5252eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5253{
5254 eCsrAuthType auth_type;
5255 /* is the auth type supported? */
5256 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5257 auth_type = eCSR_AUTH_TYPE_WPA;
5258 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5259 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5260 } else
5261#ifdef FEATURE_WLAN_ESE
5262 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5263 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5264 } else
5265#endif /* FEATURE_WLAN_ESE */
5266 {
5267 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5268 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005269 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005270 return auth_type;
5271}
5272
5273/**
5274 * hdd_translate_rsn_to_csr_encryption_type() -
5275 * Translate RSN to CSR encryption type
5276 * @cipher_suite: cipher suite
5277 *
5278 * Return: eCsrEncryptionType enumeration
5279 */
5280eCsrEncryptionType
5281hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5282{
5283 eCsrEncryptionType cipher_type;
5284
5285 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5286 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5287 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5288 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5289 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5290 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5291 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5292 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5293 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5294 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5295 else
5296 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5297
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005298 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005299 return cipher_type;
5300}
5301
5302/**
5303 * hdd_translate_wpa_to_csr_encryption_type() -
5304 * Translate WPA to CSR encryption type
5305 * @cipher_suite: cipher suite
5306 *
5307 * Return: eCsrEncryptionType enumeration
5308 */
5309eCsrEncryptionType
5310hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5311{
5312 eCsrEncryptionType cipher_type;
5313
5314 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5315 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5316 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5317 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5318 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5319 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5320 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5321 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5322 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5323 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5324 else
5325 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5326
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005327 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 return cipher_type;
5329}
5330
5331/**
5332 * hdd_process_genie() - process gen ie
5333 * @pAdapter: pointer to adapter
5334 * @bssid: pointer to mac address
5335 * @pEncryptType: pointer to encryption type
5336 * @mcEncryptType: pointer to multicast encryption type
5337 * @pAuthType: pointer to auth type
5338 *
5339 * Return: 0 on success, error number otherwise
5340 */
5341static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5342 u8 *bssid,
5343 eCsrEncryptionType *pEncryptType,
5344 eCsrEncryptionType *mcEncryptType,
5345 eCsrAuthType *pAuthType,
5346#ifdef WLAN_FEATURE_11W
5347 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5348#endif
5349 uint16_t gen_ie_len, uint8_t *gen_ie)
5350{
5351 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305352 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005353 tDot11fIERSN dot11RSNIE;
5354 tDot11fIEWPA dot11WPAIE;
5355 uint32_t i;
5356 uint8_t *pRsnIe;
5357 uint16_t RSNIeLen;
5358 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5359 bool updatePMKCache = false;
5360
5361 /*
5362 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5363 * setting present flag to 0.
5364 */
5365 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5366 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5367
5368 /* Type check */
5369 if (gen_ie[0] == DOT11F_EID_RSN) {
5370 /* Validity checks */
5371 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5372 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005373 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005374 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 return -EINVAL;
5376 }
5377 /* Skip past the EID byte and length byte */
5378 pRsnIe = gen_ie + 2;
5379 RSNIeLen = gen_ie_len - 2;
5380 /* Unpack the RSN IE */
5381 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305382 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005383 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005384 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005385 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005386 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005387 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005388 /* dot11RSNIE.akm_suite_count */
5389 /* Just translate the FIRST one */
5390 *pAuthType =
5391 hdd_translate_rsn_to_csr_auth_type(
5392 dot11RSNIE.akm_suites[0]);
5393 /* dot11RSNIE.pwise_cipher_suite_count */
5394 *pEncryptType =
5395 hdd_translate_rsn_to_csr_encryption_type(
5396 dot11RSNIE.pwise_cipher_suites[0]);
5397 /* dot11RSNIE.gp_cipher_suite_count */
5398 *mcEncryptType =
5399 hdd_translate_rsn_to_csr_encryption_type(
5400 dot11RSNIE.gp_cipher_suite);
5401#ifdef WLAN_FEATURE_11W
5402 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5403 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5404#endif
5405 /* Set the PMKSA ID Cache for this interface */
5406 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5407 if (is_zero_ether_addr(bssid)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005408 hdd_warn("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005409 break;
5410 }
5411 updatePMKCache = true;
5412 /*
5413 * For right now, I assume setASSOCIATE() has passed
5414 * in the bssid.
5415 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305416 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305417 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305418 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5420 }
5421
5422 if (updatePMKCache) {
5423 /*
5424 * Calling csr_roam_set_pmkid_cache to configure the
5425 * PMKIDs into the cache.
5426 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005427 hdd_debug("Calling sme_roam_set_pmkid_cache with cache entry %d.",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005428 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005429 /* Finally set the PMKSA ID Cache in CSR */
5430 result =
5431 sme_roam_set_pmkid_cache(halHandle,
5432 pAdapter->sessionId,
5433 PMKIDCache,
5434 dot11RSNIE.pmkid_count,
5435 false);
5436 }
5437 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5438 /* Validity checks */
5439 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5440 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005441 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005442 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005443 return -EINVAL;
5444 }
5445 /* Skip past the EID and length byte - and four byte WiFi OUI */
5446 pRsnIe = gen_ie + 2 + 4;
5447 RSNIeLen = gen_ie_len - (2 + 4);
5448 /* Unpack the WPA IE */
5449 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305450 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005452 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005453 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005454 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005455 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456 /* dot11WPAIE.auth_suite_count */
5457 /* Just translate the FIRST one */
5458 *pAuthType =
5459 hdd_translate_wpa_to_csr_auth_type(
5460 dot11WPAIE.auth_suites[0]);
5461 /* dot11WPAIE.unicast_cipher_count */
5462 *pEncryptType =
5463 hdd_translate_wpa_to_csr_encryption_type(
5464 dot11WPAIE.unicast_ciphers[0]);
5465 /* dot11WPAIE.unicast_cipher_count */
5466 *mcEncryptType =
5467 hdd_translate_wpa_to_csr_encryption_type(
5468 dot11WPAIE.multicast_cipher);
5469 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005470 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005471 return -EINVAL;
5472 }
5473 return 0;
5474}
5475
5476/**
5477 * hdd_set_genie_to_csr() - set genie to csr
5478 * @pAdapter: pointer to adapter
5479 * @RSNAuthType: pointer to auth type
5480 *
5481 * Return: 0 on success, error number otherwise
5482 */
5483int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5484{
5485 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5486 uint32_t status = 0;
5487 eCsrEncryptionType RSNEncryptType;
5488 eCsrEncryptionType mcRSNEncryptType;
5489#ifdef WLAN_FEATURE_11W
5490 uint8_t RSNMfpRequired = 0;
5491 uint8_t RSNMfpCapable = 0;
5492#endif
5493 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5494 /* MAC address of assoc peer */
5495 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305496 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005497 pWextState->roamProfile.BSSIDs.bssid,
5498 sizeof(bssid));
5499 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5500 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5501 /* continue */
5502 } else {
5503 return 0;
5504 }
5505 /* The actual processing may eventually be more extensive than this. */
5506 /* Right now, just consume any PMKIDs that are sent in by the app. */
5507 status = hdd_process_genie(pAdapter, bssid,
5508 &RSNEncryptType,
5509 &mcRSNEncryptType, RSNAuthType,
5510#ifdef WLAN_FEATURE_11W
5511 &RSNMfpRequired, &RSNMfpCapable,
5512#endif
5513 pWextState->WPARSNIE[1] + 2,
5514 pWextState->WPARSNIE);
5515 if (status == 0) {
5516 /*
5517 * Now copy over all the security attributes
5518 * you have parsed out.
5519 */
5520 pWextState->roamProfile.EncryptionType.numEntries = 1;
5521 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5522
5523 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5524 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5525 mcRSNEncryptType;
5526
Krunal Sonibe766b02016-03-10 13:00:44 -08005527 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005528 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5529 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5530 /*
5531 * For wpa none supplicant sends the WPA IE with unicast
5532 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5533 * multicast cipher as either AES/TKIP based on group
5534 * cipher configuration mentioned in the
5535 * wpa_supplicant.conf.
5536 */
5537
5538 /* Set the unicast cipher same as multicast cipher */
5539 pWextState->roamProfile.EncryptionType.encryptionType[0]
5540 = mcRSNEncryptType;
5541 }
5542#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005543 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005544 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005545 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5546 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5547#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005548 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005549 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550 }
5551 return 0;
5552}
5553
5554/**
5555 * hdd_set_csr_auth_type() - set csr auth type
5556 * @pAdapter: pointer to adapter
5557 * @RSNAuthType: auth type
5558 *
5559 * Return: 0 on success, error number otherwise
5560 */
5561int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5562{
5563 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5564 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5565 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005566
5567 pRoamProfile->AuthType.numEntries = 1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005568 hdd_debug("pHddStaCtx->conn_info.authType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005569 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005570
5571 switch (pHddStaCtx->conn_info.authType) {
5572 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5573#ifdef FEATURE_WLAN_ESE
5574 case eCSR_AUTH_TYPE_CCKM_WPA:
5575 case eCSR_AUTH_TYPE_CCKM_RSN:
5576#endif
5577 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5578
5579 pRoamProfile->AuthType.authType[0] =
5580 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5581 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5582
5583#ifdef FEATURE_WLAN_ESE
5584 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5585 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5586 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005587 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588 pRoamProfile->AuthType.authType[0] =
5589 eCSR_AUTH_TYPE_CCKM_WPA;
5590 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005591 hdd_debug("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 pRoamProfile->AuthType.authType[0] =
5593 eCSR_AUTH_TYPE_CCKM_WPA;
5594 } else
5595#endif
5596 if ((pWextState->
5597 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5598 == IW_AUTH_KEY_MGMT_802_1X) {
5599 pRoamProfile->AuthType.authType[0] =
5600 eCSR_AUTH_TYPE_WPA;
5601 } else
5602 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5603 == IW_AUTH_KEY_MGMT_PSK) {
5604 pRoamProfile->AuthType.authType[0] =
5605 eCSR_AUTH_TYPE_WPA_PSK;
5606 } else {
5607 pRoamProfile->AuthType.authType[0] =
5608 eCSR_AUTH_TYPE_WPA_NONE;
5609 }
5610 }
5611 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5612#ifdef FEATURE_WLAN_ESE
5613 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5614 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5615 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005616 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 pRoamProfile->AuthType.authType[0] =
5618 eCSR_AUTH_TYPE_CCKM_RSN;
5619 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005620 hdd_debug("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005621 pRoamProfile->AuthType.authType[0] =
5622 eCSR_AUTH_TYPE_CCKM_RSN;
5623 } else
5624#endif
5625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005626 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5627 ((pWextState->
5628 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5629 == IW_AUTH_KEY_MGMT_802_1X)) {
5630 pRoamProfile->AuthType.authType[0] =
5631 eCSR_AUTH_TYPE_FT_RSN;
5632 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5633 &&
5634 ((pWextState->
5635 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5636 == IW_AUTH_KEY_MGMT_PSK)) {
5637 pRoamProfile->AuthType.authType[0] =
5638 eCSR_AUTH_TYPE_FT_RSN_PSK;
5639 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640
5641#ifdef WLAN_FEATURE_11W
5642 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5643 pRoamProfile->AuthType.authType[0] =
5644 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5645 } else if (RSNAuthType ==
5646 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5647 pRoamProfile->AuthType.authType[0] =
5648 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5649 } else
5650#endif
5651
5652 if ((pWextState->
5653 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5654 == IW_AUTH_KEY_MGMT_802_1X) {
5655 pRoamProfile->AuthType.authType[0] =
5656 eCSR_AUTH_TYPE_RSN;
5657 } else
5658 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5659 == IW_AUTH_KEY_MGMT_PSK) {
5660 pRoamProfile->AuthType.authType[0] =
5661 eCSR_AUTH_TYPE_RSN_PSK;
5662 } else {
5663 pRoamProfile->AuthType.authType[0] =
5664 eCSR_AUTH_TYPE_UNKNOWN;
5665 }
5666 }
5667 break;
5668
5669 case eCSR_AUTH_TYPE_SHARED_KEY:
5670
5671 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5672 break;
5673 default:
5674
5675#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005676 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005677#endif /* FEATURE_WLAN_ESE */
5678 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5679 break;
5680 }
5681
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005682 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005683 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005684
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005685 return 0;
5686}
5687
5688/**
5689 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5690 * to the CSR roam profile.
5691 *
5692 * @dev: Pointer to the net device.
5693 * @info: Pointer to the iw_request_info.
5694 * @wrqu: Pointer to the iwreq_data.
5695 * @extra: Pointer to the data.
5696 *
5697 * Return: 0 for success, error number on failure
5698 */
5699static int __iw_set_essid(struct net_device *dev,
5700 struct iw_request_info *info,
5701 union iwreq_data *wrqu, char *extra)
5702{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005703 uint32_t status = 0;
5704 hdd_wext_state_t *pWextState;
5705 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5706 hdd_context_t *hdd_ctx;
5707 uint32_t roamId;
5708 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005709 eCsrAuthType RSNAuthType;
5710 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005711 int ret;
5712
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005713 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005714
5715 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5716 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305717 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005718 return ret;
5719
Jeff Johnson441e1f72017-02-07 08:50:49 -08005720 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5721 if (0 != ret)
5722 return ret;
5723
Krunal Sonibe766b02016-03-10 13:00:44 -08005724 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005725 pAdapter->device_mode != QDF_IBSS_MODE &&
5726 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005727 hdd_warn("device mode %s(%d) is not allowed",
5728 hdd_device_mode_to_string(pAdapter->device_mode),
5729 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730 return -EINVAL;
5731 }
5732
5733 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5734
5735 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005736 hdd_warn("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005737 return -EBUSY;
5738 }
5739 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5740 return -EINVAL;
5741
5742 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305743 /*Try disconnecting if already in connected state*/
5744 status = wlan_hdd_try_disconnect(pAdapter);
5745 if (0 > status) {
5746 hdd_err("Failed to disconnect the existing connection");
5747 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005748 }
5749
5750 /*
5751 * when cfg80211 defined, wpa_supplicant wext driver uses
5752 * zero-length, null-string ssid for force disconnection.
5753 * after disconnection (if previously connected) and cleaning ssid,
5754 * driver MUST return success.
5755 */
5756 if (0 == wrqu->essid.length)
5757 return 0;
5758
5759 status = hdd_wmm_get_uapsd_mask(pAdapter,
5760 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305761 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005762 pWextState->roamProfile.uapsd_mask = 0;
5763
5764 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5765
5766 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5767 wrqu->essid.length;
5768
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305769 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005770 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305771 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005772 ssId), extra, wrqu->essid.length);
5773 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5774 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5775
5776 /* set gen ie */
5777 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5778
5779 /* set auth */
5780 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5781 }
5782#ifdef FEATURE_WLAN_WAPI
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005783 hdd_debug("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 if (pAdapter->wapi_info.nWapiMode) {
5785 switch (pAdapter->wapi_info.wapiAuthMode) {
5786 case WAPI_AUTH_MODE_PSK:
5787 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005788 hdd_debug("WAPI AUTH TYPE: PSK: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005789 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005790 pRoamProfile->AuthType.numEntries = 1;
5791 pRoamProfile->AuthType.authType[0] =
5792 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5793 break;
5794 }
5795 case WAPI_AUTH_MODE_CERT:
5796 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005797 hdd_debug("WAPI AUTH TYPE: CERT: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005798 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005799 pRoamProfile->AuthType.numEntries = 1;
5800 pRoamProfile->AuthType.authType[0] =
5801 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5802 break;
5803 }
5804 } /* End of switch */
5805 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5806 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005807 hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005808 pRoamProfile->EncryptionType.numEntries = 1;
5809 pRoamProfile->EncryptionType.encryptionType[0] =
5810 eCSR_ENCRYPT_TYPE_WPI;
5811 pRoamProfile->mcEncryptionType.numEntries = 1;
5812 pRoamProfile->mcEncryptionType.encryptionType[0] =
5813 eCSR_ENCRYPT_TYPE_WPI;
5814 }
5815 }
5816#endif /* FEATURE_WLAN_WAPI */
5817 /* if previous genIE is not NULL, update AssocIE */
5818 if (0 != pWextState->genIE.length) {
5819 memset(&pWextState->assocAddIE, 0,
5820 sizeof(pWextState->assocAddIE));
5821 memcpy(pWextState->assocAddIE.addIEdata,
5822 pWextState->genIE.addIEdata, pWextState->genIE.length);
5823 pWextState->assocAddIE.length = pWextState->genIE.length;
5824 pWextState->roamProfile.pAddIEAssoc =
5825 pWextState->assocAddIE.addIEdata;
5826 pWextState->roamProfile.nAddIEAssocLength =
5827 pWextState->assocAddIE.length;
5828
5829 /* clear previous genIE after use it */
5830 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5831 }
5832
5833 /*
5834 * Assumes it is not WPS Association by default, except when
5835 * pAddIEAssoc has WPS IE.
5836 */
5837 pWextState->roamProfile.bWPSAssociation = false;
5838
5839 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5840 pWextState->roamProfile.
5841 nAddIEAssocLength))
5842 pWextState->roamProfile.bWPSAssociation = true;
5843
5844 /* Disable auto BMPS entry by PMC until DHCP is done */
5845 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5846 true);
5847
5848 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5849
5850 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005851 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005852 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005853 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5854 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005855 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005856
Agrawal Ashish6b015762016-05-05 11:22:18 +05305857 /*
5858 * Change conn_state to connecting before sme_roam_connect(),
5859 * because sme_roam_connect() has a direct path to call
5860 * hdd_sme_roam_callback(), which will change the conn_state
5861 * If direct path, conn_state will be accordingly changed to
5862 * NotConnected or Associated by either
5863 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5864 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5865 * Connecting state will remain until it is completed.
5866 *
5867 * If connection state is not changed,
5868 * connection state will remain in eConnectionState_NotConnected state.
5869 * In hdd_association_completion_handler, "hddDisconInProgress" is
5870 * set to true if conn state is eConnectionState_NotConnected.
5871 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5872 * informed of connect result indication which is an issue.
5873 */
5874 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305875 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305876 hdd_conn_set_connection_state(pAdapter,
5877 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305878
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005879 status = sme_roam_connect(hHal, pAdapter->sessionId,
5880 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305881 if ((QDF_STATUS_SUCCESS != status) &&
5882 (QDF_STA_MODE == pAdapter->device_mode ||
5883 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005884 hdd_err("sme_roam_connect failed session_id: %d status %d -> NotConnected",
Agrawal Ashish6b015762016-05-05 11:22:18 +05305885 pAdapter->sessionId, status);
5886 /* change back to NotAssociated */
5887 hdd_conn_set_connection_state(pAdapter,
5888 eConnectionState_NotConnected);
5889 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005890 pRoamProfile->ChannelInfo.ChannelList = NULL;
5891 pRoamProfile->ChannelInfo.numOfChannels = 0;
5892
5893 EXIT();
5894 return status;
5895}
5896
5897/**
5898 * iw_set_essid() - set essid handler function
5899 * @dev: Pointer to the net device.
5900 * @info: Pointer to the iw_request_info.
5901 * @wrqu: Pointer to the iwreq_data.
5902 * @extra: Pointer to the data.
5903 *
5904 * Return: 0 for success, error number on failure
5905 */
5906int iw_set_essid(struct net_device *dev,
5907 struct iw_request_info *info,
5908 union iwreq_data *wrqu, char *extra)
5909{
5910 int ret;
5911
5912 cds_ssr_protect(__func__);
5913 ret = __iw_set_essid(dev, info, wrqu, extra);
5914 cds_ssr_unprotect(__func__);
5915
5916 return ret;
5917}
5918
5919/**
5920 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5921 * @dev: pointer to the net device
5922 * @info: pointer to the iw request info
5923 * @dwrq: pointer to iw_point
5924 * @extra: pointer to the data
5925 *
5926 * Return: 0 on success, error number otherwise
5927 */
5928static int __iw_get_essid(struct net_device *dev,
5929 struct iw_request_info *info,
5930 struct iw_point *dwrq, char *extra)
5931{
5932 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5933 hdd_context_t *hdd_ctx;
5934 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5935 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5936 int ret;
5937
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005938 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005939
5940 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5941 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305942 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 return ret;
5944
Jeff Johnson441e1f72017-02-07 08:50:49 -08005945 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5946 if (0 != ret)
5947 return ret;
5948
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005949 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5950 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5951 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5952 || pHddStaCtx->conn_info.connState ==
5953 eConnectionState_IbssDisconnected)
5954 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5955 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5956 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5957 dwrq->length);
5958 dwrq->flags = 1;
5959 } else {
5960 memset(extra, 0, dwrq->length);
5961 dwrq->length = 0;
5962 dwrq->flags = 0;
5963 }
5964 EXIT();
5965 return 0;
5966}
5967
5968/**
5969 * iw_get_essid() - get essid handler function
5970 * @dev: Pointer to the net device.
5971 * @info: Pointer to the iw_request_info.
5972 * @wrqu: Pointer to the iwreq_data.
5973 * @extra: Pointer to the data.
5974 *
5975 * Return: 0 for success, error number on failure
5976 */
5977int iw_get_essid(struct net_device *dev,
5978 struct iw_request_info *info,
5979 struct iw_point *wrqu, char *extra)
5980{
5981 int ret;
5982
5983 cds_ssr_protect(__func__);
5984 ret = __iw_get_essid(dev, info, wrqu, extra);
5985 cds_ssr_unprotect(__func__);
5986
5987 return ret;
5988}
5989
5990/**
5991 * __iw_set_auth() -
5992 * This function sets the auth type received from the wpa_supplicant
5993 * @dev: pointer to the net device
5994 * @info: pointer to the iw request info
5995 * @wrqu: pointer to iwreq_data
5996 * @extra: pointer to the data
5997 *
5998 * Return: 0 on success, error number otherwise
5999 */
6000static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6001 union iwreq_data *wrqu, char *extra)
6002{
6003 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6004 hdd_context_t *hdd_ctx;
6005 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6006 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6007 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6008 eCsrEncryptionType mcEncryptionType;
6009 eCsrEncryptionType ucEncryptionType;
6010 int ret;
6011
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006012 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006013
6014 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6015 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306016 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006017 return ret;
6018
Jeff Johnson441e1f72017-02-07 08:50:49 -08006019 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6020 if (0 != ret)
6021 return ret;
6022
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006023 switch (wrqu->param.flags & IW_AUTH_INDEX) {
6024 case IW_AUTH_WPA_VERSION:
6025 pWextState->wpaVersion = wrqu->param.value;
6026 break;
6027
6028 case IW_AUTH_CIPHER_PAIRWISE:
6029 {
6030 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6031 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6032 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6033 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6034 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6035 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6036 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6037 if ((IW_AUTH_KEY_MGMT_802_1X
6038 ==
6039 (pWextState->
6040 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6041 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6042 pHddStaCtx->conn_info.authType))
6043 /*Dynamic WEP key */
6044 ucEncryptionType =
6045 eCSR_ENCRYPT_TYPE_WEP40;
6046 else
6047 /*Static WEP key */
6048 ucEncryptionType =
6049 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6050 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6051 if ((IW_AUTH_KEY_MGMT_802_1X
6052 ==
6053 (pWextState->
6054 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6055 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6056 pHddStaCtx->conn_info.authType))
6057 /*Dynamic WEP key */
6058 ucEncryptionType =
6059 eCSR_ENCRYPT_TYPE_WEP104;
6060 else
6061 /*Static WEP key */
6062 ucEncryptionType =
6063 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6064 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006065 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
6066 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006067 return -EINVAL;
6068 }
6069
6070 pRoamProfile->EncryptionType.numEntries = 1;
6071 pRoamProfile->EncryptionType.encryptionType[0] =
6072 ucEncryptionType;
6073 }
6074 break;
6075 case IW_AUTH_CIPHER_GROUP:
6076 {
6077 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6078 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6079 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6080 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6081 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6082 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6083 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6084 if ((IW_AUTH_KEY_MGMT_802_1X
6085 ==
6086 (pWextState->
6087 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6088 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6089 pHddStaCtx->conn_info.authType))
6090 mcEncryptionType =
6091 eCSR_ENCRYPT_TYPE_WEP40;
6092 else
6093 mcEncryptionType =
6094 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6095 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6096 /* Dynamic WEP keys won't work with shared keys */
6097 if ((IW_AUTH_KEY_MGMT_802_1X
6098 ==
6099 (pWextState->
6100 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6101 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6102 pHddStaCtx->conn_info.authType)) {
6103 mcEncryptionType =
6104 eCSR_ENCRYPT_TYPE_WEP104;
6105 } else {
6106 mcEncryptionType =
6107 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6108 }
6109 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006110 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 wrqu->param.value);
6112 return -EINVAL;
6113 }
6114
6115 pRoamProfile->mcEncryptionType.numEntries = 1;
6116 pRoamProfile->mcEncryptionType.encryptionType[0] =
6117 mcEncryptionType;
6118 }
6119 break;
6120
6121 case IW_AUTH_80211_AUTH_ALG:
6122 {
Jeff Johnson5a062372017-01-12 09:51:25 -08006123 /* Save the auth algo here and set auth type to SME
6124 * Roam profile in the iw_set_ap_address
6125 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006126 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6127 pHddStaCtx->conn_info.authType =
6128 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6129
6130 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6131 pHddStaCtx->conn_info.authType =
6132 eCSR_AUTH_TYPE_SHARED_KEY;
6133
6134 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6135 /*Not supported */
6136 pHddStaCtx->conn_info.authType =
6137 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6138 pWextState->roamProfile.AuthType.authType[0] =
6139 pHddStaCtx->conn_info.authType;
6140 }
6141 break;
6142
6143 case IW_AUTH_KEY_MGMT:
6144 {
6145#ifdef FEATURE_WLAN_ESE
6146#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6147 /*Check for CCKM AKM type */
6148 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006149 hdd_debug("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006150 /* Set the CCKM bit in authKeyMgmt */
6151 /*
6152 * Right now, this breaks all ref to authKeyMgmt because
6153 * our code doesn't realize it is a "bitfield"
6154 */
6155 pWextState->authKeyMgmt |=
6156 IW_AUTH_KEY_MGMT_CCKM;
6157 /* Set the key management to 802.1X */
6158 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
6159 pWextState->isESEConnection = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006160 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6161 /* Save the key management */
6162 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006163 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164 /* Save the key management anyway */
6165 pWextState->authKeyMgmt = wrqu->param.value;
6166 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6167 /* Save the key management */
6168 pWextState->authKeyMgmt |=
6169 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006170 }
6171#else
6172 /* Save the key management */
6173 pWextState->authKeyMgmt = wrqu->param.value;
6174#endif /* FEATURE_WLAN_ESE */
6175 }
6176 break;
6177
6178 case IW_AUTH_TKIP_COUNTERMEASURES:
6179 {
6180 if (wrqu->param.value) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006181 hdd_debug("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006182 wrqu->param.value);
6183 pWextState->mTKIPCounterMeasures =
6184 TKIP_COUNTER_MEASURE_STARTED;
6185 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006186 hdd_debug("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006187 wrqu->param.value);
6188 pWextState->mTKIPCounterMeasures =
6189 TKIP_COUNTER_MEASURE_STOPED;
6190 }
6191 }
6192 break;
6193 case IW_AUTH_DROP_UNENCRYPTED:
6194 case IW_AUTH_WPA_ENABLED:
6195 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6196 case IW_AUTH_ROAMING_CONTROL:
6197 case IW_AUTH_PRIVACY_INVOKED:
6198
6199 default:
6200
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006201 hdd_warn("called with unsupported auth type %d",
6202 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 break;
6204 }
6205
6206 EXIT();
6207 return 0;
6208}
6209
6210/**
6211 * iw_set_auth() - set auth callback function
6212 * @dev: Pointer to the net device.
6213 * @info: Pointer to the iw_request_info.
6214 * @wrqu: Pointer to the iwreq_data.
6215 * @extra: Pointer to the data.
6216 *
6217 * Return: 0 for success, error number on failure.
6218 */
6219int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6220 union iwreq_data *wrqu, char *extra)
6221{
6222 int ret;
6223
6224 cds_ssr_protect(__func__);
6225 ret = __iw_set_auth(dev, info, wrqu, extra);
6226 cds_ssr_unprotect(__func__);
6227
6228 return ret;
6229}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006230/**
6231 * __iw_get_auth() -
6232 * This function returns the auth type to the wpa_supplicant
6233 * @dev: pointer to the net device
6234 * @info: pointer to the iw request info
6235 * @wrqu: pointer to iwreq_data
6236 * @extra: pointer to the data
6237 *
6238 * Return: 0 on success, error number otherwise
6239 */
6240static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6241 union iwreq_data *wrqu, char *extra)
6242{
6243 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6244 hdd_context_t *hdd_ctx;
6245 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6246 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6247 int ret;
6248
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006249 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006250
6251 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6252 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306253 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006254 return ret;
6255
Jeff Johnson441e1f72017-02-07 08:50:49 -08006256 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6257 if (0 != ret)
6258 return ret;
6259
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006260 switch (pRoamProfile->negotiatedAuthType) {
6261 case eCSR_AUTH_TYPE_WPA_NONE:
6262 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6263 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6264 break;
6265 case eCSR_AUTH_TYPE_WPA:
6266 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6267 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6268 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006269
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006271 case eCSR_AUTH_TYPE_RSN:
6272 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6273 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6274 break;
6275 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6276 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6277 break;
6278 case eCSR_AUTH_TYPE_SHARED_KEY:
6279 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6280 break;
6281 case eCSR_AUTH_TYPE_UNKNOWN:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006282 hdd_debug("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006283 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6284 break;
6285 case eCSR_AUTH_TYPE_AUTOSWITCH:
6286 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6287 break;
6288 case eCSR_AUTH_TYPE_WPA_PSK:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006289 hdd_debug("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006290 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6291 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006292
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006293 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006294 case eCSR_AUTH_TYPE_RSN_PSK:
6295#ifdef WLAN_FEATURE_11W
6296 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6297 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6298#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006299 hdd_debug("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006300 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6301 return -EIO;
6302 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006303 hdd_warn("Unknown auth type: %d",
6304 pRoamProfile->negotiatedAuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006305 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6306 return -EIO;
6307 }
6308 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6309 switch (pRoamProfile->negotiatedUCEncryptionType) {
6310 case eCSR_ENCRYPT_TYPE_NONE:
6311 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6312 break;
6313 case eCSR_ENCRYPT_TYPE_WEP40:
6314 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6315 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6316 break;
6317 case eCSR_ENCRYPT_TYPE_TKIP:
6318 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6319 break;
6320 case eCSR_ENCRYPT_TYPE_WEP104:
6321 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6322 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6323 break;
6324 case eCSR_ENCRYPT_TYPE_AES:
6325 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6326 break;
6327 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006328 hdd_warn("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006329 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006330 return -EIO;
6331 }
6332 }
6333
6334 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6335 switch (pRoamProfile->negotiatedMCEncryptionType) {
6336 case eCSR_ENCRYPT_TYPE_NONE:
6337 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6338 break;
6339 case eCSR_ENCRYPT_TYPE_WEP40:
6340 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6341 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6342 break;
6343 case eCSR_ENCRYPT_TYPE_TKIP:
6344 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6345 break;
6346 case eCSR_ENCRYPT_TYPE_WEP104:
6347 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6348 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6349 break;
6350 case eCSR_ENCRYPT_TYPE_AES:
6351 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6352 break;
6353 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006354 hdd_err("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006355 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006356 return -EIO;
6357 }
6358 }
6359
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006360 hdd_debug("called with auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006361 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362 EXIT();
6363 return 0;
6364}
6365
6366/**
6367 * iw_get_auth() - get auth callback function
6368 * @dev: Pointer to the net device.
6369 * @info: Pointer to the iw_request_info.
6370 * @wrqu: Pointer to the iwreq_data.
6371 * @extra: Pointer to the data.
6372 *
6373 * Return: 0 for success, error number on failure.
6374 */
6375int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6376 union iwreq_data *wrqu, char *extra)
6377{
6378 int ret;
6379
6380 cds_ssr_protect(__func__);
6381 ret = __iw_get_auth(dev, info, wrqu, extra);
6382 cds_ssr_unprotect(__func__);
6383
6384 return ret;
6385}
6386
6387/**
6388 * __iw_set_ap_address() - set ap address
6389 * @dev: pointer to the net device
6390 * @info: pointer to the iw request info
6391 * @wrqu: pointer to iwreq_data
6392 * @extra: pointer to the data
6393 *
6394 * This function updates the HDD global station context connection info
6395 * BSSID with the MAC address received from the wpa_supplicant.
6396 *
6397 * Return: 0 on success, error number otherwise
6398 */
6399static int __iw_set_ap_address(struct net_device *dev,
6400 struct iw_request_info *info,
6401 union iwreq_data *wrqu, char *extra)
6402{
6403
6404 hdd_adapter_t *adapter;
6405 hdd_context_t *hdd_ctx;
6406 hdd_station_ctx_t *pHddStaCtx =
6407 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6408 uint8_t *pMacAddress = NULL;
6409 int ret;
6410
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006411 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006412
6413 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6414
6415 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6416 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306417 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006418 return ret;
6419
Jeff Johnson441e1f72017-02-07 08:50:49 -08006420 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6421 if (0 != ret)
6422 return ret;
6423
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006425 hdd_debug(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306426 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306427 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006428 EXIT();
6429
6430 return 0;
6431}
6432
6433/**
6434 * iw_set_ap_address() - set ap addresses callback function
6435 * @dev: Pointer to the net device.
6436 * @info: Pointer to the iw_request_info.
6437 * @wrqu: Pointer to the iwreq_data.
6438 * @extra: Pointer to the data.
6439 *
6440 * Return: 0 for success, error number on failure.
6441 */
6442int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6443 union iwreq_data *wrqu, char *extra)
6444{
6445 int ret;
6446
6447 cds_ssr_protect(__func__);
6448 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6449 cds_ssr_unprotect(__func__);
6450
6451 return ret;
6452}
6453
6454/**
6455 * __iw_get_ap_address() - get ap address
6456 * @dev: pointer to the net device
6457 * @info: pointer to the iw request info
6458 * @wrqu: pointer to iwreq_data
6459 * @extra: pointer to the data
6460 *
6461 * This function returns currently associated BSSID.
6462 *
6463 * Return: 0 on success, error number otherwise
6464 */
6465static int __iw_get_ap_address(struct net_device *dev,
6466 struct iw_request_info *info,
6467 union iwreq_data *wrqu, char *extra)
6468{
6469 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6470 hdd_context_t *hdd_ctx;
6471 hdd_station_ctx_t *pHddStaCtx =
6472 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6473 int ret;
6474
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006475 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006476
6477 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6478 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306479 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 return ret;
6481
Jeff Johnson441e1f72017-02-07 08:50:49 -08006482 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6483 if (0 != ret)
6484 return ret;
6485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6487 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306488 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006489 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306490 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006491 } else {
6492 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6493 }
6494 EXIT();
6495 return 0;
6496}
6497
6498/**
6499 * iw_get_ap_address() - get ap addresses callback function
6500 * @dev: Pointer to the net device.
6501 * @info: Pointer to the iw_request_info.
6502 * @wrqu: Pointer to the iwreq_data.
6503 * @extra: Pointer to the data.
6504 *
6505 * Return: 0 for success, error number on failure.
6506 */
6507int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6508 union iwreq_data *wrqu, char *extra)
6509{
6510 int ret;
6511
6512 cds_ssr_protect(__func__);
6513 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6514 cds_ssr_unprotect(__func__);
6515
6516 return ret;
6517}