blob: c905ebc37cfc0eec256fcec4a1e170d80b1e9b7f [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>
54#include "cds_concurrency.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>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053062#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080063#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080064#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053065#include "wlan_pmo_ucfg_api.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080066
67/* These are needed to recognize WPA and RSN suite types */
68#define HDD_WPA_OUI_SIZE 4
69#define HDD_RSN_OUI_SIZE 4
70uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
71uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
72uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
73uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
74uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
75uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
76
77#ifdef FEATURE_WLAN_ESE
78/* CCKM */
79uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
80/* CCKM */
81uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82#endif /* FEATURE_WLAN_ESE */
83
84/* group cipher */
85uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
86
87/* WEP-40 or RSN */
88uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
89
90/* TKIP or RSN-PSK */
91uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
92
93/* Reserved */
94uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
95
96/* AES-CCMP */
97uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
98
99/* WEP-104 */
100uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
101
102#ifdef WLAN_FEATURE_11W
103/* RSN-PSK-SHA256 */
104uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
105
106/* RSN-8021X-SHA256 */
107uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
108#endif
109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110/* Offset where the EID-Len-IE, start. */
111#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
112#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800113
114#define BEACON_FRAME_IES_OFFSET 12
115#define HDD_PEER_AUTHORIZE_WAIT 10
116
117/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700118 * beacon_filter_table - table of IEs used for beacon filtering
119 */
120static const int beacon_filter_table[] = {
121 SIR_MAC_DS_PARAM_SET_EID,
122 SIR_MAC_ERP_INFO_EID,
123 SIR_MAC_EDCA_PARAM_SET_EID,
124 SIR_MAC_QOS_CAPABILITY_EID,
125 SIR_MAC_HT_INFO_EID,
126 SIR_MAC_VHT_OPMODE_EID,
127 SIR_MAC_VHT_OPERATION_EID,
128};
129
130/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800131 * hdd_conn_set_authenticated() - set authentication state
132 * @pAdapter: pointer to the adapter
133 * @authState: authentication state
134 *
135 * This function updates the global HDD station context
136 * authentication state.
137 *
138 * Return: none
139 */
140static void
141hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
142{
143 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
144 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
145
146 /* save the new connection state */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700147 hdd_notice("Authenticated state Changed from oldState:%d to State:%d",
148 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800149 pHddStaCtx->conn_info.uIsAuthenticated = authState;
150
151 /* Check is pending ROC request or not when auth state changed */
152 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
153}
154
155/**
156 * hdd_conn_set_connection_state() - set connection state
157 * @pAdapter: pointer to the adapter
158 * @connState: connection state
159 *
160 * This function updates the global HDD station context connection state.
161 *
162 * Return: none
163 */
164void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
165 eConnectionState connState)
166{
167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
168 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
169
170 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530171 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
172 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
173 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800174 pHddStaCtx->conn_info.connState = connState;
175
176 /* Check is pending ROC request or not when connection state changed */
177 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
178}
179
180/**
181 * hdd_conn_get_connection_state() - get connection state
182 * @pAdapter: pointer to the adapter
183 * @pConnState: pointer to connection state
184 *
185 * This function updates the global HDD station context connection state.
186 *
187 * Return: true if (Infra Associated or IBSS Connected)
188 * and sets output parameter pConnState;
189 * false otherwise
190 */
191static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
192 eConnectionState *pConnState)
193{
194 bool fConnected = false;
195 eConnectionState connState;
196
197 /* get the connection state. */
198 connState = pHddStaCtx->conn_info.connState;
199
200 if (eConnectionState_Associated == connState ||
201 eConnectionState_IbssConnected == connState ||
202 eConnectionState_IbssDisconnected == connState) {
203 fConnected = true;
204 }
205
206 if (pConnState)
207 *pConnState = connState;
208
209 return fConnected;
210}
211
212/**
213 * hdd_is_connecting() - Function to check connection progress
214 * @hdd_sta_ctx: pointer to global HDD Station context
215 *
216 * Return: true if connecting, false otherwise
217 */
218bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
219{
220 return hdd_sta_ctx->conn_info.connState ==
221 eConnectionState_Connecting;
222}
223
224/**
225 * hdd_conn_is_connected() - Function to check connection status
226 * @pHddStaCtx: pointer to global HDD Station context
227 *
228 * Return: false if any errors encountered, true otherwise
229 */
230bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
231{
232 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
233}
234
235/**
236 * hdd_conn_get_connected_band() - get current connection radio band
237 * @pHddStaCtx: pointer to global HDD Station context
238 *
239 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
240 * eCSR_BAND_ALL if not connected
241 */
242eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
243{
244 uint8_t staChannel = 0;
245
246 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
247 staChannel = pHddStaCtx->conn_info.operationChannel;
248
249 if (staChannel > 0 && staChannel < 14)
250 return eCSR_BAND_24;
251 else if (staChannel >= 36 && staChannel <= 184)
252 return eCSR_BAND_5G;
253 else /* If station is not connected return as eCSR_BAND_ALL */
254 return eCSR_BAND_ALL;
255}
256
257/**
258 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
259 * @pHddStaCtx: pointer to global HDD Station context
260 * @pConnectedCipherAlgo: pointer to connected cipher algo
261 *
262 * Return: false if any errors encountered, true otherwise
263 */
264static inline bool
265hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
266 eCsrEncryptionType *pConnectedCipherAlgo)
267{
268 bool fConnected = false;
269
270 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
271
272 if (pConnectedCipherAlgo)
273 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
274
275 return fConnected;
276}
277
278/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700279 * hdd_remove_beacon_filter() - remove beacon filter
280 * @adapter: Pointer to the hdd adapter
281 *
282 * Return: 0 on success and errno on failure
283 */
284static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
285{
286 QDF_STATUS status;
287 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
288
289 status = sme_remove_beacon_filter(hdd_ctx->hHal,
290 adapter->sessionId);
291 if (!QDF_IS_STATUS_SUCCESS(status)) {
292 hdd_err("sme_remove_beacon_filter() failed");
293 return -EFAULT;
294 }
295
296 return 0;
297}
298
299/**
300 * hdd_add_beacon_filter() - add beacon filter
301 * @adapter: Pointer to the hdd adapter
302 *
303 * Return: 0 on success and errno on failure
304 */
305static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
306{
307 int i;
308 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
309 QDF_STATUS status;
310 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
311
312 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530313 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700314 (unsigned long int *)ie_map);
315
316 status = sme_add_beacon_filter(hdd_ctx->hHal,
317 adapter->sessionId, ie_map);
318 if (!QDF_IS_STATUS_SUCCESS(status)) {
319 hdd_err("sme_add_beacon_filter() failed");
320 return -EFAULT;
321 }
322 return 0;
323}
324
325/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530326 * hdd_copy_vht_caps()- copy vht caps info from roam info to
327 * hdd station context.
328 * @hdd_sta_ctx: pointer to hdd station context
329 * @roam_info: pointer to roam info
330 *
331 * Return: None
332 */
333static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
334 tCsrRoamInfo *roam_info)
335{
336 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
337 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
338 uint32_t i, temp_ht_cap;
339
340 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
341
342 if (roam_ht_cap->advCodingCap)
343 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
344 if (roam_ht_cap->supportedChannelWidthSet)
345 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
346 temp_ht_cap = roam_ht_cap->mimoPowerSave &
347 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
348 if (temp_ht_cap)
349 hdd_ht_cap->cap_info |=
350 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
351 if (roam_ht_cap->greenField)
352 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
353 if (roam_ht_cap->shortGI20MHz)
354 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
355 if (roam_ht_cap->shortGI40MHz)
356 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
357 if (roam_ht_cap->txSTBC)
358 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
359 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
360 IEEE80211_HT_CAP_RX_STBC_SHIFT);
361 if (temp_ht_cap)
362 hdd_ht_cap->cap_info |=
363 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
364 if (roam_ht_cap->delayedBA)
365 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
366 if (roam_ht_cap->maximalAMSDUsize)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
368 if (roam_ht_cap->dsssCckMode40MHz)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
370 if (roam_ht_cap->psmp)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
372 if (roam_ht_cap->stbcControlFrame)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
374 if (roam_ht_cap->lsigTXOPProtection)
375 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
376
377 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
378 if (roam_ht_cap->maxRxAMPDUFactor)
379 hdd_ht_cap->ampdu_params_info |=
380 IEEE80211_HT_AMPDU_PARM_FACTOR;
381 temp_ht_cap = roam_ht_cap->mpduDensity &
382 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
383 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
384 if (temp_ht_cap)
385 hdd_ht_cap->ampdu_params_info |=
386 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
387
388 /* 802.11n HT extended capabilities masks */
389 if (roam_ht_cap->pco)
390 hdd_ht_cap->extended_ht_cap_info |=
391 IEEE80211_HT_EXT_CAP_PCO;
392 temp_ht_cap = roam_ht_cap->transitionTime &
393 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
394 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
395 if (temp_ht_cap)
396 hdd_ht_cap->extended_ht_cap_info |=
397 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
398 temp_ht_cap = roam_ht_cap->mcsFeedback &
399 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
400 if (temp_ht_cap)
401 hdd_ht_cap->extended_ht_cap_info |=
402 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
403
404 /* tx_bf_cap_info capabilities */
405 if (roam_ht_cap->txBF)
406 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
407 if (roam_ht_cap->rxStaggeredSounding)
408 hdd_ht_cap->tx_BF_cap_info |=
409 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
410 if (roam_ht_cap->txStaggeredSounding)
411 hdd_ht_cap->tx_BF_cap_info |=
412 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
413 if (roam_ht_cap->rxZLF)
414 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
415 if (roam_ht_cap->txZLF)
416 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
417 if (roam_ht_cap->implicitTxBF)
418 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
419 temp_ht_cap = roam_ht_cap->calibration &
420 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
421 if (temp_ht_cap)
422 hdd_ht_cap->tx_BF_cap_info |=
423 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
424 if (roam_ht_cap->explicitCSITxBF)
425 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
426 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
427 hdd_ht_cap->tx_BF_cap_info |=
428 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
429 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
430 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
431 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
432 if (temp_ht_cap)
433 hdd_ht_cap->tx_BF_cap_info |=
434 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
435 temp_ht_cap =
436 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
437 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
438 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
439 if (temp_ht_cap)
440 hdd_ht_cap->tx_BF_cap_info |=
441 temp_ht_cap <<
442 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
443 temp_ht_cap =
444 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
445 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
446 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
447 if (temp_ht_cap)
448 hdd_ht_cap->tx_BF_cap_info |=
449 temp_ht_cap <<
450 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
451 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
452 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
453 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
454 if (temp_ht_cap)
455 hdd_ht_cap->tx_BF_cap_info |=
456 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
457 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
458 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
459 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
460 if (temp_ht_cap)
461 hdd_ht_cap->tx_BF_cap_info |=
462 temp_ht_cap <<
463 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
464 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
465 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
466 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
467 if (temp_ht_cap)
468 hdd_ht_cap->tx_BF_cap_info |=
469 temp_ht_cap <<
470 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
471
472 /* antenna selection */
473 if (roam_ht_cap->antennaSelection)
474 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
475 if (roam_ht_cap->explicitCSIFeedbackTx)
476 hdd_ht_cap->antenna_selection_info |=
477 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
478 if (roam_ht_cap->antennaIndicesFeedbackTx)
479 hdd_ht_cap->antenna_selection_info |=
480 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
481 if (roam_ht_cap->explicitCSIFeedback)
482 hdd_ht_cap->antenna_selection_info |=
483 ANTENNA_SEL_INFO_EXP_CSI_FB;
484 if (roam_ht_cap->antennaIndicesFeedback)
485 hdd_ht_cap->antenna_selection_info |=
486 ANTENNA_SEL_INFO_ANT_ID_FB;
487 if (roam_ht_cap->rxAS)
488 hdd_ht_cap->antenna_selection_info |=
489 ANTENNA_SEL_INFO_RX_AS;
490 if (roam_ht_cap->txSoundingPPDUs)
491 hdd_ht_cap->antenna_selection_info |=
492 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
493
494 /* mcs data rate */
495 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
496 hdd_ht_cap->mcs.rx_mask[i] =
497 roam_ht_cap->supportedMCSSet[i];
498 hdd_ht_cap->mcs.rx_highest =
499 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
500 ((short) (roam_ht_cap->supportedMCSSet[10]));
501 hdd_ht_cap->mcs.tx_params =
502 roam_ht_cap->supportedMCSSet[12];
503}
504
505#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
506#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
507#define VHT_CAP_RXSTBC_MASK_SHIFT 8
508#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
509#define VHT_CAP_BEAMFORMEE_STS_MASK \
510 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
511#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
512#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
513 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
514#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
515#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
516 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
517#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
518
519/**
520 * hdd_copy_ht_caps()- copy ht caps info from roam info to
521 * hdd station context.
522 * @hdd_sta_ctx: pointer to hdd station context
523 * @roam_info: pointer to roam info
524 *
525 * Return: None
526 */
527static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
528 tCsrRoamInfo *roam_info)
529{
530 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
531 struct ieee80211_vht_cap *hdd_vht_cap =
532 &hdd_sta_ctx->conn_info.vht_caps;
533 uint32_t temp_vht_cap;
534
535 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
536
537 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
538 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
539 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
540 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
541 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
542 if (temp_vht_cap)
543 if (roam_vht_cap->supportedChannelWidthSet &
544 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
545 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
546 hdd_vht_cap->vht_cap_info |=
547 temp_vht_cap <<
548 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
549 if (roam_vht_cap->supportedChannelWidthSet &
550 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
551 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
552 hdd_vht_cap->vht_cap_info |=
553 temp_vht_cap <<
554 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
555 if (roam_vht_cap->ldpcCodingCap)
556 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
557 if (roam_vht_cap->shortGI80MHz)
558 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
559 if (roam_vht_cap->shortGI160and80plus80MHz)
560 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
561 if (roam_vht_cap->txSTBC)
562 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
563 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
564 VHT_CAP_RXSTBC_MASK_SHIFT);
565 if (temp_vht_cap)
566 hdd_vht_cap->vht_cap_info |=
567 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
568 if (roam_vht_cap->suBeamFormerCap)
569 hdd_vht_cap->vht_cap_info |=
570 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
571 if (roam_vht_cap->suBeamformeeCap)
572 hdd_vht_cap->vht_cap_info |=
573 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
574 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
575 (VHT_CAP_BEAMFORMEE_STS_MASK);
576 if (temp_vht_cap)
577 hdd_vht_cap->vht_cap_info |=
578 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
579 temp_vht_cap = roam_vht_cap->numSoundingDim &
580 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
581 if (temp_vht_cap)
582 hdd_vht_cap->vht_cap_info |=
583 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
584 if (roam_vht_cap->muBeamformerCap)
585 hdd_vht_cap->vht_cap_info |=
586 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
587 if (roam_vht_cap->muBeamformeeCap)
588 hdd_vht_cap->vht_cap_info |=
589 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
590 if (roam_vht_cap->vhtTXOPPS)
591 hdd_vht_cap->vht_cap_info |=
592 IEEE80211_VHT_CAP_VHT_TXOP_PS;
593 if (roam_vht_cap->htcVHTCap)
594 hdd_vht_cap->vht_cap_info |=
595 IEEE80211_VHT_CAP_HTC_VHT;
596 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
597 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
598 if (temp_vht_cap)
599 hdd_vht_cap->vht_cap_info |=
600 temp_vht_cap <<
601 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
602 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
603 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
604 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
605 if (temp_vht_cap)
606 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
607 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
608 if (roam_vht_cap->rxAntPattern)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
611 if (roam_vht_cap->txAntPattern)
612 hdd_vht_cap->vht_cap_info |=
613 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
614 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
615 hdd_vht_cap->supp_mcs.rx_highest =
616 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
617 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
618 hdd_vht_cap->supp_mcs.tx_highest =
619 ((uint16_t)roam_vht_cap->txSupDataRate);
620}
621
622/* ht param */
623#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
624#define HT_PARAM_SERVICE_INT_GRAN 0xe0
625#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
626
627/* operatinon mode */
628#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
629
630/* stbc_param */
631#define HT_STBC_PARAM_MCS 0x007f
632
633/**
634 * hdd_copy_ht_operation()- copy HT operation element from roam info to
635 * hdd station context.
636 * @hdd_sta_ctx: pointer to hdd station context
637 * @roam_info: pointer to roam info
638 *
639 * Return: None
640 */
641static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
642 tCsrRoamInfo *roam_info)
643{
644 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
645 struct ieee80211_ht_operation *hdd_ht_ops =
646 &hdd_sta_ctx->conn_info.ht_operation;
647 uint32_t i, temp_ht_ops;
648
649 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
650
651 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
652
653 /* HT_PARAMS */
654 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
655 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
656 if (temp_ht_ops)
657 hdd_ht_ops->ht_param |= temp_ht_ops;
658 else
659 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
660 if (roam_ht_ops->recommendedTxWidthSet)
661 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
662 if (roam_ht_ops->rifsMode)
663 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
664 if (roam_ht_ops->controlledAccessOnly)
665 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
666 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
667 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
668 if (temp_ht_ops)
669 hdd_ht_ops->ht_param |= temp_ht_ops <<
670 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
671
672 /* operation mode */
673 temp_ht_ops = roam_ht_ops->opMode &
674 IEEE80211_HT_OP_MODE_PROTECTION;
675 switch (temp_ht_ops) {
676 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
677 hdd_ht_ops->operation_mode |=
678 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
679 break;
680 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
681 hdd_ht_ops->operation_mode |=
682 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
683 break;
684 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
685 hdd_ht_ops->operation_mode |=
686 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
687 break;
688 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
689 default:
690 hdd_ht_ops->operation_mode |=
691 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
692 }
693 if (roam_ht_ops->nonGFDevicesPresent)
694 hdd_ht_ops->operation_mode |=
695 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
696 if (roam_ht_ops->transmitBurstLimit)
697 hdd_ht_ops->operation_mode |=
698 HT_OP_MODE_TX_BURST_LIMIT;
699 if (roam_ht_ops->obssNonHTStaPresent)
700 hdd_ht_ops->operation_mode |=
701 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
702
703 /* stbc_param */
704 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
705 HT_STBC_PARAM_MCS;
706 if (temp_ht_ops)
707 hdd_ht_ops->stbc_param |= temp_ht_ops;
708 if (roam_ht_ops->dualCTSProtection)
709 hdd_ht_ops->stbc_param |=
710 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
711 if (roam_ht_ops->secondaryBeacon)
712 hdd_ht_ops->stbc_param |=
713 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
714 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
715 hdd_ht_ops->stbc_param |=
716 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
717 if (roam_ht_ops->pcoActive)
718 hdd_ht_ops->stbc_param |=
719 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
720 if (roam_ht_ops->pcoPhase)
721 hdd_ht_ops->stbc_param |=
722 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
723
724 /* basic MCs set */
725 for (i = 0; i < 16; ++i)
726 hdd_ht_ops->basic_set[i] =
727 roam_ht_ops->basicMCSSet[i];
728}
729
730/**
731 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
732 * hdd station context.
733 * @hdd_sta_ctx: pointer to hdd station context
734 * @roam_info: pointer to roam info
735 *
736 * Return: None
737 */
738static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
739 tCsrRoamInfo *roam_info)
740{
741 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
742 struct ieee80211_vht_operation *hdd_vht_ops =
743 &hdd_sta_ctx->conn_info.vht_operation;
744
745 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
746
747 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
748 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
749 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
750 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
751}
752
753
754/**
755 * hdd_save_bss_info() - save connection info in hdd sta ctx
756 * @adapter: Pointer to adapter
757 * @roam_info: pointer to roam info
758 *
759 * Return: None
760 */
761static void hdd_save_bss_info(hdd_adapter_t *adapter,
762 tCsrRoamInfo *roam_info)
763{
764 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
765
766 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
767 hdd_sta_ctx->conn_info.operationChannel);
768 if (roam_info->vht_caps.present) {
769 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
770 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
771 } else {
772 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
773 }
774 if (roam_info->ht_caps.present) {
775 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
776 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
777 } else {
778 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
779 }
780 if (roam_info->reassoc)
781 hdd_sta_ctx->conn_info.roam_count++;
782 if (roam_info->hs20vendor_ie.present) {
783 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
784 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
785 &roam_info->hs20vendor_ie,
786 sizeof(roam_info->hs20vendor_ie));
787 } else {
788 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
789 }
790 if (roam_info->ht_operation.present) {
791 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
792 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
793 } else {
794 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
795 }
796 if (roam_info->vht_operation.present) {
797 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
798 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
799 } else {
800 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
801 }
802}
803
804/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800805 * hdd_conn_save_connect_info() - save current connection information
806 * @pAdapter: pointer to adapter
807 * @pRoamInfo: pointer to roam info
808 * @eBssType: bss type
809 *
810 * Return: none
811 */
812static void
813hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
814 eCsrRoamBssType eBssType)
815{
816 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
817 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
818
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530819 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800820
821 if (pRoamInfo) {
822 /* Save the BSSID for the connection */
823 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530824 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530825 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 &pRoamInfo->bssid);
827
828 /*
829 * Save the Station ID for this station from
830 * the 'Roam Info'. For IBSS mode, staId is
831 * assigned in NEW_PEER_IND. For reassoc,
832 * the staID doesn't change and it may be invalid
833 * in this structure so no change here.
834 */
835 if (!pRoamInfo->fReassocReq) {
836 pHddStaCtx->conn_info.staId[0] =
837 pRoamInfo->staId;
838 }
839 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
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 } else {
843 /*
844 * can't happen. We need a valid IBSS or Infra setting
845 * in the BSSDescription or we can't function.
846 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530847 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800848 }
849
850 /* notify WMM */
851 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
852
853 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530854 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800855 } else {
856 /* Get Multicast Encryption Type */
857 encryptType =
858 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
859 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
860 /* Get Unicast Encryption Type */
861 encryptType =
862 pRoamInfo->u.pConnectedProfile->EncryptionType;
863 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
864
865 pHddStaCtx->conn_info.authType =
866 pRoamInfo->u.pConnectedProfile->AuthType;
867
868 pHddStaCtx->conn_info.operationChannel =
869 pRoamInfo->u.pConnectedProfile->operationChannel;
870
871 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530872 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 &pRoamInfo->u.pConnectedProfile->SSID,
874 sizeof(tSirMacSSid));
875
876 /* Save dot11mode in which STA associated to AP */
877 pHddStaCtx->conn_info.dot11Mode =
878 pRoamInfo->u.pConnectedProfile->dot11Mode;
879
880 pHddStaCtx->conn_info.proxyARPService =
881 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530882
883 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
884
885 pHddStaCtx->conn_info.rate_flags =
886 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530888 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890}
891
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800892/**
893 * hdd_send_ft_assoc_response() - send fast transition assoc response
894 * @dev: pointer to net device
895 * @pAdapter: pointer to adapter
896 * @pCsrRoamInfo: pointer to roam info
897 *
898 * Send the 11R key information to the supplicant. Only then can the supplicant
899 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
900 * for the same purpose.)
901 *
902 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
903 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
904 * This is the Assoc Response.
905 *
906 * Return: none
907 */
908static void
909hdd_send_ft_assoc_response(struct net_device *dev,
910 hdd_adapter_t *pAdapter,
911 tCsrRoamInfo *pCsrRoamInfo)
912{
913 union iwreq_data wrqu;
914 char *buff;
915 unsigned int len = 0;
916 u8 *pFTAssocRsp = NULL;
917
918 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700919 hdd_err("pCsrRoamInfo->nAssocRspLength=%d",
920 (int)pCsrRoamInfo->nAssocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800921 return;
922 }
923
924 pFTAssocRsp =
925 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
926 pCsrRoamInfo->nAssocReqLength);
927 if (pFTAssocRsp == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700928 hdd_err("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800929 return;
930 }
931 /* pFTAssocRsp needs to point to the IEs */
932 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700933 hdd_notice("AssocRsp is now at %02x%02x",
934 (unsigned int)pFTAssocRsp[0],
935 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800936
937 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700938 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700940 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800941 return;
942 }
943 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
944 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
945 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 memcpy(buff, pFTAssocRsp, len);
947 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
948
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700949 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800951
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800952/**
953 * hdd_send_ft_event() - send fast transition event
954 * @pAdapter: pointer to adapter
955 *
956 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
957 * FT events to the supplicant. At the reception of Auth2 we send the RIC
958 * followed by the auth response IEs to the supplicant.
959 * Once both are received in the supplicant, an FT event is generated
960 * to the supplicant.
961 *
962 * Return: none
963 */
964static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
965{
966 uint16_t auth_resp_len = 0;
967 uint32_t ric_ies_length = 0;
968 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
969
970#if defined(KERNEL_SUPPORT_11R_CFG80211)
971 struct cfg80211_ft_event_params ftEvent;
972 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
973 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
974 struct net_device *dev = pAdapter->dev;
975#else
976 char *buff;
977 union iwreq_data wrqu;
978 uint16_t str_len;
979#endif
980
981#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530982 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
983 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984
985 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
986 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
987 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700988 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 }
990
991 ftEvent.ric_ies = ricIe;
992 ftEvent.ric_ies_len = ric_ies_length;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700993 hdd_notice("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800994
995 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
996 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
997 &auth_resp_len);
998
999 if (auth_resp_len == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001000 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 return;
1002 }
1003
1004 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1005
1006 ftEvent.target_ap = ftIe;
1007
Anurag Chouhan6d760662016-02-20 16:05:43 +05301008 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1009 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001010
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001011 hdd_notice("ftEvent.ies_len %zu", ftEvent.ies_len);
1012 hdd_notice("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1013 hdd_notice("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014 ftEvent.target_ap[0], ftEvent.target_ap[1],
1015 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1016 ftEvent.target_ap[5]);
1017
1018 (void)cfg80211_ft_event(dev, &ftEvent);
1019
1020#else
1021 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001022 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001024 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 return;
1026 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001027
1028 /* Sme needs to send the RIC IEs first */
1029 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1030 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1031 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1032 &ric_ies_length);
1033 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001034 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001035 } else {
1036 wrqu.data.length = str_len + ric_ies_length;
1037 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1038 }
1039
1040 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301041 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001042 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1043 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1044 (u8 *) &buff[str_len],
1045 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1046
1047 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001048 qdf_mem_free(buff);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001049 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001050 return;
1051 }
1052
1053 wrqu.data.length = str_len + auth_resp_len;
1054 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1055
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001056 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001057#endif
1058}
1059
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001060#ifdef FEATURE_WLAN_ESE
1061/**
1062 * hdd_send_new_ap_channel_info() - send new ap channel info
1063 * @dev: pointer to net device
1064 * @pAdapter: pointer to adapter
1065 * @pCsrRoamInfo: pointer to roam info
1066 *
1067 * Send the ESE required "new AP Channel info" to the supplicant.
1068 * (This keeps the supplicant "up to date" on the current channel.)
1069 *
1070 * The current (new AP) channel information is passed in.
1071 *
1072 * Return: none
1073 */
1074static void
1075hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1076 tCsrRoamInfo *pCsrRoamInfo)
1077{
1078 union iwreq_data wrqu;
1079 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1080
1081 if (descriptor == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001082 hdd_err("pCsrRoamInfo->pBssDesc(%p)", descriptor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001083 return;
1084 }
1085 /*
1086 * Send the Channel event, the supplicant needs this to generate
1087 * the Adjacent AP report.
1088 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001089 hdd_warn("Sending up an SIOCGIWFREQ, channelId(%d)",
1090 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001091 memset(&wrqu, '\0', sizeof(wrqu));
1092 wrqu.freq.m = descriptor->channelId;
1093 wrqu.freq.e = 0;
1094 wrqu.freq.i = 0;
1095 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1096}
1097
1098#endif /* FEATURE_WLAN_ESE */
1099
1100/**
1101 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1102 * @pAdapter: pointer to adapter
1103 * @pCsrRoamInfo: pointer to roam info
1104 *
1105 * Return: none
1106 */
1107static void
1108hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1109 tCsrRoamInfo *pCsrRoamInfo)
1110{
1111 union iwreq_data wrqu;
1112 u8 *pBeaconIes;
1113 u8 currentLen = 0;
1114 char *buff;
1115 int totalIeLen = 0, currentOffset = 0, strLen;
1116
1117 memset(&wrqu, '\0', sizeof(wrqu));
1118
1119 if (0 == pCsrRoamInfo->nBeaconLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001120 hdd_warn("pCsrRoamInfo->nBeaconFrameLength = 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001121 return;
1122 }
1123 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1124 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001125 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001126 return;
1127 }
1128 /* pBeaconIes needs to point to the IEs */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001129 hdd_notice("Beacon IEs is now at %02x%02x",
1130 (unsigned int)pBeaconIes[0],
1131 (unsigned int)pBeaconIes[1]);
1132 hdd_notice("Beacon IEs length = %d",
1133 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001134
1135 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001136 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001138 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139 return;
1140 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001141
1142 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1143 currentLen = strLen + 1;
1144
1145 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1146 do {
1147 /*
1148 * If the beacon size exceeds max CUSTOM event size, break it
1149 * into chunks of CUSTOM event max size and send it to
1150 * supplicant. Changes are done in supplicant to handle this.
1151 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301152 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001153 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301154 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301155 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001156 currentLen);
1157 currentOffset += currentLen;
1158 totalIeLen -= currentLen;
1159 wrqu.data.length = strLen + 1 + currentLen;
1160 if (totalIeLen)
1161 buff[strLen] = 1; /* more chunks pending */
1162 else
1163 buff[strLen] = 0; /* last chunk */
1164
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001165 hdd_notice("Beacon IEs length to supplicant = %d",
1166 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001167 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1168 } while (totalIeLen > 0);
1169
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001170 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001171}
1172
1173/**
1174 * hdd_send_association_event() - send association event
1175 * @dev: pointer to net device
1176 * @pCsrRoamInfo: pointer to roam info
1177 *
1178 * Return: none
1179 */
1180static void hdd_send_association_event(struct net_device *dev,
1181 tCsrRoamInfo *pCsrRoamInfo)
1182{
Rajeev Kumar78427682017-01-13 16:13:11 -08001183 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001184 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1185 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1186 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1187 union iwreq_data wrqu;
1188 int we_event;
1189 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301190 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001192 /* Added to find the auth type on the fly at run time */
1193 /* rather than with cfg to see if FT is enabled */
1194 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1195 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196
1197 memset(&wrqu, '\0', sizeof(wrqu));
1198 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1199 we_event = SIOCGIWAP;
1200#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1201 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301202 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 /* change logging before release */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001204 hdd_info("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301205 /* Update tdls module about the disconnection event */
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301206 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301207 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208#endif
1209 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001210 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301211
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 if (!pCsrRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001213 hdd_err("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001214 return;
1215 }
1216
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001217 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
1218 cds_incr_active_session(pAdapter->device_mode,
1219 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1221 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1222
1223#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001224 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001225 if (global_p2p_connection_status ==
1226 P2P_CLIENT_CONNECTING_STATE_1) {
1227 global_p2p_connection_status =
1228 P2P_CLIENT_CONNECTED_STATE_1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001229 hdd_err("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001230 } else if (global_p2p_connection_status ==
1231 P2P_CLIENT_CONNECTING_STATE_2) {
1232 global_p2p_connection_status =
1233 P2P_CLIENT_COMPLETED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001234 hdd_err("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001235 }
1236 }
1237#endif
1238 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1239 MAC_ADDRESS_STR "\n",
1240 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1241 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1242 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1243
1244 /*
1245 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1246 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001247 * fFTEnable is true.
1248 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001249 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001250 if ((pRoamProfile->AuthType.authType[0] ==
1251 eCSR_AUTH_TYPE_FT_RSN_PSK)
1252 || (pRoamProfile->AuthType.authType[0] ==
1253 eCSR_AUTH_TYPE_FT_RSN)
1254#ifdef FEATURE_WLAN_ESE
1255 || (pRoamProfile->AuthType.authType[0] ==
1256 eCSR_AUTH_TYPE_CCKM_RSN)
1257 || (pRoamProfile->AuthType.authType[0] ==
1258 eCSR_AUTH_TYPE_CCKM_WPA)
1259#endif
1260 ) {
1261 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1262 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301263 qdf_copy_macaddr(&peerMacAddr,
1264 &pHddStaCtx->conn_info.bssId);
1265 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1266 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1267 chan_info.info = pCsrRoamInfo->chan_info.info;
1268 chan_info.band_center_freq1 =
1269 pCsrRoamInfo->chan_info.band_center_freq1;
1270 chan_info.band_center_freq2 =
1271 pCsrRoamInfo->chan_info.band_center_freq2;
1272 chan_info.reg_info_1 =
1273 pCsrRoamInfo->chan_info.reg_info_1;
1274 chan_info.reg_info_2 =
1275 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301276
Dustin Brown7d043f62017-03-27 12:07:36 -07001277 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1278 pAdapter->device_mode,
1279 peerMacAddr.bytes);
Rajeev Kumar78427682017-01-13 16:13:11 -08001280 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301281 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1282 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001283 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1284 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301285 if (ret)
1286 hdd_err("Peer object %pM fail to set associated state",
1287 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301288
Abhishek Singh1c676222016-05-09 14:20:28 +05301289 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001290 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1291 ePeerConnected,
1292 pCsrRoamInfo->timingMeasCap,
1293 pAdapter->sessionId, &chan_info,
1294 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001295 /* Update tdls module about connection event */
1296 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001297
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001298#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001299#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001300 /* start timer in sta/p2p_cli */
1301 spin_lock_bh(&pHddCtx->bus_bw_lock);
1302 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1303 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001304 cdp_get_intra_bss_fwd_pkts_count(
1305 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301306 &pAdapter->prev_fwd_tx_packets,
1307 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1309 hdd_start_bus_bw_compute_timer(pAdapter);
1310#endif
1311#endif
1312 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1313 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001314 cds_update_connection_info(pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001315 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
1316 ETH_ALEN);
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301317 hdd_err("wlan: new IBSS connection to " MAC_ADDRESS_STR,
1318 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301319
Dustin Brown7d043f62017-03-27 12:07:36 -07001320 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1321 QDF_IBSS_MODE,
1322 pCsrRoamInfo->bssid.bytes);
Rajeev Kumar78427682017-01-13 16:13:11 -08001323 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301324 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1325 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001326 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1327 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301328 if (ret)
1329 hdd_err("Peer object %pM fail to set associated state",
1330 peerMacAddr.bytes);
1331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001332 } else { /* Not Associated */
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301333 hdd_err("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301335 cds_decr_session_set_pcl(pAdapter->device_mode,
1336 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001337
1338#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1339 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1340#endif
1341
Abhishek Singh1c676222016-05-09 14:20:28 +05301342 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1343 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301344 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001345 &pHddStaCtx->conn_info.bssId);
1346
1347 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001348 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301349 ePeerDisconnected, 0,
1350 pAdapter->sessionId,
1351 NULL,
1352 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301354
Dustin Brown7d043f62017-03-27 12:07:36 -07001355 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1356 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001357 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301358 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1359 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1360
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001361 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001362 /* Update tdls module about the disconnection event */
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301363 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001364
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365#ifdef MSM_PLATFORM
1366 /* stop timer in sta/p2p_cli */
1367 spin_lock_bh(&pHddCtx->bus_bw_lock);
1368 pAdapter->prev_tx_packets = 0;
1369 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301370 pAdapter->prev_fwd_tx_packets = 0;
1371 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1373 hdd_stop_bus_bw_compute_timer(pAdapter);
1374#endif
1375 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001376 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001377 /* Send SCC/MCC Switching event to IPA */
1378 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1379
1380 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001381 /* During the WLAN uninitialization,supplicant is stopped before the
1382 * driver so not sending the status of the connection to supplicant
1383 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001384 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001385 wireless_send_event(dev, we_event, &wrqu, msg);
1386#ifdef FEATURE_WLAN_ESE
1387 if (eConnectionState_Associated ==
1388 pHddStaCtx->conn_info.connState) {
1389 if ((pRoamProfile->AuthType.authType[0] ==
1390 eCSR_AUTH_TYPE_CCKM_RSN) ||
1391 (pRoamProfile->AuthType.authType[0] ==
1392 eCSR_AUTH_TYPE_CCKM_WPA))
1393 hdd_send_new_ap_channel_info(dev, pAdapter,
1394 pCsrRoamInfo);
1395 }
1396#endif
1397 }
1398}
1399
1400/**
1401 * hdd_conn_remove_connect_info() - remove connection info
1402 * @pHddStaCtx: pointer to global HDD station context
1403 * @pCsrRoamInfo: pointer to roam info
1404 *
1405 * Return: none
1406 */
1407static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1408{
1409 /* Remove staId, bssId and peerMacAddress */
1410 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301411 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1412 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301413 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414
1415 /* Clear all security settings */
1416 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1417 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1418 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1419
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301420 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1421 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 pHddStaCtx->conn_info.proxyARPService = 0;
1424
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301425 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426}
1427
1428/**
1429 * hdd_roam_deregister_sta() - deregister station
1430 * @pAdapter: pointer to adapter
1431 * @staId: station identifier
1432 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301433 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001434 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301435QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001436{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301437 QDF_STATUS qdf_status;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301438 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1439 int ret = 0;
1440 uint8_t *peer_mac = NULL;
1441 struct qdf_mac_addr broadcastMacAddr =
1442 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443 if (eConnectionState_IbssDisconnected ==
1444 pHddStaCtx->conn_info.connState) {
1445 /*
1446 * Do not set the carrier off when the last peer leaves.
1447 * We will set the carrier off while stopping the IBSS.
1448 */
1449 }
1450
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001451 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001452 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301453 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301454 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301455 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1456 staid, qdf_status, qdf_status);
1457 }
1458
1459 if (adapter->device_mode == QDF_STA_MODE) {
1460 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1461 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1462 if (pHddStaCtx->broadcast_staid == staid)
1463 peer_mac = broadcastMacAddr.bytes;
1464 else
1465 peer_mac = pHddStaCtx->conn_info.
1466 peerMacAddress[staid].bytes;
1467 }
1468
Dustin Brown7d043f62017-03-27 12:07:36 -07001469 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301470 if (ret) {
1471 hdd_err("Peer obj %pM delete fails", peer_mac);
1472 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001473 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301474 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001475}
1476
1477/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301478 * hdd_print_bss_info() - print bss info
1479 * @hdd_sta_ctx: pointer to hdd station context
1480 *
1481 * Return: None
1482 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001483static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301484{
1485 uint32_t *cap_info;
1486
1487 hdd_info("WIFI DATA LOGGER");
1488 hdd_info("channel: %d",
1489 hdd_sta_ctx->conn_info.freq);
1490 hdd_info("dot11mode: %d",
1491 hdd_sta_ctx->conn_info.dot11Mode);
1492 hdd_info("AKM: %d",
1493 hdd_sta_ctx->conn_info.authType);
1494 hdd_info("ssid: %.*s",
1495 hdd_sta_ctx->conn_info.SSID.SSID.length,
1496 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1497 hdd_info("roam count: %d",
1498 hdd_sta_ctx->conn_info.roam_count);
1499 hdd_info("ant_info: %d",
1500 hdd_sta_ctx->conn_info.txrate.nss);
1501 hdd_info("datarate legacy %d",
1502 hdd_sta_ctx->conn_info.txrate.legacy);
1503 hdd_info("datarate mcs: %d",
1504 hdd_sta_ctx->conn_info.txrate.mcs);
1505 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1506 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1507 hdd_info("ht caps: %x", *cap_info);
1508 }
1509 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1510 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1511 hdd_info("vht caps: %x", *cap_info);
1512 }
1513 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1514 hdd_info("hs20 info: %x",
1515 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1516 hdd_info("signal: %d",
1517 hdd_sta_ctx->conn_info.signal);
1518 hdd_info("noise: %d",
1519 hdd_sta_ctx->conn_info.noise);
1520}
1521
1522/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523 * hdd_dis_connect_handler() - disconnect event handler
1524 * @pAdapter: pointer to adapter
1525 * @pRoamInfo: pointer to roam info
1526 * @roamId: roam identifier
1527 * @roamStatus: roam status
1528 * @roamResult: roam result
1529 *
1530 * This function handles disconnect event:
1531 * 1. Disable transmit queues;
1532 * 2. Clean up internal connection states and data structures;
1533 * 3. Send disconnect indication to supplicant.
1534 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301535 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001536 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301537static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001538 tCsrRoamInfo *pRoamInfo,
1539 uint32_t roamId,
1540 eRoamCmdStatus roamStatus,
1541 eCsrRoamResult roamResult)
1542{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301543 QDF_STATUS status = QDF_STATUS_SUCCESS;
1544 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 struct net_device *dev = pAdapter->dev;
1546 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1547 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1548 uint8_t sta_id;
1549 bool sendDisconInd = true;
1550
1551 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001552 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301553 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001554 }
1555 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001556 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1558 WLAN_CONTROL_PATH);
1559
1560 if (hdd_ipa_is_enabled(pHddCtx))
1561 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001562 HDD_IPA_STA_DISCONNECT,
1563 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564
1565#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1566 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1567#endif
1568
Nirav Shah1da77682016-05-03 20:16:39 +05301569 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1570 pAdapter->sessionId,
1571 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001572
1573 /* HDD has initiated disconnect, do not send disconnect indication
1574 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301575 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 * to cfg80211_disconnected.
1577 */
1578 if ((eConnectionState_Disconnecting ==
1579 pHddStaCtx->conn_info.connState) ||
1580 (eConnectionState_NotConnected ==
1581 pHddStaCtx->conn_info.connState)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001582 hdd_notice("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 sendDisconInd = false;
1584 }
1585
1586 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1587 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001588 hdd_conn_set_connection_state(pAdapter,
1589 eConnectionState_Disconnecting);
1590 }
1591
1592 hdd_clear_roam_profile_ie(pAdapter);
1593 hdd_wmm_init(pAdapter);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301594 hdd_info("Invoking packetdump deregistration API");
1595 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596
1597 /* indicate 'disconnect' status to wpa_supplicant... */
1598 hdd_send_association_event(dev, pRoamInfo);
1599 /* indicate disconnected event to nl80211 */
1600 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1601 /*
1602 * Only send indication to kernel if not initiated
1603 * by kernel
1604 */
1605 if (sendDisconInd) {
1606 /*
1607 * To avoid wpa_supplicant sending "HANGED" CMD
1608 * to ICS UI.
1609 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001610 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1611 if (pRoamInfo->reasonCode ==
1612 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1613 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301614 wlan_hdd_cfg80211_indicate_disconnect(
1615 dev, false,
1616 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001617 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301618 wlan_hdd_cfg80211_indicate_disconnect(
1619 dev, false,
1620 WLAN_REASON_UNSPECIFIED
1621 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001622 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301624 hdd_info("sent disconnected event to nl80211, reason code %d",
1625 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1626 pRoamInfo->reasonCode :
1627 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 }
1629 /*
1630 * During the WLAN uninitialization,supplicant is stopped
1631 * before the driver so not sending the status of the
1632 * connection to supplicant.
1633 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001634 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001636 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001637 if (global_p2p_connection_status ==
1638 P2P_CLIENT_CONNECTED_STATE_1) {
1639 global_p2p_connection_status =
1640 P2P_CLIENT_DISCONNECTED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001641 hdd_err("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001642 } else if (global_p2p_connection_status ==
1643 P2P_CLIENT_COMPLETED_STATE) {
1644 global_p2p_connection_status =
1645 P2P_NOT_ACTIVE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001646 hdd_err("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001647 }
1648 }
1649#endif
1650
1651 }
1652 }
1653
1654 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001655 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001656 if (hdd_remove_beacon_filter(pAdapter) != 0)
1657 hdd_err("hdd_remove_beacon_filter() failed");
1658
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001659 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301660 uint8_t i;
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001661 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001662 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301663 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301664 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1665 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301666 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001667 }
1668 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301669 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001670 for (i = 0; i < MAX_PEERS; i++) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301671 if (0 == pHddStaCtx->conn_info.staId[i])
1672 continue;
1673 sta_id = pHddStaCtx->conn_info.staId[i];
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001674 hdd_info("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301675 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301676 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001677 hdd_err("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301678 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301679 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301680 }
1681 /* set the staid and peer mac as 0, all other
1682 * reset are done in hdd_connRemoveConnectInfo.
1683 */
1684 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301685 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301686 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301687 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1688 pHddCtx->sta_to_adapter[sta_id] = NULL;
1689 }
1690 } else {
1691 sta_id = pHddStaCtx->conn_info.staId[0];
Nitesh Shahcc962812017-02-01 11:58:15 +05301692 hdd_info("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301693
1694 /* clear scan cache for Link Lost */
1695 if (pRoamInfo && !pRoamInfo->reasonCode &&
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301696 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301697 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1698 pHddStaCtx->conn_info.bssId.bytes);
1699 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1700 pHddStaCtx->conn_info.bssId.bytes);
1701 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301702 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 /* Clear saved connection information in HDD */
1705 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301707 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708
1709#ifdef FEATURE_WLAN_TDLS
1710 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1711 wlan_hdd_tdls_disconnection_callback(pAdapter);
1712#endif
1713
Krunal Sonibe766b02016-03-10 13:00:44 -08001714 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1715 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1717 (pAdapter),
1718 pAdapter->sessionId);
1719 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301720 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001721 /* Unblock anyone waiting for disconnect to complete */
1722 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301723 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 return status;
1725}
1726
1727/**
1728 * hdd_set_peer_authorized_event() - set peer_authorized_event
1729 * @vdev_id: vdevid
1730 *
1731 * Return: None
1732 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001733static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301735 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 hdd_adapter_t *adapter = NULL;
1737
1738 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1739 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001740 hdd_err("Invalid vdev_id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001741 }
1742 complete(&adapter->sta_authorized_event);
1743}
1744
1745/**
1746 * hdd_change_peer_state() - change peer state
1747 * @pAdapter: HDD adapter
1748 * @sta_state: peer state
1749 * @roam_synch_in_progress: roam synch in progress
1750 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301751 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301753QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 uint8_t sta_id,
1755 enum ol_txrx_peer_state sta_state,
1756 bool roam_synch_in_progress)
1757{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301758 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001759 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001760 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1761 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1762 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001763
1764 if (!pdev) {
1765 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301766 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001767 }
1768
1769 if (sta_id >= WLAN_MAX_STA_COUNT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001770 hdd_err("Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301771 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 }
1773
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001774 peer = cdp_peer_find_by_local_id(soc,
1775 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301777 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778
Leo Changfdb45c32016-10-28 11:09:23 -07001779 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001780 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001781 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001782 return QDF_STATUS_E_FAULT;
1783 }
1784
Leo Changfdb45c32016-10-28 11:09:23 -07001785 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301786 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001787 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301788 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 }
1790#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1791 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301792 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793#endif
1794
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001795 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1797 /* make sure event is reset */
1798 INIT_COMPLETION(pAdapter->sta_authorized_event);
1799#endif
1800
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001801 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 hdd_set_peer_authorized_event,
1803 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001805 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301806 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 }
1808
Krunal Sonibe766b02016-03-10 13:00:44 -08001809 if (pAdapter->device_mode == QDF_STA_MODE ||
1810 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001812 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001813 unsigned long rc;
1814
1815 /* wait for event from firmware to set the event */
1816 rc = wait_for_completion_timeout(
1817 &pAdapter->sta_authorized_event,
1818 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1819 if (!rc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001820 hdd_notice("timeout waiting for sta_authorized_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 }
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001822 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1823 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001824 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825#endif
1826 }
1827 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301828 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829}
1830
1831/**
1832 * hdd_roam_register_sta() - register station
1833 * @pAdapter: pointer to adapter
1834 * @pRoamInfo: pointer to roam info
1835 * @staId: station identifier
1836 * @pPeerMacAddress: peer MAC address
1837 * @pBssDesc: pointer to BSS description
1838 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301839 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001840 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001841QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001842 tCsrRoamInfo *pRoamInfo,
1843 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301844 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001845 tSirBssDescription *pBssDesc)
1846{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301847 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001848 struct ol_txrx_desc_type staDesc = { 0 };
1849 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001850 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001851 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1852 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001853
1854 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301855 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856
1857 /* Get the Station ID from the one saved during the association */
1858 staDesc.sta_id = staId;
1859
1860 /* set the QoS field appropriately */
1861 if (hdd_wmm_is_active(pAdapter))
1862 staDesc.is_qos_enabled = 1;
1863 else
1864 staDesc.is_qos_enabled = 0;
1865
1866#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001867 hdd_notice("WAPI STA Registered: %d",
1868 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001869 if (pAdapter->wapi_info.fIsWapiSta)
1870 staDesc.is_wapi_supported = 1;
1871 else
1872 staDesc.is_wapi_supported = 0;
1873#endif /* FEATURE_WLAN_WAPI */
1874
Dhanashri Atre50141c52016-04-07 13:15:29 -07001875 /* Register the vdev transmit and receive functions */
1876 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1877 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001878
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001879 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1880 (struct cdp_pdev *)pdev,
1881 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001882 if (!pAdapter->txrx_vdev) {
1883 hdd_err("%s find vdev fail", __func__);
1884 return QDF_STATUS_E_FAILURE;
1885 }
1886
1887 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001888 cdp_vdev_register(soc,
1889 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001890 if (!txrx_ops.tx.tx) {
1891 hdd_err("%s vdev register fail", __func__);
1892 return QDF_STATUS_E_FAILURE;
1893 }
1894
Dhanashri Atre50141c52016-04-07 13:15:29 -07001895 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001896 qdf_status = cdp_peer_register(soc,
1897 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301898 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001899 hdd_warn("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001900 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301901 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 }
1903
1904 if (!pRoamInfo->fAuthRequired) {
1905 /*
1906 * Connections that do not need Upper layer auth, transition
1907 * TLSHIM directly to 'Authenticated' state
1908 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301909 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001910 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001911 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001912#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1913 pRoamInfo->roamSynchInProgress
1914#else
1915 false
1916#endif
1917 );
1918
1919 hdd_conn_set_authenticated(pAdapter, true);
1920 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001921 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001922 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301923 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001924 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001925 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001926#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1927 pRoamInfo->roamSynchInProgress
1928#else
1929 false
1930#endif
1931 );
1932 hdd_conn_set_authenticated(pAdapter, false);
1933 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301934 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935}
1936
1937/**
1938 * hdd_send_re_assoc_event() - send reassoc event
1939 * @dev: pointer to net device
1940 * @pAdapter: pointer to adapter
1941 * @pCsrRoamInfo: pointer to roam info
1942 * @reqRsnIe: pointer to RSN Information element
1943 * @reqRsnLength: length of RSN IE
1944 *
1945 * Return: none
1946 */
1947static void hdd_send_re_assoc_event(struct net_device *dev,
1948 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1949 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1950{
1951 unsigned int len = 0;
1952 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001953 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
1954 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 uint32_t rspRsnLength = 0;
1956 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1958 uint8_t *buf_ptr, ssid_ie_len;
1959 struct cfg80211_bss *bss = NULL;
1960 uint8_t *final_req_ie = NULL;
1961 tCsrRoamConnectedProfile roam_profile;
1962 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1963
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001964 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1965
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08001966 if (pAdapter->defer_disconnect) {
1967 hdd_debug("Do not send roam event as discon will be processed");
1968 goto done;
1969 }
1970
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001971 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001972 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001973 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974 }
1975
Naveen Rawat14298b92015-11-25 16:27:41 -08001976 if (!assoc_req_ies) {
1977 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001978 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001979 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001980 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001981 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001982 goto done;
1983 }
1984
1985 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001986 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 goto done;
1988 }
1989
1990 pFTAssocRsp =
1991 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1992 pCsrRoamInfo->nAssocReqLength);
1993 if (pFTAssocRsp == NULL)
1994 goto done;
1995
1996 /* pFTAssocRsp needs to point to the IEs */
1997 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001998 hdd_info("AssocRsp is now at %02x%02x",
1999 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002000
2001 /*
2002 * Active session count is decremented upon disconnection, but during
2003 * roaming, there is no disconnect indication and hence active session
2004 * count is not decremented.
2005 * After roaming is completed, active session count is incremented
2006 * as a part of connect indication but effectively after roaming the
2007 * active session count should still be the same and hence upon
2008 * successful reassoc decrement the active session count here.
2009 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002010 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05302011 cds_decr_session_set_pcl(pAdapter->device_mode,
2012 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013
2014 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2015 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2016 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302017 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2018 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019
2020 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302021 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2023 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302024
2025 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2026 chan, pCsrRoamInfo->bssid.bytes,
2027 &roam_profile.SSID.ssId[0],
2028 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029
2030 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002031 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 buf_ptr = buf_ssid_ie;
2033 *buf_ptr = SIR_MAC_SSID_EID;
2034 buf_ptr++;
2035 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2036 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002038 roam_profile.SSID.length);
2039 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08002040 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302041 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002042 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002043 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002044 if (final_req_ie == NULL)
2045 goto done;
2046 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302047 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302049 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2050 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2051 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002052 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002053 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302054 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002055 final_req_ie, (ssid_ie_len + reqRsnLength));
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002056 cfg80211_roamed_bss(dev, bss,
2057 final_req_ie, (ssid_ie_len + reqRsnLength),
2058 rspRsnIe, rspRsnLength, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002059
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302060 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002061 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2062 pCsrRoamInfo->nAssocReqLength);
2063
2064 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302065 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002066 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2067
Prakash Dhavali989127d2016-11-29 14:56:44 +05302068 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002069 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2070 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002071 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002072done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002073 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002074 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002075 qdf_mem_free(final_req_ie);
2076 qdf_mem_free(rspRsnIe);
2077 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002078}
2079
2080/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302081 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002082 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302083 *
2084 * Return: roam sync status if roaming offloaded else false
2085 */
2086#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002087bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302088{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002089 if (roaminfo)
2090 return roaminfo->roamSynchInProgress;
2091 else
2092 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302093}
2094#endif
2095
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002096/**
2097 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2098 * @hddstactx: pointer to HDD sta context
2099 * @roaminfo: pointer to roaminfo structure
2100 *
2101 * This function returns staid for IBSS peer. If peer is broadcast
2102 * MAC address return self staid(0) else find the peer sta id of
2103 * the peer.
2104 *
2105 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2106 */
2107static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2108 tCsrRoamInfo *roaminfo)
2109{
2110 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2111 QDF_STATUS status;
2112
2113 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2114 staid = 0;
2115 } else {
2116 status = hdd_get_peer_sta_id(hddstactx,
2117 &roaminfo->peerMac, &staid);
2118 if (status != QDF_STATUS_SUCCESS) {
2119 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2120 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2121 }
2122 }
2123
2124 return staid;
2125}
Govind Singhedc5cda2015-10-23 17:11:35 +05302126
2127/**
2128 * hdd_change_sta_state_authenticated()-
2129 * This function changes STA state to authenticated
2130 * @adapter: pointer to the adapter structure.
2131 * @roaminfo: pointer to the RoamInfo structure.
2132 *
2133 * This is called from hdd_RoamSetKeyCompleteHandler
2134 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2135 *
2136 * Return: 0 on success and errno on failure
2137 */
2138static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2139 tCsrRoamInfo *roaminfo)
2140{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002141 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002142 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002143 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302144 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002145 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302146
Dustin Brownf660fb42016-09-09 12:04:00 -07002147 timeout = hddstactx->hdd_ReassocScenario ?
2148 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002149 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002150
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002151 if (QDF_IBSS_MODE == adapter->device_mode)
2152 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2153 else
2154 staid = hddstactx->conn_info.staId[0];
2155
2156 hdd_info("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302157
2158 /* Connections that do not need Upper layer authentication,
2159 * transition TL to 'Authenticated' state after the keys are set
2160 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002161 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302162 hdd_is_roam_sync_in_progress(roaminfo));
2163 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002164 if ((QDF_STA_MODE == adapter->device_mode) ||
2165 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302166 sme_ps_enable_auto_ps_timer(
2167 WLAN_HDD_GET_HAL_CTX(adapter),
2168 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002169 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302170 }
2171
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002172 return qdf_status_to_os_return(status);
2173}
2174
2175/**
2176 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2177 * if key installation is required
2178 * @encr_type: encryption type
2179 *
2180 * Return: true if key installation is required and false otherwise.
2181 */
2182static inline bool hdd_is_key_install_required_for_ibss(
2183 eCsrEncryptionType encr_type)
2184{
2185 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2186 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2187 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
2188 eCSR_ENCRYPT_TYPE_AES == encr_type)
2189 return true;
2190 else
2191 return false;
2192}
2193
2194/**
2195 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2196 * complete
2197 * @adapter: pointer to HDD adapter
2198 * @roaminfo: pointer to roam info
2199 * @roam_result: roam result
2200 *
2201 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2202 * This function checks for the successful set key completion and update
2203 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2204 *
2205 * Return: None
2206 */
2207static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2208 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2209{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002210 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2211 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2212
2213 /*
2214 * If the security mode is one of the following, IBSS peer will be
2215 * waiting in CONN state and we will move the peer state to AUTH
2216 * here. For non-secure connection, no need to wait for set-key complete
2217 * peer will be moved to AUTH in hdd_roam_register_sta.
2218 */
2219 if (QDF_IBSS_MODE == adapter->device_mode) {
2220 if (hdd_is_key_install_required_for_ibss(encr_type))
2221 hdd_change_sta_state_authenticated(adapter, roaminfo);
2222
2223 return;
2224 }
2225
2226 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2227 hdd_sta_ctx->conn_info.gtk_installed = true;
2228 /*
2229 * PTK exchange happens in preauthentication itself if key_mgmt
2230 * is FT-PSK, ptk_installed was false as there is no set PTK
2231 * after roaming. STA TL state moves to authenticated only if
2232 * ptk_installed is true. So, make ptk_installed to true in
2233 * case of 11R roaming.
2234 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302235 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2236 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002237 hdd_sta_ctx->conn_info.ptk_installed = true;
2238 } else {
2239 hdd_sta_ctx->conn_info.ptk_installed = true;
2240 }
2241
2242 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2243 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2244 * unicast key and it was resulting in sending few un-encrypted packet.
2245 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2246 * set the unicast and broadcast key.
2247 */
2248 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2249 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2250 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2251 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2252 if (hdd_sta_ctx->conn_info.gtk_installed &&
2253 hdd_sta_ctx->conn_info.ptk_installed)
2254 hdd_change_sta_state_authenticated(adapter, roaminfo);
2255 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2256 hdd_change_sta_state_authenticated(adapter, roaminfo);
2257 }
2258
2259 if (hdd_sta_ctx->conn_info.gtk_installed &&
2260 hdd_sta_ctx->conn_info.ptk_installed) {
2261 hdd_sta_ctx->conn_info.gtk_installed = false;
2262 hdd_sta_ctx->conn_info.ptk_installed = false;
2263 }
2264
2265 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2266
2267 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302268}
2269
2270/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 * hdd_roam_set_key_complete_handler() - Update the security parameters
2272 * @pAdapter: pointer to adapter
2273 * @pRoamInfo: pointer to roam info
2274 * @roamId: roam id
2275 * @roamStatus: roam status
2276 * @roamResult: roam result
2277 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302278 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302280static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 tCsrRoamInfo *pRoamInfo,
2282 uint32_t roamId,
2283 eRoamCmdStatus roamStatus,
2284 eCsrRoamResult roamResult)
2285{
2286 eCsrEncryptionType connectedCipherAlgo;
2287 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002288 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302289
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002290 ENTER();
2291
2292 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002293 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302294 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 }
2296 /*
2297 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2298 * then go to 'authenticated'. For all other authentication types
2299 * (those that do not require upper layer authentication) we can put TL
2300 * directly into 'authenticated' state.
2301 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002302 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 MAC_ADDRESS_STR, roamStatus, roamResult,
2304 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2305
2306 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2307 &connectedCipherAlgo);
2308 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002309 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2310 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 } else {
2312 /*
2313 * possible disassoc after issuing set key and waiting
2314 * set key complete.
2315 */
2316 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2317 }
2318
2319 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302320 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002321}
2322
2323/**
2324 * hdd_perform_roam_set_key_complete() - perform set key complete
2325 * @pAdapter: pointer to adapter
2326 *
2327 * Return: none
2328 */
2329void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2330{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302331 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2333 tCsrRoamInfo roamInfo;
2334 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302335 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302336 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302337 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302338 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302340 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002341 hdd_roam_set_key_complete_handler(pAdapter,
2342 &roamInfo,
2343 pHddStaCtx->roam_info.roamId,
2344 pHddStaCtx->roam_info.roamStatus,
2345 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302346 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002347 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348
2349 pHddStaCtx->roam_info.deferKeyComplete = false;
2350}
2351
2352/**
2353 * hdd_association_completion_handler() - association completion handler
2354 * @pAdapter: pointer to adapter
2355 * @pRoamInfo: pointer to roam info
2356 * @roamId: roam id
2357 * @roamStatus: roam status
2358 * @roamResult: roam result
2359 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302360 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302362static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002363 tCsrRoamInfo *pRoamInfo,
2364 uint32_t roamId,
2365 eRoamCmdStatus roamStatus,
2366 eCsrRoamResult roamResult)
2367{
2368 struct net_device *dev = pAdapter->dev;
2369 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2370 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302371 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002372 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2373 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002375 bool hddDisconInProgress = false;
2376 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302377 tSirResultCodes timeout_reason = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378
2379 if (!pHddCtx) {
2380 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302381 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002382 }
2383
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302384 /* validate config */
2385 if (!pHddCtx->config) {
2386 hdd_err("config is NULL");
2387 return QDF_STATUS_E_NULL_VALUE;
2388 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389 /* HDD has initiated disconnect, do not send connect result indication
2390 * to kernel as it will be handled by __cfg80211_disconnect.
2391 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302392 if (((eConnectionState_Disconnecting ==
2393 pHddStaCtx->conn_info.connState) ||
2394 (eConnectionState_NotConnected ==
2395 pHddStaCtx->conn_info.connState)) &&
2396 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2397 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002398 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399 hddDisconInProgress = true;
2400 }
2401
2402 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2403 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002404 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302405 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002406 }
2407 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 hdd_conn_set_connection_state(pAdapter,
2409 eConnectionState_Associated);
2410 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002412 /* Save the connection info from CSR... */
2413 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2414 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002415
2416 if (hdd_add_beacon_filter(pAdapter) != 0)
2417 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002418#ifdef FEATURE_WLAN_WAPI
2419 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2420 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2421 || pRoamInfo->u.pConnectedProfile->AuthType ==
2422 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2423 pAdapter->wapi_info.fIsWapiSta = 1;
2424 } else {
2425 pAdapter->wapi_info.fIsWapiSta = 0;
2426 }
2427#endif /* FEATURE_WLAN_WAPI */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428 /* Indicate 'connect' status to user space */
2429 hdd_send_association_event(dev, pRoamInfo);
2430
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002431 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 if (pHddCtx->miracast_value)
2433 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2434 }
2435
2436 /* Initialize the Linkup event completion variable */
2437 INIT_COMPLETION(pAdapter->linkup_event_var);
2438
2439 /*
2440 * Sometimes Switching ON the Carrier is taking time to activate
2441 * the device properly. Before allowing any packet to go up to
2442 * the application, device activation has to be ensured for
2443 * proper queue mapping by the kernel. we have registered net
2444 * device notifier for device change notification. With this we
2445 * will come to know that the device is getting
2446 * activated properly.
2447 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002448 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002449 /*
2450 * Enable Linkup Event Servicing which allows the net
2451 * device notifier to set the linkup event variable.
2452 */
2453 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002455 /* Switch on the Carrier to activate the device */
2456 wlan_hdd_netif_queue_control(pAdapter,
2457 WLAN_NETIF_CARRIER_ON,
2458 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002460 /*
2461 * Wait for the Link to up to ensure all the queues
2462 * are set properly by the kernel.
2463 */
2464 rc = wait_for_completion_timeout(
2465 &pAdapter->linkup_event_var,
2466 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2467 );
2468 if (!rc)
2469 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002470
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002471 /*
2472 * Disable Linkup Event Servicing - no more service
2473 * required from the net device notifier call.
2474 */
2475 pAdapter->isLinkUpSvcNeeded = false;
2476 } else {
2477 pHddStaCtx->ft_carrier_on = false;
2478 ft_carrier_on = true;
2479 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002480 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2481 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2482 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002483 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002484
2485 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2486
2487 if (hdd_ipa_is_enabled(pHddCtx))
2488 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002489 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002490 pRoamInfo->bssid.bytes);
2491
2492#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2493 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2494#endif
2495
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302496 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002497 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498
Nirav Shah1da77682016-05-03 20:16:39 +05302499 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2500 pAdapter->sessionId,
2501 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2502
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002503 /*
2504 * For reassoc, the station is already registered, all we need
2505 * is to change the state of the STA in TL.
2506 * If authentication is required (WPA/WPA2/DWEP), change TL to
2507 * CONNECTED instead of AUTHENTICATED.
2508 */
2509 if (!pRoamInfo->fReassocReq) {
2510 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002511 u8 *pFTAssocRsp = NULL;
2512 unsigned int assocRsplen = 0;
2513 u8 *pFTAssocReq = NULL;
2514 unsigned int assocReqlen = 0;
2515 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002516 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2517 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2518
2519 /* add bss_id to cfg80211 data base */
2520 bss =
2521 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2522 pRoamInfo);
2523 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302524 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002525 wlan_hdd_netif_queue_control(pAdapter,
2526 WLAN_NETIF_CARRIER_OFF,
2527 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302528 if (!hddDisconInProgress) {
2529 /*
2530 * Here driver was not able to add bss
2531 * in cfg80211 database this can happen
2532 * if connected channel is not valid,
2533 * i.e reg domain was changed during
2534 * connection. Queue disconnect for the
2535 * session if disconnect is not in
2536 * progress.
2537 */
2538 hdd_err("Disconnecting...");
2539 sme_roam_disconnect(
2540 WLAN_HDD_GET_HAL_CTX(pAdapter),
2541 pAdapter->sessionId,
2542 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2543 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302544 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002546 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2547 eCSR_AUTH_TYPE_FT_RSN
2548 || pRoamInfo->u.pConnectedProfile->AuthType ==
2549 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2550
2551 /* Association Response */
2552 pFTAssocRsp =
2553 (u8 *) (pRoamInfo->pbFrames +
2554 pRoamInfo->nBeaconLength +
2555 pRoamInfo->nAssocReqLength);
2556 if (pFTAssocRsp != NULL) {
2557 /*
2558 * pFTAssocRsp needs to point to the IEs
2559 */
2560 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002561 hdd_info("AssocRsp is now at %02x%02x",
2562 (unsigned int)pFTAssocRsp[0],
2563 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002564 assocRsplen =
2565 pRoamInfo->nAssocRspLength -
2566 FT_ASSOC_RSP_IES_OFFSET;
2567 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002568 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002569 assocRsplen = 0;
2570 }
2571
2572 /* Association Request */
2573 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2574 pRoamInfo->nBeaconLength);
2575 if (pFTAssocReq != NULL) {
2576 if (!ft_carrier_on) {
2577 /*
2578 * pFTAssocReq needs to point to
2579 * the IEs
2580 */
2581 pFTAssocReq +=
2582 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002583 hdd_info("pFTAssocReq is now at %02x%02x",
2584 (unsigned int)
2585 pFTAssocReq[0],
2586 (unsigned int)
2587 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 assocReqlen =
2589 pRoamInfo->nAssocReqLength -
2590 FT_ASSOC_REQ_IES_OFFSET;
2591 } else {
2592 /*
2593 * This should contain only the
2594 * FTIEs
2595 */
2596 assocReqlen =
2597 pRoamInfo->nAssocReqLength;
2598 }
2599 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002600 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 assocReqlen = 0;
2602 }
2603
2604 if (ft_carrier_on) {
2605 if (!hddDisconInProgress) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302606 struct cfg80211_bss *roam_bss;
2607
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 /*
2609 * After roaming is completed,
2610 * active session count is
2611 * incremented as a part of
2612 * connect indication but
2613 * effectively the active
2614 * session count should still
2615 * be the same and hence upon
2616 * successful reassoc
2617 * decrement the active session
2618 * count here.
2619 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002620 if (!hdd_is_roam_sync_in_progress
2621 (pRoamInfo))
2622 cds_decr_session_set_pcl
2623 (pAdapter->device_mode,
2624 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002625 hdd_info("ft_carrier_on is %d, sending roamed indication",
2626 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 chan =
2628 ieee80211_get_channel
2629 (pAdapter->wdev.wiphy,
2630 (int)pRoamInfo->pBssDesc->
2631 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002632 hdd_info(
2633 "assocReqlen %d assocRsplen %d",
2634 assocReqlen,
2635 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002636
2637 hdd_notice(
2638 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302639 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302640 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302641 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002642 pFTAssocReq,
2643 assocReqlen);
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002644 if (!pAdapter->defer_disconnect) {
2645 roam_bss = hdd_cfg80211_get_bss(
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302646 pAdapter->wdev.wiphy,
2647 chan,
2648 pRoamInfo->bssid.bytes,
2649 pRoamInfo->u.
2650 pConnectedProfile->SSID.ssId,
2651 pRoamInfo->u.
2652 pConnectedProfile->SSID.length);
Varun Reddy Yeturua5784142017-03-10 12:11:44 -08002653 cfg80211_roamed_bss(dev,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302654 roam_bss,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002655 pFTAssocReq,
2656 assocReqlen,
2657 pFTAssocRsp,
2658 assocRsplen,
2659 GFP_KERNEL);
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002660 wlan_hdd_send_roam_auth_event(
Prakash Dhavali989127d2016-11-29 14:56:44 +05302661 pAdapter,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002662 pRoamInfo->bssid.bytes,
2663 pFTAssocReq,
2664 assocReqlen,
2665 pFTAssocRsp,
2666 assocRsplen,
2667 pRoamInfo);
Varun Reddy Yeturuc13305e2017-03-10 14:05:02 -08002668 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 }
2670 if (sme_get_ftptk_state
2671 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2672 pAdapter->sessionId)) {
2673 sme_set_ftptk_state
2674 (WLAN_HDD_GET_HAL_CTX
2675 (pAdapter),
2676 pAdapter->sessionId,
2677 false);
2678 pRoamInfo->fAuthRequired =
2679 false;
2680
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302681 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002682 roam_info.bssid,
2683 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302684 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302685 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 roam_info.peerMac,
2687 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302688 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 pHddStaCtx->roam_info.roamId =
2690 roamId;
2691 pHddStaCtx->roam_info.
2692 roamStatus = roamStatus;
2693 pHddStaCtx->roam_info.
2694 deferKeyComplete = true;
2695 }
2696 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002697 hdd_info("ft_carrier_on is %d, sending connect indication",
2698 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302699 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302700 pRoamInfo->
2701 bssid.bytes,
2702 pRoamInfo,
2703 pFTAssocReq,
2704 assocReqlen,
2705 pFTAssocRsp,
2706 assocRsplen,
2707 WLAN_STATUS_SUCCESS,
2708 GFP_KERNEL,
2709 false,
2710 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002711 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002712 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002713 /*
2714 * wpa supplicant expecting WPA/RSN IE in
2715 * connect result.
2716 */
2717 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2718 (pAdapter),
2719 pAdapter->sessionId,
2720 &reqRsnLength,
2721 reqRsnIe);
2722
2723 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2724 (pAdapter),
2725 pAdapter->sessionId,
2726 &rspRsnLength,
2727 rspRsnIe);
2728 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002729 if (ft_carrier_on)
2730 hdd_send_re_assoc_event(dev,
2731 pAdapter,
2732 pRoamInfo,
2733 reqRsnIe,
2734 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002735 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002736 hdd_info("sending connect indication to nl80211:for bssid "
2737 MAC_ADDRESS_STR
2738 " result:%d and Status:%d",
2739 MAC_ADDR_ARRAY
2740 (pRoamInfo->bssid.bytes),
2741 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742
2743 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302744 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302745 pRoamInfo->
2746 bssid.bytes,
2747 pRoamInfo,
2748 reqRsnIe,
2749 reqRsnLength,
2750 rspRsnIe,
2751 rspRsnLength,
2752 WLAN_STATUS_SUCCESS,
2753 GFP_KERNEL,
2754 false,
2755 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002756 }
2757 }
2758 }
2759 if (!hddDisconInProgress) {
2760 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002761 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 bss);
2763
2764 /*
2765 * Perform any WMM-related association
2766 * processing.
2767 */
2768 hdd_wmm_assoc(pAdapter, pRoamInfo,
2769 eCSR_BSS_TYPE_INFRASTRUCTURE);
2770
2771 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002772 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002773 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002774 qdf_status = hdd_roam_register_sta(pAdapter,
2775 pRoamInfo,
2776 pHddStaCtx->conn_info.staId[0],
2777 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002778 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002779 wlan_hdd_netif_queue_control(pAdapter,
2780 WLAN_WAKE_ALL_NETIF_QUEUE,
2781 WLAN_CONTROL_PATH);
2782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 }
2784 } else {
2785 /*
2786 * wpa supplicant expecting WPA/RSN IE in connect result
2787 * in case of reassociation also need to indicate it to
2788 * supplicant.
2789 */
2790 csr_roam_get_wpa_rsn_req_ie(
2791 WLAN_HDD_GET_HAL_CTX(pAdapter),
2792 pAdapter->sessionId,
2793 &reqRsnLength, reqRsnIe);
2794
2795 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2796 reqRsnIe, reqRsnLength);
2797 /* Reassoc successfully */
2798 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302799 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002800 hdd_change_peer_state(pAdapter,
2801 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002802 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2804 pRoamInfo->roamSynchInProgress
2805#else
2806 false
2807#endif
2808 );
2809 hdd_conn_set_authenticated(pAdapter, false);
2810 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002811 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2812 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302813 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002814 hdd_change_peer_state(pAdapter,
2815 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002816 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002817#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2818 pRoamInfo->roamSynchInProgress
2819#else
2820 false
2821#endif
2822 );
2823 hdd_conn_set_authenticated(pAdapter, true);
2824 }
2825
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302826 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002827 /*
2828 * Perform any WMM-related association
2829 * processing
2830 */
2831 hdd_wmm_assoc(pAdapter, pRoamInfo,
2832 eCSR_BSS_TYPE_INFRASTRUCTURE);
2833 }
2834
2835 /* Start the tx queues */
2836#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2837 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002838 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002840 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002841 wlan_hdd_netif_queue_control(pAdapter,
2842 WLAN_WAKE_ALL_NETIF_QUEUE,
2843 WLAN_CONTROL_PATH);
2844 }
2845
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302846#ifdef FEATURE_WLAN_TDLS
2847 wlan_hdd_tdls_connection_callback(pAdapter);
2848#endif
2849
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302850 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002851 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302852 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002853 }
2854#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302855 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002856 sizeof(pAdapter->hdd_stats.hddPmfStats));
2857#endif
2858 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302859 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002860 hdd_wext_state_t *pWextState =
2861 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2862 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302863 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2864 " result:%d and Status:%d",
2865 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2866 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002867 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302868 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2869 " result:%d and Status:%d",
2870 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2871 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302872
2873 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2874 (pRoamInfo &&
2875 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2876 pRoamInfo->statusCode) ||
2877 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2878 pRoamInfo->statusCode) ||
2879 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2880 pRoamInfo->statusCode)))) {
2881 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2882 pRoamInfo ?
2883 pRoamInfo->bssid.bytes :
2884 pWextState->req_bssId.bytes);
2885 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2886 pRoamInfo ?
2887 pRoamInfo->bssid.bytes :
2888 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302889 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302890 }
2891
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002892 /*
2893 * CR465478: Only send up a connection failure result when CSR
2894 * has completed operation - with a ASSOCIATION_FAILURE status.
2895 */
2896 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2897 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302898 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002899 hdd_err("send connect failure to nl80211: for bssid "
2900 MAC_ADDRESS_STR
2901 " result:%d and Status:%d reasoncode %d",
2902 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2903 roamResult, roamStatus,
2904 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302905 pHddStaCtx->conn_info.assoc_status_code =
2906 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08002907 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002908 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 MAC_ADDRESS_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002910 " result:%d and Status:%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2912 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08002913 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05302914 hdd_err("Invoking packetdump deregistration API");
2915 wlan_deregister_txrx_packetdump();
2916
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917 /* inform association failure event to nl80211 */
2918 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2919 roamResult) {
2920 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302921 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002922 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302923 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002924 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302925 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302926 connect_timeout,
2927 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302929 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302931 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002932 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302933 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302934 connect_timeout,
2935 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 } else {
Wu Gao77d28352016-11-23 17:50:56 +08002937 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302938 hdd_connect_result(dev,
2939 pRoamInfo->bssid.bytes,
2940 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08002941 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05302942 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302944 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302945 connect_timeout,
2946 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08002947 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302948 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302950 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002951 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302952 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302953 connect_timeout,
2954 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002955 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302956 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002957 } else if ((eCSR_ROAM_CANCELLED == roamStatus
2958 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05302959 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002960 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05302961 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002962 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302963 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302964 connect_timeout,
2965 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002966 }
2967
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002968 /*
2969 * Set connection state to eConnectionState_NotConnected only
2970 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002971 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002973 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
2974 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002976 hdd_conn_set_connection_state(pAdapter,
2977 eConnectionState_NotConnected);
2978 }
2979 hdd_wmm_init(pAdapter);
2980
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002981 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 wlan_hdd_netif_queue_control(pAdapter,
2983 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2984 WLAN_CONTROL_PATH);
2985 }
2986
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302987 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302989 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002990
Govind Singh24db1ed2015-12-18 15:54:59 +05302991 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2992 cds_force_sap_on_scc(roamResult,
2993 pRoamInfo->pBssDesc->channelId);
2994 } else {
2995 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302996 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302997 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302999 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000}
3001
3002/**
3003 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3004 * @pAdapter: pointer to adapter
3005 * @pRoamInfo: pointer to roam info
3006 * @roamId: roam id
3007 * @roamStatus: roam status
3008 * @roamResult: roam result
3009 *
3010 * Here we update the status of the Ibss when we receive information that we
3011 * have started/joined an ibss session.
3012 *
3013 * Return: none
3014 */
3015static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3016 tCsrRoamInfo *pRoamInfo,
3017 uint32_t roamId,
3018 eRoamCmdStatus roamStatus,
3019 eCsrRoamResult roamResult)
3020{
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003021 hdd_info("%s: id %d, status %d, result %d",
3022 pAdapter->dev->name, roamId,
3023 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024
3025 switch (roamResult) {
3026 /* both IBSS Started and IBSS Join should come in here. */
3027 case eCSR_ROAM_RESULT_IBSS_STARTED:
3028 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3029 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3030 {
3031 hdd_context_t *pHddCtx =
3032 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303033 hdd_station_ctx_t *hdd_sta_ctx =
3034 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303035 struct qdf_mac_addr broadcastMacAddr =
3036 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037
3038 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303039 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003040 return;
3041 }
3042
3043 /* When IBSS Started comes from CSR, we need to move
3044 * connection state to IBSS Disconnected (meaning no peers
3045 * are in the IBSS).
3046 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003047 hdd_conn_set_connection_state(pAdapter,
3048 eConnectionState_IbssDisconnected);
3049 /* notify wmm */
3050 hdd_wmm_connect(pAdapter, pRoamInfo,
3051 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303052
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003053 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303054
3055 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003056 pAdapter;
3057 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303058 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003059 &broadcastMacAddr,
3060 pRoamInfo->pBssDesc);
3061
3062 if (pRoamInfo->pBssDesc) {
3063 struct cfg80211_bss *bss;
3064#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3065 struct ieee80211_channel *chan;
3066 int chan_no;
3067 unsigned int freq;
3068#endif
3069 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003070 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3071 pAdapter->dev->name,
3072 MAC_ADDR_ARRAY(
3073 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074
3075 /* we must first give cfg80211 the BSS information */
3076 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3077 pRoamInfo);
3078 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003079 hdd_err("%s: unable to create IBSS entry",
3080 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003081 return;
3082 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003083 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003084 wlan_hdd_netif_queue_control(pAdapter,
3085 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3086 WLAN_CONTROL_PATH);
3087
3088#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3089 chan_no = pRoamInfo->pBssDesc->channelId;
3090
3091 if (chan_no <= 14)
3092 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003093 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003094 else
3095 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003096 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003097
3098 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3099
3100 if (chan)
3101 cfg80211_ibss_joined(pAdapter->dev,
3102 bss->bssid, chan,
3103 GFP_KERNEL);
3104 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003105 hdd_err("%s: chanId: %d, can't find channel",
3106 pAdapter->dev->name,
3107 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003108#else
3109 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3110 GFP_KERNEL);
3111#endif
3112 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003114 bss);
3115 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003116 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003117 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07003118 pAdapter->sessionId);
3119 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3120 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003121 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003122 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 break;
3124 }
3125
3126 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3127 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003128 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003129 break;
3130 }
3131
3132 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003133 hdd_err("%s: unexpected result %d",
3134 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003135 break;
3136 }
3137
3138 return;
3139}
3140
3141/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003142 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3143 * @sta_ctx: pointer to hdd station context
3144 * @sta_id: station ID
3145 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146 *
3147 * This information is passed to iwconfig later. The peer that joined
3148 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003149
3150 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003151 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003152bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3153 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003154{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003155 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003157 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3158 if (0 == sta_ctx->conn_info.staId[idx]) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003159 hdd_info("adding peer: %pM, sta_id: %d, at idx: %d",
3160 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003161 sta_ctx->conn_info.staId[idx] = sta_id;
3162 qdf_copy_macaddr(
3163 &sta_ctx->conn_info.peerMacAddress[idx],
3164 peer_mac_addr);
3165 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003166 }
3167 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003168 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169}
3170
3171/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003172 * hdd_delete_peer() - removes peer from hdd station context peer table
3173 * @sta_ctx: pointer to hdd station context
3174 * @sta_id: station ID
3175 *
3176 * Return: None
3177 */
3178void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3179{
3180 int i;
3181
3182 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3183 if (sta_id == sta_ctx->conn_info.staId[i]) {
3184 sta_ctx->conn_info.staId[i] = 0;
3185 return;
3186 }
3187 }
3188
3189 hdd_err(FL("sta_id %d is not present in peer table"), sta_id);
3190}
3191
3192/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3194 * @pAdapter: pointer to adapter
3195 * @staId: station id
3196 *
3197 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003198 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003199 * false otherwise.
3200 */
3201static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3202{
3203 bool fSuccess = false;
3204 int idx = 0;
3205 uint8_t valid_idx = 0;
3206 uint8_t del_idx = 0;
3207 uint8_t empty_slots = 0;
3208 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3209
Naveen Rawatc45d1622016-07-05 12:20:09 -07003210 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3212 pHddStaCtx->conn_info.staId[idx] = 0;
3213
Anurag Chouhanc5548422016-02-24 18:33:27 +05303214 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 peerMacAddress[idx]);
3216
3217 fSuccess = true;
3218
3219 /*
3220 * Note the deleted Index, if its 0 we need special
3221 * handling.
3222 */
3223 del_idx = idx;
3224
3225 empty_slots++;
3226 } else {
3227 if (pHddStaCtx->conn_info.staId[idx] != 0) {
3228 valid_idx = idx;
3229 } else {
3230 /* Found an empty slot */
3231 empty_slots++;
3232 }
3233 }
3234 }
3235
Naveen Rawatc45d1622016-07-05 12:20:09 -07003236 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003237 /* Last peer departed, set the IBSS state appropriately */
3238 pHddStaCtx->conn_info.connState =
3239 eConnectionState_IbssDisconnected;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003240 hdd_err("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003241 }
3242 /* Find next active staId, to have a valid sta trigger for TL. */
3243 if (fSuccess == true) {
3244 if (del_idx == 0) {
3245 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
3246 pHddStaCtx->conn_info.staId[0] =
3247 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303248 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 peerMacAddress[0],
3250 &pHddStaCtx->conn_info.
3251 peerMacAddress[valid_idx]);
3252
3253 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303254 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 peerMacAddress[valid_idx]);
3256 }
3257 }
3258 }
3259 return fSuccess;
3260}
3261
3262/**
3263 * roam_ibss_connect_handler() - IBSS connection handler
3264 * @pAdapter: pointer to adapter
3265 * @pRoamInfo: pointer to roam info
3266 *
3267 * We update the status of the IBSS to connected in this function.
3268 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303269 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003270 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303271static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 tCsrRoamInfo *pRoamInfo)
3273{
3274 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275 /*
3276 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3277 * a partner stations).
3278 */
3279 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3280
3281 /* Save the connection info from CSR... */
3282 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3283
3284 /* Send the bssid address to the wext. */
3285 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3286 /* add bss_id to cfg80211 data base */
3287 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3288 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003289 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303291 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003292 }
3293 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 bss);
3296
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303297 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003298}
3299
3300/**
3301 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3302 * @pAdapter: pointer to adapter
3303 * @pRoamInfo: pointer to roam info
3304 * @roamId: roam id
3305 * @roamStatus: roam status
3306 * @roamResult: roam result
3307 *
3308 * This function indicates the Mic failure to the supplicant
3309 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303310 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003311 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303312static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003313hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3314 tCsrRoamInfo *pRoamInfo,
3315 uint32_t roamId,
3316 eRoamCmdStatus roamStatus,
3317 eCsrRoamResult roamResult)
3318{
3319 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3320
3321 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3322 TKIP_COUNTER_MEASURE_STOPED ==
3323 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3324 struct iw_michaelmicfailure msg;
3325 union iwreq_data wreq;
3326 memset(&msg, '\0', sizeof(msg));
3327 msg.src_addr.sa_family = ARPHRD_ETHER;
3328 memcpy(msg.src_addr.sa_data,
3329 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3330 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003331 hdd_info("MIC MAC " MAC_ADDRESS_STR,
3332 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003333
3334 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3335 msg.flags = IW_MICFAILURE_GROUP;
3336 else
3337 msg.flags = IW_MICFAILURE_PAIRWISE;
3338 memset(&wreq, 0, sizeof(wreq));
3339 wreq.data.length = sizeof(msg);
3340 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3341 (char *)&msg);
3342 /* inform mic failure to nl80211 */
3343 cfg80211_michael_mic_failure(pAdapter->dev,
3344 pRoamInfo->u.pMICFailureInfo->
3345 taMacAddr,
3346 ((pRoamInfo->u.pMICFailureInfo->
3347 multicast ==
3348 eSIR_TRUE) ?
3349 NL80211_KEYTYPE_GROUP :
3350 NL80211_KEYTYPE_PAIRWISE),
3351 pRoamInfo->u.pMICFailureInfo->
3352 keyId,
3353 pRoamInfo->u.pMICFailureInfo->TSC,
3354 GFP_KERNEL);
3355
3356 }
3357
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303358 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003359}
3360
3361/**
3362 * roam_roam_connect_status_update_handler() - IBSS connect status update
3363 * @pAdapter: pointer to adapter
3364 * @pRoamInfo: pointer to roam info
3365 * @roamId: roam id
3366 * @roamStatus: roam status
3367 * @roamResult: roam result
3368 *
3369 * The Ibss connection status is updated regularly here in this function.
3370 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303371 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003372 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303373static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003374roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3375 tCsrRoamInfo *pRoamInfo,
3376 uint32_t roamId,
3377 eRoamCmdStatus roamStatus,
3378 eCsrRoamResult roamResult)
3379{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003380 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003381 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303382
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003383 switch (roamResult) {
3384 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3385 {
3386 hdd_station_ctx_t *pHddStaCtx =
3387 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003388 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003389 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003390
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303391 hdd_err("IBSS New Peer indication from SME "
3392 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3393 MAC_ADDRESS_STR " and stationID= %d",
3394 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3395 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3396 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003397
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003398 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003399 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3400 pRoamInfo->staId,
3401 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003402 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003403 break;
3404 }
3405
3406 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3407
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003408 if (hdd_is_key_install_required_for_ibss(encr_type))
3409 pRoamInfo->fAuthRequired = true;
3410
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303412 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003413 pRoamInfo,
3414 pRoamInfo->staId,
3415 &pRoamInfo->peerMac,
3416 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303417 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003418 hdd_err("Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303419 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 }
3421 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003422 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3423 if (stainfo == NULL) {
3424 hdd_err("memory allocation for station_info failed");
3425 return QDF_STATUS_E_NOMEM;
3426 }
3427 stainfo->filled = 0;
3428 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003429
3430 cfg80211_new_sta(pAdapter->dev,
3431 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003432 stainfo, GFP_KERNEL);
3433 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003434
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003435 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 pHddStaCtx->ibss_enc_key.keyDirection =
3437 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303438 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003439 &pRoamInfo->peerMac);
3440
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003441 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003442 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003443
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303444 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003445 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3446 (pAdapter),
3447 pAdapter->sessionId,
3448 &pHddStaCtx->ibss_enc_key,
3449 &roamId);
3450
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303451 if (QDF_STATUS_SUCCESS != qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003452 hdd_err("sme_roam_set_key failed, status=%d",
3453 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303454 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003455 }
3456 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003457 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003458 wlan_hdd_netif_queue_control(pAdapter,
3459 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3460 WLAN_CONTROL_PATH);
3461 break;
3462 }
3463
3464 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3465 {
3466
3467 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3468
3469 break;
3470 }
3471 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3472 {
3473 hdd_station_ctx_t *pHddStaCtx =
3474 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3475
3476 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003477 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003478
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303479 hdd_err("IBSS Peer Departed from SME "
3480 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3481 MAC_ADDRESS_STR " and stationID= %d",
3482 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3483 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3484 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485
3486 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3487
3488 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3489 pHddStaCtx->ibss_sta_generation++;
3490
3491 cfg80211_del_sta(pAdapter->dev,
3492 (const u8 *)&pRoamInfo->peerMac.bytes,
3493 GFP_KERNEL);
3494 break;
3495 }
3496 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3497 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003498 hdd_info("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003500 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501 wlan_hdd_netif_queue_control(pAdapter,
3502 WLAN_NETIF_TX_DISABLE_N_CARRIER,
3503 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003504 hdd_conn_set_connection_state(pAdapter,
3505 eConnectionState_NotConnected);
3506
3507 /* Send the bssid address to the wext. */
3508 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3509 break;
3510 }
3511 default:
3512 break;
3513
3514 }
3515
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303516 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003517}
3518
3519#ifdef FEATURE_WLAN_TDLS
3520/**
3521 * hdd_roam_register_tdlssta() - register new TDLS station
3522 * @pAdapter: pointer to adapter
3523 * @peerMac: pointer to peer MAC address
3524 * @staId: station identifier
3525 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303526 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003527 *
3528 * Construct the staDesc and register with TL the new STA.
3529 * This is called as part of ADD_STA in the TDLS setup.
3530 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303531 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303533QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003534 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303535 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003536{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303537 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003538 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003539 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003540 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3541 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003542
3543 /*
3544 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3545 * be peer MAC, here we are working on direct Link
3546 */
3547 staDesc.sta_id = staId;
3548
3549 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303550 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003551
Dhanashri Atre50141c52016-04-07 13:15:29 -07003552 /* Register the vdev transmit and receive functions */
3553 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3554 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003555 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003556 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3557 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003558 pAdapter, &txrx_ops);
3559 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003560
3561 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003562 qdf_status = cdp_peer_register(soc,
3563 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303564 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003565 hdd_err("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303566 qdf_status, qdf_status);
3567 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003568 }
3569
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303570 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571}
3572
3573/**
3574 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3575 * @pAdapter: pointer to adapter
3576 * @staId: station identifier
3577 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303578 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003579 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303580QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003581{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303582 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003583 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003584 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3585 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303586 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003587 hdd_warn("cdp_clear_peer() failed for staID %d. Status=%d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003588 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003589 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303590 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003591}
3592
3593/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003594 * hdd_tdls_connection_tracker_update() - update connection tracker state
3595 * @adapter: pointer to adapter
3596 * @roam_info: pointer to roam info
3597 * @hdd_tdls_ctx: tdls context
3598 *
3599 * Return: QDF_STATUS enumeration
3600 */
3601static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3602 tCsrRoamInfo *roam_info,
3603 tdlsCtx_t *hdd_tdls_ctx)
3604{
3605 hddTdlsPeer_t *curr_peer;
3606 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3607
3608 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303609 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003610
3611 if (!curr_peer) {
3612 hdd_err("curr_peer is null");
3613 return QDF_STATUS_E_FAILURE;
3614 }
3615
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003616 if (eTDLS_LINK_CONNECTED ==
3617 curr_peer->link_status) {
3618 hdd_err("Received CONNECTION_TRACKER_NOTIFICATION "
3619 MAC_ADDRESS_STR
3620 " staId: %d, reason: %d",
3621 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3622 roam_info->staId,
3623 roam_info->reasonCode);
3624
3625 if (roam_info->reasonCode ==
3626 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3627 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003628 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3629 roam_info->reasonCode ==
3630 eWMI_TDLS_SCAN_STARTED_EVENT)
3631 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003632 else if (roam_info->reasonCode ==
3633 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3634 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003635 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3636 roam_info->reasonCode ==
3637 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3638 hdd_ctx->enable_tdls_connection_tracker = true;
Nitesh Shahc549dd52017-02-23 16:45:44 +05303639 hdd_info("hdd_ctx->enable_tdls_connection_tracker %d",
3640 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003641 } else {
3642 hdd_err("TDLS not connected, ignore notification, reason: %d",
3643 roam_info->reasonCode);
3644 }
3645
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003646 return QDF_STATUS_SUCCESS;
3647}
3648
3649
3650
3651
3652/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003653 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3654 * @pAdapter: pointer to adapter
3655 * @pRoamInfo: pointer to roam info
3656 * @roamId: roam id
3657 * @roamStatus: roam status
3658 * @roamResult: roam result
3659 *
3660 * HDD interface between SME and TL to ensure TDLS client registration with
3661 * TL in case of new TDLS client is added and deregistration at the time
3662 * TDLS client is deleted.
3663 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303664 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003665 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303666static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3668 tCsrRoamInfo *pRoamInfo,
3669 uint32_t roamId,
3670 eRoamCmdStatus roamStatus,
3671 eCsrRoamResult roamResult)
3672{
3673 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303674 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003675 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303676 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 uint8_t staIdx;
3678 hddTdlsPeer_t *curr_peer;
3679 uint32_t reason;
3680
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003681 hdd_info("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003682 roamResult ==
3683 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3684 ==
3685 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3686 roamResult ==
3687 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3688 : roamResult ==
3689 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3690 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3691 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3692 roamResult ==
3693 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3694 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3695 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3696 : roamResult ==
3697 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3698 : roamResult ==
3699 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3700 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3701 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3702
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003703 switch (roamResult) {
3704 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3705 {
3706 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003707 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003708 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303709 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3710
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 } else {
3712 /*
3713 * Check if there is available index for this new TDLS
3714 * STA.
3715 */
3716 for (staIdx = 0;
3717 staIdx < pHddCtx->max_num_tdls_sta;
3718 staIdx++) {
3719 if (0 ==
3720 pHddCtx->tdlsConnInfo[staIdx].
3721 staId) {
3722 pHddCtx->tdlsConnInfo[staIdx].
3723 sessionId =
3724 pRoamInfo->sessionId;
3725 pHddCtx->tdlsConnInfo[staIdx].
3726 staId = pRoamInfo->staId;
3727
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003728 hdd_warn("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003729 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003730 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003731 staIdx,
3732 pHddCtx->
3733 tdlsConnInfo[staIdx].
3734 staId,
3735 MAC_ADDR_ARRAY
3736 (pRoamInfo->peerMac.bytes));
3737
Anurag Chouhanc5548422016-02-24 18:33:27 +05303738 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003739 tdlsConnInfo
3740 [staIdx].
3741 peerMac,
3742 &pRoamInfo->
3743 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303744 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003745 break;
3746 }
3747 }
3748 if (staIdx < pHddCtx->max_num_tdls_sta) {
3749 if (-1 ==
3750 wlan_hdd_tdls_set_sta_id(pAdapter,
3751 pRoamInfo->
3752 peerMac.bytes,
3753 pRoamInfo->
3754 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003755 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303756 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003757 }
3758
3759 (WLAN_HDD_GET_CTX(pAdapter))->
3760 sta_to_adapter[pRoamInfo->staId] =
3761 pAdapter;
3762 /*
3763 * store the ucast signature,
3764 * if required for further reference.
3765 */
3766
3767 wlan_hdd_tdls_set_signature(pAdapter,
3768 pRoamInfo->
3769 peerMac.bytes,
3770 pRoamInfo->
3771 ucastSig);
3772 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303773 status = QDF_STATUS_E_FAILURE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003774 hdd_err("no available slot in conn_info. staId %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 pRoamInfo->staId);
3776 }
3777 pAdapter->tdlsAddStaStatus = status;
3778 }
3779 complete(&pAdapter->tdls_add_station_comp);
3780 break;
3781 }
3782 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3783 {
3784 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003785 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003786 pRoamInfo->statusCode);
3787 }
3788 /* store the ucast signature which will be used later when
3789 * registering to TL
3790 */
3791 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3792 complete(&pAdapter->tdls_add_station_comp);
3793 break;
3794 }
3795 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3796 {
3797 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003798 hdd_err("Link Establish Request failed. status(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003799 pRoamInfo->statusCode);
3800 }
3801 complete(&pAdapter->tdls_link_establish_req_comp);
3802 break;
3803 }
3804 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3805 {
3806 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3807 staIdx++) {
3808 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3809 pRoamInfo->sessionId)
3810 && pRoamInfo->staId ==
3811 pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003812 hdd_warn("HDD: del STA IDX = %x",
3813 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303814 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003815 curr_peer =
3816 wlan_hdd_tdls_find_peer(pAdapter,
3817 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05303818 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303819 if (NULL != curr_peer) {
3820 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3821 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3822 curr_peer->link_status);
3823 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303824 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003825 hdd_roam_deregister_tdlssta
3826 (pAdapter,
3827 pRoamInfo->staId);
3828 wlan_hdd_tdls_decrement_peer_count
3829 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303830 } else if (eTDLS_LINK_CONNECTING ==
3831 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303832 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303833 hdd_roam_deregister_tdlssta
3834 (pAdapter,
3835 pRoamInfo->staId);
3836 }
Nitesh Shah3dea6722017-02-01 14:35:57 +05303837 } else
3838 mutex_unlock(&pHddCtx->tdls_lock);
3839
Nitesh Shah99dd9552017-03-20 19:27:47 +05303840 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003841 wlan_hdd_tdls_reset_peer(pAdapter,
3842 pRoamInfo->
3843 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05303844 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003845
3846 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3847 pHddCtx->tdlsConnInfo[staIdx].
3848 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303849 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 tdlsConnInfo[staIdx].
3851 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303852 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303853 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003854 break;
3855 }
3856 }
3857 complete(&pAdapter->tdls_del_station_comp);
3858 }
3859 break;
3860 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3861 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003862 hdd_err("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003863 pRoamInfo->reasonCode);
3864
Nitesh Shahf1f38992017-01-31 16:40:16 +05303865 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003866 curr_peer =
3867 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303868 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003869 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05303870 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303871 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3872 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303873 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303874 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003875 break;
3876 }
3877 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3878 {
3879 /* 0 staIdx is assigned to AP we dont want to touch that */
3880 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3881 staIdx++) {
3882 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3883 pRoamInfo->sessionId)
3884 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003885 hdd_warn("hdd_tdlsStatusUpdate: staIdx %d "
3886 MAC_ADDRESS_STR,
3887 pHddCtx->tdlsConnInfo[staIdx].
3888 staId,
3889 MAC_ADDR_ARRAY(pHddCtx->
3890 tdlsConnInfo
3891 [staIdx].
3892 peerMac.
3893 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05303894 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 wlan_hdd_tdls_reset_peer(pAdapter,
3896 pHddCtx->
3897 tdlsConnInfo
3898 [staIdx].
3899 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05303900 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 hdd_roam_deregister_tdlssta(pAdapter,
3902 pHddCtx->
3903 tdlsConnInfo
3904 [staIdx].
3905 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303906 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 sizeof
3908 (smeTdlsPeerStateParams));
3909 smeTdlsPeerStateParams.vdevId =
3910 pHddCtx->tdlsConnInfo[staIdx].
3911 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303912 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003913 peerMacAddr,
3914 &pHddCtx->
3915 tdlsConnInfo[staIdx].
3916 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303917 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003918 smeTdlsPeerStateParams.peerState =
3919 eSME_TDLS_PEER_STATE_TEARDOWN;
3920
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003921 hdd_info("calling sme_update_tdls_peer_state for staIdx %d "
3922 MAC_ADDRESS_STR,
3923 pHddCtx->tdlsConnInfo[staIdx].
3924 staId,
3925 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 tdlsConnInfo
3927 [staIdx].
3928 peerMac.
3929 bytes));
3930 status =
3931 sme_update_tdls_peer_state(
3932 pHddCtx->hHal,
3933 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303934 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003935 hdd_err("sme_update_tdls_peer_state failed for "
3936 MAC_ADDRESS_STR,
3937 MAC_ADDR_ARRAY
3938 (pHddCtx->
3939 tdlsConnInfo[staIdx].
3940 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003941 }
3942 wlan_hdd_tdls_decrement_peer_count
3943 (pAdapter);
3944
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303945 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946 tdlsConnInfo[staIdx].
3947 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303948 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003949 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3950 pHddCtx->tdlsConnInfo[staIdx].
3951 sessionId = 255;
3952
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303953 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003954 }
3955 }
3956 break;
3957 }
3958 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3959 {
3960 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07003961 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
3962 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303963 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003964 break;
3965 }
3966
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07003967 if (pHddCtx->tdls_nss_switch_in_progress) {
3968 hdd_err("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
3969 status = QDF_STATUS_SUCCESS;
3970 break;
3971 }
3972
Nitesh Shah8e866642017-01-31 15:43:31 +05303973 mutex_lock(&pHddCtx->tdls_lock);
3974 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3975 if (!pHddTdlsCtx) {
3976 mutex_unlock(&pHddCtx->tdls_lock);
3977 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
3978 roamResult);
3979 status = QDF_STATUS_E_FAILURE;
3980 break;
3981 }
3982
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003983 curr_peer =
3984 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05303985 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303987 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303988 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 } else {
3990 if (eTDLS_LINK_CONNECTED ==
3991 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003992 hdd_err("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003993 } else {
3994 /*
3995 * If external control is enabled then initiate
3996 * TDLS only if forced peer is set otherwise
3997 * ignore should Discover trigger from fw.
3998 */
3999 if (pHddCtx->config->
4000 fTDLSExternalControl
4001 && (false ==
4002 curr_peer->isForcedPeer)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004003 hdd_info("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304004 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004005 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 }
Jeff Johnson68755312017-02-10 11:46:55 -08004007 hdd_info("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
4008 pHddCtx->config->
4009 fTDLSExternalControl,
4010 curr_peer->isForcedPeer,
4011 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304012 pHddTdlsCtx->curr_candidate = curr_peer;
4013 wlan_hdd_tdls_implicit_send_discovery_request(
4014 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004015 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304016 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304018 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004019 break;
4020 }
4021
4022 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4023 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304024 mutex_lock(&pHddCtx->tdls_lock);
4025 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4026 if (!pHddTdlsCtx) {
4027 mutex_unlock(&pHddCtx->tdls_lock);
4028 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
4029 roamResult);
4030 status = QDF_STATUS_E_FAILURE;
4031 break;
4032 }
4033
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 curr_peer =
4035 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304036 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304038 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304039 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004040 } else {
4041 if (eTDLS_LINK_CONNECTED ==
4042 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004043 hdd_err("Received SHOULD_TEARDOWN for peer "
4044 MAC_ADDRESS_STR
4045 " staId: %d, reason: %d",
4046 MAC_ADDR_ARRAY(pRoamInfo->
4047 peerMac.bytes),
4048 pRoamInfo->staId,
4049 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004050
4051 if (pRoamInfo->reasonCode ==
4052 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4053 pRoamInfo->reasonCode ==
4054 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4055 pRoamInfo->reasonCode ==
4056 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4057 pRoamInfo->reasonCode ==
4058 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4059 reason =
4060 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4061 } else
4062 reason =
4063 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4064
4065 wlan_hdd_tdls_indicate_teardown
4066 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304067 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304068 hdd_send_wlan_tdls_teardown_event(
4069 eTDLS_TEARDOWN_BSS_DISCONNECT,
4070 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004072 hdd_err("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
4073 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004074 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304075 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004076 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304077 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004078 break;
4079 }
4080
4081 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4082 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304083 mutex_lock(&pHddCtx->tdls_lock);
4084 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4085 if (!pHddTdlsCtx) {
4086 mutex_unlock(&pHddCtx->tdls_lock);
4087 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
4088 roamResult);
4089 status = QDF_STATUS_E_FAILURE;
4090 break;
4091 }
4092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 curr_peer =
4094 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304095 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304097 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304098 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004099 } else {
4100 if (eTDLS_LINK_CONNECTED ==
4101 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004102 hdd_err("Received SHOULD_PEER_DISCONNECTED for peer "
4103 MAC_ADDRESS_STR
4104 " staId: %d, reason: %d",
4105 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4106 pRoamInfo->staId,
4107 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004108
4109 if (pRoamInfo->reasonCode ==
4110 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4111 pRoamInfo->reasonCode ==
4112 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4113 pRoamInfo->reasonCode ==
4114 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4115 pRoamInfo->reasonCode ==
4116 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4117 reason =
4118 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4119 } else
4120 reason =
4121 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4122
4123 wlan_hdd_tdls_indicate_teardown
4124 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304125 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304126 hdd_send_wlan_tdls_teardown_event(
4127 eTDLS_TEARDOWN_BSS_DISCONNECT,
4128 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004130 hdd_err("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
4131 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004132 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304133 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304135 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 break;
4137 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004138
4139 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304140 mutex_lock(&pHddCtx->tdls_lock);
4141 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4142 if (!pHddTdlsCtx) {
4143 mutex_unlock(&pHddCtx->tdls_lock);
4144 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
4145 roamResult);
4146 status = QDF_STATUS_E_FAILURE;
4147 break;
4148 }
4149
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004150 status = hdd_tdls_connection_tracker_update(pAdapter,
4151 pRoamInfo,
4152 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304153 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004154 break;
4155
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004156 default:
4157 {
4158 break;
4159 }
4160 }
4161
4162 return status;
4163}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004164#else
4165
Nitesh Shah99dd9552017-03-20 19:27:47 +05304166inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004167 uint8_t staId)
4168{
4169 return QDF_STATUS_SUCCESS;
4170}
4171
4172static inline QDF_STATUS
4173hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4174 tCsrRoamInfo *pRoamInfo,
4175 uint32_t roamId,
4176 eRoamCmdStatus roamStatus,
4177 eCsrRoamResult roamResult)
4178{
4179 return QDF_STATUS_SUCCESS;
4180}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004181#endif
4182
4183#ifdef WLAN_FEATURE_11W
4184/**
4185 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4186 * @pAdapter: pointer to the adapter
4187 * @nFrameLength: Length of the unprotected frame being passed
4188 * @pbFrames: Pointer to the frame buffer
4189 * @frameType: 802.11 frame type
4190 *
4191 * This function forwards the unprotected management frame to the supplicant.
4192 *
4193 * Return: nothing
4194 */
4195static void
4196hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4197 uint8_t *pbFrames, uint8_t frameType)
4198{
4199 uint8_t type = 0;
4200 uint8_t subType = 0;
4201
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004202 hdd_info("Frame Type = %d Frame Length = %d",
4203 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004204
4205 /* Sanity Checks */
4206 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004207 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004208 return;
4209 }
4210
4211 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004212 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004213 return;
4214 }
4215
4216 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004217 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004218 return;
4219 }
4220
4221 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004222 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004223 return;
4224 }
4225
4226 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004227 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228 return;
4229 }
4230
4231 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4232 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4233
4234 /* Get pAdapter from Destination mac address of the frame */
4235 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4236#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4237 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4238 nFrameLength);
4239#else
4240 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4241 nFrameLength);
4242#endif
4243 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4244 } else if (type == SIR_MAC_MGMT_FRAME &&
4245 subType == SIR_MAC_MGMT_DEAUTH) {
4246#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4247 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4248 nFrameLength);
4249#else
4250 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4251 nFrameLength);
4252#endif
4253 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4254 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004255 hdd_err("Frame type %d and subtype %d are not valid",
4256 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004257 return;
4258 }
4259}
4260#endif
4261
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004262#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263/**
4264 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4265 * @pAdapter: pointer to adapter
4266 * @tid: traffic identifier
4267 * @state: state
4268 * @measInterval: measurement interval
4269 *
4270 * This function sends traffic stream metrics IE information to
4271 * the supplicant via wireless event.
4272 *
4273 * Return: none
4274 */
4275static void
4276hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4277 uint8_t state, uint16_t measInterval)
4278{
4279 union iwreq_data wrqu;
4280 char buf[IW_CUSTOM_MAX + 1];
4281 int nBytes = 0;
4282
4283 if (NULL == pAdapter)
4284 return;
4285
4286 /* create the event */
4287 memset(&wrqu, '\0', sizeof(wrqu));
4288 memset(buf, '\0', sizeof(buf));
4289
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004290 hdd_info("TSM Ind tid(%d) state(%d) MeasInt(%d)",
4291 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004292
4293 nBytes =
4294 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4295 measInterval);
4296
4297 wrqu.data.pointer = buf;
4298 wrqu.data.length = nBytes;
4299 /* send the event */
4300 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4301}
4302
4303/**
4304 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4305 * @pAdapter: pointer to adapter
4306 * @pRoamInfo: pointer to roam info
4307 *
4308 * This function sends cckm preauth indication to the supplicant
4309 * via wireless custom event.
4310 *
4311 * Return: none
4312 */
4313static void
4314hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4315{
4316 union iwreq_data wrqu;
4317 char buf[IW_CUSTOM_MAX + 1];
4318 char *pos = buf;
4319 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4320
4321 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4322 return;
4323
4324 /* create the event */
4325 memset(&wrqu, '\0', sizeof(wrqu));
4326 memset(buf, '\0', sizeof(buf));
4327
4328 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004329 hdd_info("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
4330 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4331 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004332
4333 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4334 pos += nBytes;
4335 freeBytes -= nBytes;
4336
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304337 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304338 pos += QDF_MAC_ADDR_SIZE;
4339 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340
4341 nBytes = snprintf(pos, freeBytes, " %u:%u",
4342 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4343 freeBytes -= nBytes;
4344
4345 wrqu.data.pointer = buf;
4346 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4347
4348 /* send the event */
4349 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4350}
4351
4352/**
4353 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4354 * @pAdapter: pointer to adapter
4355 * @pRoamInfo: pointer to roam info
4356 *
4357 * Return: none
4358 */
4359static void
4360hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4361 tCsrRoamInfo *pRoamInfo)
4362{
4363 union iwreq_data wrqu;
4364 char buf[IW_CUSTOM_MAX + 1];
4365 int nBytes = 0;
4366
4367 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4368 return;
4369
4370 /* create the event */
4371 memset(&wrqu, '\0', sizeof(wrqu));
4372 memset(buf, '\0', sizeof(buf));
4373
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004374 hdd_info("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004375
4376 nBytes =
4377 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4378 pRoamInfo->tsmRoamDelay);
4379
4380 wrqu.data.pointer = buf;
4381 wrqu.data.length = nBytes;
4382
4383 /* send the event */
4384 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4385}
4386
4387/**
4388 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4389 * @pAdapter: pointer to adapter
4390 * @measurementToken: measurement token
4391 * @flag: flag
4392 * @numBss: number of bss
4393 *
4394 * If the measurement is none and no scan results found,
4395 * indicate the supplicant about measurement done.
4396 *
4397 * Return: none
4398 */
4399void
4400hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4401 const uint16_t measurementToken,
4402 const bool flag, const uint8_t numBss)
4403{
4404 union iwreq_data wrqu;
4405 char buf[IW_CUSTOM_MAX];
4406 char *pos = buf;
4407 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4408
4409 memset(&wrqu, '\0', sizeof(wrqu));
4410 memset(buf, '\0', sizeof(buf));
4411
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004412 hdd_info("CCXBCNREP=%d %d %d", measurementToken,
4413 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004414
4415 nBytes =
4416 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4417 flag, numBss);
4418
4419 wrqu.data.pointer = buf;
4420 wrqu.data.length = nBytes;
4421 /* send the event */
4422 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4423}
4424
4425/**
4426 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4427 * @pAdapter: pointer to adapter
4428 * @pRoamInfo: pointer to roam info
4429 *
4430 * If the measurement is none and no scan results found,
4431 * indicate the supplicant about measurement done.
4432 *
4433 * Return: none
4434 */
4435static void
4436hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4437 const tCsrRoamInfo *pRoamInfo)
4438{
4439 union iwreq_data wrqu;
4440 char buf[IW_CUSTOM_MAX];
4441 char *pos = buf;
4442 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4443 uint8_t i = 0, len = 0;
4444 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4445 uint8_t lastSent = 0, sendBss = 0;
4446 int bcnRepFieldSize =
4447 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4448 bcnReportFields);
4449 uint8_t ieLenByte = 1;
4450 /*
4451 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4452 */
4453#define ESEBCNREPHEADER_LEN (18)
4454
4455 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4456 return;
4457
4458 /*
4459 * Custom event can pass maximum of 256 bytes of data,
4460 * based on the IE len we need to identify how many BSS info can
4461 * be filled in to custom event data.
4462 */
4463 /*
4464 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4465 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4466 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4467 */
4468
4469 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4470 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004471 hdd_info("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004473 * indicate the supplicant about measurement done
4474 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004475 hdd_indicate_ese_bcn_report_no_results(
4476 pAdapter,
4477 pRoamInfo->pEseBcnReportRsp->
4478 measurementToken,
4479 pRoamInfo->pEseBcnReportRsp->flag,
4480 pRoamInfo->pEseBcnReportRsp->numBss);
4481 } else {
4482 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4483 memset(&wrqu, '\0', sizeof(wrqu));
4484 memset(buf, '\0', sizeof(buf));
4485 tot_bcn_ieLen = 0;
4486 sendBss = 0;
4487 pos = buf;
4488 freeBytes = IW_CUSTOM_MAX;
4489
4490 for (i = lastSent;
4491 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4492 len =
4493 bcnRepFieldSize + ieLenByte +
4494 pRoamInfo->pEseBcnReportRsp->
4495 bcnRepBssInfo[i].ieLen;
4496 if ((len + tot_bcn_ieLen) >
4497 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4498 break;
4499 }
4500 tot_bcn_ieLen += len;
4501 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004502 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4503 i, bcnRepFieldSize, 1,
4504 pRoamInfo->pEseBcnReportRsp->
4505 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004506 }
4507
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004508 hdd_info("Sending %d BSS Info", sendBss);
4509 hdd_info("CCXBCNREP=%d %d %d %d",
4510 pRoamInfo->pEseBcnReportRsp->measurementToken,
4511 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4512 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004513
4514 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4515 pRoamInfo->pEseBcnReportRsp->
4516 measurementToken,
4517 pRoamInfo->pEseBcnReportRsp->flag,
4518 sendBss);
4519 pos += nBytes;
4520 freeBytes -= nBytes;
4521
4522 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304523 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004524 sizeof(tot_bcn_ieLen));
4525 pos += sizeof(tot_bcn_ieLen);
4526 freeBytes -= sizeof(tot_bcn_ieLen);
4527
4528 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004529 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4531 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4532 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4533 pRoamInfo->pEseBcnReportRsp->
4534 bcnRepBssInfo[i +
4535 lastSent].bcnReportFields.
4536 ChanNum,
4537 pRoamInfo->pEseBcnReportRsp->
4538 bcnRepBssInfo[i +
4539 lastSent].bcnReportFields.
4540 Spare,
4541 pRoamInfo->pEseBcnReportRsp->
4542 bcnRepBssInfo[i +
4543 lastSent].bcnReportFields.
4544 MeasDuration,
4545 pRoamInfo->pEseBcnReportRsp->
4546 bcnRepBssInfo[i +
4547 lastSent].bcnReportFields.
4548 PhyType,
4549 pRoamInfo->pEseBcnReportRsp->
4550 bcnRepBssInfo[i +
4551 lastSent].bcnReportFields.
4552 RecvSigPower,
4553 pRoamInfo->pEseBcnReportRsp->
4554 bcnRepBssInfo[i +
4555 lastSent].bcnReportFields.
4556 ParentTsf,
4557 pRoamInfo->pEseBcnReportRsp->
4558 bcnRepBssInfo[i +
4559 lastSent].bcnReportFields.
4560 TargetTsf[0],
4561 pRoamInfo->pEseBcnReportRsp->
4562 bcnRepBssInfo[i +
4563 lastSent].bcnReportFields.
4564 TargetTsf[1],
4565 pRoamInfo->pEseBcnReportRsp->
4566 bcnRepBssInfo[i +
4567 lastSent].bcnReportFields.
4568 BcnInterval,
4569 pRoamInfo->pEseBcnReportRsp->
4570 bcnRepBssInfo[i +
4571 lastSent].bcnReportFields.
4572 CapabilityInfo,
4573 pRoamInfo->pEseBcnReportRsp->
4574 bcnRepBssInfo[i +
4575 lastSent].bcnReportFields.
4576 Bssid[0],
4577 pRoamInfo->pEseBcnReportRsp->
4578 bcnRepBssInfo[i +
4579 lastSent].bcnReportFields.
4580 Bssid[1],
4581 pRoamInfo->pEseBcnReportRsp->
4582 bcnRepBssInfo[i +
4583 lastSent].bcnReportFields.
4584 Bssid[2],
4585 pRoamInfo->pEseBcnReportRsp->
4586 bcnRepBssInfo[i +
4587 lastSent].bcnReportFields.
4588 Bssid[3],
4589 pRoamInfo->pEseBcnReportRsp->
4590 bcnRepBssInfo[i +
4591 lastSent].bcnReportFields.
4592 Bssid[4],
4593 pRoamInfo->pEseBcnReportRsp->
4594 bcnRepBssInfo[i +
4595 lastSent].bcnReportFields.
4596 Bssid[5]);
4597
4598 /* bcn report fields are copied */
4599 len =
4600 sizeof(pRoamInfo->pEseBcnReportRsp->
4601 bcnRepBssInfo[i +
4602 lastSent].
4603 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304604 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 (char *)&pRoamInfo->
4606 pEseBcnReportRsp->bcnRepBssInfo[i +
4607 lastSent].
4608 bcnReportFields, len);
4609 pos += len;
4610 freeBytes -= len;
4611
4612 /* Add 1 byte of ie len */
4613 len =
4614 pRoamInfo->pEseBcnReportRsp->
4615 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304616 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617 pos += sizeof(len);
4618 freeBytes -= sizeof(len);
4619
4620 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304621 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004622 (char *)pRoamInfo->
4623 pEseBcnReportRsp->bcnRepBssInfo[i +
4624 lastSent].
4625 pBuf, len);
4626 pos += len;
4627 freeBytes -= len;
4628 }
4629
4630 wrqu.data.pointer = buf;
4631 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4632
4633 /* send the event */
4634 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4635 buf);
4636 lastSent += sendBss;
4637 }
4638 }
4639}
4640
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004641#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004642
4643/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304644 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4645 * @pHddStaCtx: Station Context
4646 *
4647 * API to check if the connection authentication type is 8021x_sha256.
4648 *
4649 * Return: bool
4650 */
4651#ifdef WLAN_FEATURE_11W
4652static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4653{
4654 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4655 pHddStaCtx->conn_info.authType;
4656}
4657#else
4658static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4659{
4660 return false;
4661}
4662#endif
4663
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304664/*
4665 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4666 * @adapter: Pointer to adapter context
4667 * @roam_info: Pointer to roam info
4668 *
4669 * Return: None
4670 */
4671static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4672 tCsrRoamInfo *roam_info)
4673{
4674 struct hdd_chan_change_params chan_change;
4675 struct cfg80211_bss *bss;
4676 struct net_device *dev = adapter->dev;
4677 struct wireless_dev *wdev = dev->ieee80211_ptr;
4678 struct wiphy *wiphy = wdev->wiphy;
4679 QDF_STATUS status;
4680
4681 hdd_info("channel switch for session:%d to channel:%d",
4682 adapter->sessionId, roam_info->chan_info.chan_id);
4683
4684 chan_change.chan = roam_info->chan_info.chan_id;
4685 chan_change.chan_params.ch_width =
4686 roam_info->chan_info.ch_width;
4687 chan_change.chan_params.sec_ch_offset =
4688 roam_info->chan_info.sec_ch_offset;
4689 chan_change.chan_params.center_freq_seg0 =
4690 roam_info->chan_info.band_center_freq1;
4691 chan_change.chan_params.center_freq_seg1 =
4692 roam_info->chan_info.band_center_freq2;
4693
4694 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4695 if (NULL == bss)
4696 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4697 else
4698 cfg80211_put_bss(wiphy, bss);
4699
4700 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4701 if (QDF_IS_STATUS_ERROR(status))
4702 hdd_err("channel change notification failed");
4703
4704 status = cds_set_hw_mode_on_channel_switch(adapter->sessionId);
4705 if (QDF_IS_STATUS_ERROR(status))
4706 hdd_info("set hw mode change not done");
4707}
4708
Komal Seelam98760ba2015-12-15 11:05:18 +05304709/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 * hdd_sme_roam_callback() - hdd sme roam callback
4711 * @pContext: pointer to adapter context
4712 * @pRoamInfo: pointer to roam info
4713 * @roamId: roam id
4714 * @roamStatus: roam status
4715 * @roamResult: roam result
4716 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304717 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304719QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004720hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4721 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4722{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304723 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004724 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4725 hdd_wext_state_t *pWextState = NULL;
4726 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304727 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304728 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004729
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004730 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4731 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004732
4733 /* Sanity check */
4734 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004735 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304736 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004737 }
4738
4739 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4740 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4741
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304742 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4743 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4744 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4745 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304746
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004747 switch (roamStatus) {
4748 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304749 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4750 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004751 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 break;
4753
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 /*
4755 * We did pre-auth,then we attempted a 11r or ese reassoc.
4756 * reassoc failed due to failure, timeout, reject from ap
4757 * in any case tell the OS, our carrier is off and mark
4758 * interface down.
4759 */
4760 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004761 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4762 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304763 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004764 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4765 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 pHddStaCtx->ft_carrier_on = false;
4767 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004768 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4769 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 break;
4771
4772 case eCSR_ROAM_FT_START:
4773 /*
4774 * When we roam for ESE and 11r, we dont want the OS to be
4775 * informed that the link is down. So mark the link ready for
4776 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4777 * be received. Where in we will not mark the link down
4778 * Also we want to stop tx at this point when we will be
4779 * doing disassoc at this time. This saves 30-60 msec
4780 * after reassoc.
4781 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004782 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004783 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4784 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004785 wlan_hdd_netif_queue_control(pAdapter,
4786 WLAN_NETIF_TX_DISABLE,
4787 WLAN_CONTROL_PATH);
4788 status = hdd_roam_deregister_sta(pAdapter,
4789 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304790 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304791 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004792 pHddStaCtx->ft_carrier_on = true;
4793 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004794 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4795 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004796 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004797 case eCSR_ROAM_NAPI_OFF:
4798 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4799 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004800 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturua5784142017-03-10 12:11:44 -08004801 if (pAdapter->defer_disconnect)
4802 hdd_process_defer_disconnect(pAdapter);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004803 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004804 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004805 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004806 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 wlan_hdd_netif_queue_control(pAdapter,
4808 WLAN_NETIF_TX_DISABLE,
4809 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004810 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 wlan_hdd_netif_queue_control(pAdapter,
4812 WLAN_NETIF_CARRIER_OFF,
4813 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004814 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004815 break;
4816 case eCSR_ROAM_LOSTLINK:
4817 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004818 hdd_info("Roaming started due to connection lost");
4819 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004820 wlan_hdd_netif_queue_control(pAdapter,
4821 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4822 WLAN_CONTROL_PATH);
4823 break;
4824 }
4825 case eCSR_ROAM_DISASSOCIATED:
4826 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004827 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05304828 hdd_napi_serialize(0);
4829 cds_set_connection_in_progress(false);
4830 hdd_set_roaming_in_progress(false);
4831 pAdapter->defer_disconnect = 0;
4832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004833 /* Call to clear any MC Addr List filter applied after
4834 * successful connection.
4835 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05304836 hdd_disable_and_flush_mc_addr_list(pAdapter,
4837 pmo_peer_disconnect);
4838 qdf_ret_status =
4839 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4840 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841 }
4842 break;
4843 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004844 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304845 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4847 roamStatus, roamResult);
4848 break;
4849 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004850 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 /*
4852 * To Do - address probable memory leak with WEP encryption upon
4853 * successful association.
4854 */
4855 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4856 /* Clear saved connection information in HDD */
4857 hdd_conn_remove_connect_info(
4858 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4859 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304860 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004861 hdd_association_completion_handler(pAdapter, pRoamInfo,
4862 roamId, roamStatus,
4863 roamResult);
4864#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4865 if (pRoamInfo)
4866 pRoamInfo->roamSynchInProgress = false;
4867#endif
4868 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004869 case eCSR_ROAM_CANCELLED:
4870 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304872 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004873 pRoamInfo,
4874 roamId,
4875 roamStatus,
4876 roamResult);
4877 break;
4878 case eCSR_ROAM_IBSS_IND:
4879 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4880 roamStatus, roamResult);
4881 break;
4882
4883 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304884 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 roam_roam_connect_status_update_handler(pAdapter,
4886 pRoamInfo,
4887 roamId,
4888 roamStatus,
4889 roamResult);
4890 break;
4891
4892 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304893 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894 hdd_roam_mic_error_indication_handler(pAdapter,
4895 pRoamInfo,
4896 roamId,
4897 roamStatus,
4898 roamResult);
4899 break;
4900
4901 case eCSR_ROAM_SET_KEY_COMPLETE:
4902 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304903 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004904 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4905 roamId, roamStatus,
4906 roamResult);
4907 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4908 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004909 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004910 pHddStaCtx->hdd_ReassocScenario,
4911 pAdapter->sessionId);
4912 }
4913 }
4914#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4915 if (pRoamInfo != NULL)
4916 pRoamInfo->roamSynchInProgress = false;
4917#endif
4918 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004919
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004920 case eCSR_ROAM_FT_RESPONSE:
4921 hdd_send_ft_event(pAdapter);
4922 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004923
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004924 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304925 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4926 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004927 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304928 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 wlan_hdd_cfg80211_pmksa_candidate_notify(
4930 pAdapter, pRoamInfo, 1, false);
4931 }
4932 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004933
4934#ifdef FEATURE_WLAN_LFR_METRICS
4935 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4936 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304937 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4939 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304940 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 }
4942 break;
4943 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4944 /*
4945 * This event will notify pre-auth completion in case of success
4946 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304947 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004948 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4949 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304950 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 }
4952 break;
4953 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4954 /*
4955 * This event will notify pre-auth completion incase of failure.
4956 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304957 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004958 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4959 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304960 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004961 }
4962 break;
4963 case eCSR_ROAM_HANDOVER_SUCCESS:
4964 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004965 * It will be only invoked on success
4966 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304967 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004968 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4969 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304970 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004971 }
4972 break;
4973#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004974 case eCSR_ROAM_REMAIN_CHAN_READY:
4975 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4976 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977#ifdef FEATURE_WLAN_TDLS
4978 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304979 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004980 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4981 roamId,
4982 roamStatus,
4983 roamResult);
4984 break;
4985 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4986 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4987 pRoamInfo->reasonCode);
4988 break;
4989#endif
4990#ifdef WLAN_FEATURE_11W
4991 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4992 hdd_indicate_unprot_mgmt_frame(pAdapter,
4993 pRoamInfo->nFrameLength,
4994 pRoamInfo->pbFrames,
4995 pRoamInfo->frameType);
4996 break;
4997#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004998#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999 case eCSR_ROAM_TSM_IE_IND:
5000 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5001 pRoamInfo->tsmIe.state,
5002 pRoamInfo->tsmIe.msmt_interval);
5003 break;
5004
5005 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5006 {
5007 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5008 pHddStaCtx->conn_info.authType
5009 || eCSR_AUTH_TYPE_CCKM_RSN ==
5010 pHddStaCtx->conn_info.authType) {
5011 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5012 }
5013 break;
5014 }
5015
5016 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5017 {
5018 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5019 break;
5020 }
5021
5022 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5023 {
5024 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5025 break;
5026 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005027#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305028 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305029 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305030 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305031
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305032 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5033 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5034 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5035 pAdapter, pRoamInfo->pBssDesc);
5036 if (NULL == bss_status)
5037 hdd_info("UPDATE_SCAN_RESULT returned NULL");
5038 else
5039 cfg80211_put_bss(
5040#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5041 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5042#endif
5043 bss_status);
5044 }
5045 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005046 case eCSR_ROAM_NDP_STATUS_UPDATE:
5047 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5048 roamResult);
5049 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005050 case eCSR_ROAM_START:
5051 hdd_info("Process ROAM_START from firmware");
5052 wlan_hdd_netif_queue_control(pAdapter,
5053 WLAN_NETIF_TX_DISABLE,
5054 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005055 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005056 cds_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005057 hdd_set_roaming_in_progress(true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005058 cds_restart_opportunistic_timer(true);
5059 break;
5060 case eCSR_ROAM_ABORT:
5061 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005062 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005063 wlan_hdd_netif_queue_control(pAdapter,
5064 WLAN_WAKE_ALL_NETIF_QUEUE,
5065 WLAN_CONTROL_PATH);
5066 cds_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005067 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturua5784142017-03-10 12:11:44 -08005068 /*
5069 * If disconnect operation is in deferred state, do it now.
5070 */
5071 if (pAdapter->defer_disconnect)
5072 hdd_process_defer_disconnect(pAdapter);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005073 break;
5074
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 default:
5076 break;
5077 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305078 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005079}
5080
5081/**
5082 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5083 * @auth_suite: auth suite
5084 *
5085 * Return: eCsrAuthType enumeration
5086 */
5087eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5088{
5089 eCsrAuthType auth_type;
5090 /* is the auth type supported? */
5091 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5092 auth_type = eCSR_AUTH_TYPE_RSN;
5093 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5094 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005095 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005096 /* Check for 11r FT Authentication with PSK */
5097 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5098 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5099 /* Check for 11R FT Authentication with 802.1X */
5100 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5101 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005102#ifdef FEATURE_WLAN_ESE
5103 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5104 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5105 } else
5106#endif /* FEATURE_WLAN_ESE */
5107#ifdef WLAN_FEATURE_11W
5108 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5109 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5110 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5111 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5112 } else
5113#endif
5114 {
5115 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5116 }
5117 return auth_type;
5118}
5119
5120/**
5121 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5122 * @auth_suite: auth suite
5123 *
5124 * Return: eCsrAuthType enumeration
5125 */
5126eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5127{
5128 eCsrAuthType auth_type;
5129 /* is the auth type supported? */
5130 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5131 auth_type = eCSR_AUTH_TYPE_WPA;
5132 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5133 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5134 } else
5135#ifdef FEATURE_WLAN_ESE
5136 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5137 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5138 } else
5139#endif /* FEATURE_WLAN_ESE */
5140 {
5141 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5142 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005143 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144 return auth_type;
5145}
5146
5147/**
5148 * hdd_translate_rsn_to_csr_encryption_type() -
5149 * Translate RSN to CSR encryption type
5150 * @cipher_suite: cipher suite
5151 *
5152 * Return: eCsrEncryptionType enumeration
5153 */
5154eCsrEncryptionType
5155hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5156{
5157 eCsrEncryptionType cipher_type;
5158
5159 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5160 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5161 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5162 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5163 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5164 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5165 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5166 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5167 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5168 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5169 else
5170 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5171
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005172 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005173 return cipher_type;
5174}
5175
5176/**
5177 * hdd_translate_wpa_to_csr_encryption_type() -
5178 * Translate WPA to CSR encryption type
5179 * @cipher_suite: cipher suite
5180 *
5181 * Return: eCsrEncryptionType enumeration
5182 */
5183eCsrEncryptionType
5184hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5185{
5186 eCsrEncryptionType cipher_type;
5187
5188 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5189 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5190 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5191 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5192 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5193 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5194 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5195 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5196 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5197 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5198 else
5199 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5200
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005201 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005202 return cipher_type;
5203}
5204
5205/**
5206 * hdd_process_genie() - process gen ie
5207 * @pAdapter: pointer to adapter
5208 * @bssid: pointer to mac address
5209 * @pEncryptType: pointer to encryption type
5210 * @mcEncryptType: pointer to multicast encryption type
5211 * @pAuthType: pointer to auth type
5212 *
5213 * Return: 0 on success, error number otherwise
5214 */
5215static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5216 u8 *bssid,
5217 eCsrEncryptionType *pEncryptType,
5218 eCsrEncryptionType *mcEncryptType,
5219 eCsrAuthType *pAuthType,
5220#ifdef WLAN_FEATURE_11W
5221 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5222#endif
5223 uint16_t gen_ie_len, uint8_t *gen_ie)
5224{
5225 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305226 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005227 tDot11fIERSN dot11RSNIE;
5228 tDot11fIEWPA dot11WPAIE;
5229 uint32_t i;
5230 uint8_t *pRsnIe;
5231 uint16_t RSNIeLen;
5232 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5233 bool updatePMKCache = false;
5234
5235 /*
5236 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5237 * setting present flag to 0.
5238 */
5239 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5240 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5241
5242 /* Type check */
5243 if (gen_ie[0] == DOT11F_EID_RSN) {
5244 /* Validity checks */
5245 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5246 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005247 hdd_err("Invalid DOT11F RSN IE length :%d",
5248 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 return -EINVAL;
5250 }
5251 /* Skip past the EID byte and length byte */
5252 pRsnIe = gen_ie + 2;
5253 RSNIeLen = gen_ie_len - 2;
5254 /* Unpack the RSN IE */
5255 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5256 pRsnIe, RSNIeLen, &dot11RSNIE);
5257 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005258 hdd_info("pairwise cipher suite count: %d",
5259 dot11RSNIE.pwise_cipher_suite_count);
5260 hdd_info("authentication suite count: %d",
5261 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005262 /* dot11RSNIE.akm_suite_count */
5263 /* Just translate the FIRST one */
5264 *pAuthType =
5265 hdd_translate_rsn_to_csr_auth_type(
5266 dot11RSNIE.akm_suites[0]);
5267 /* dot11RSNIE.pwise_cipher_suite_count */
5268 *pEncryptType =
5269 hdd_translate_rsn_to_csr_encryption_type(
5270 dot11RSNIE.pwise_cipher_suites[0]);
5271 /* dot11RSNIE.gp_cipher_suite_count */
5272 *mcEncryptType =
5273 hdd_translate_rsn_to_csr_encryption_type(
5274 dot11RSNIE.gp_cipher_suite);
5275#ifdef WLAN_FEATURE_11W
5276 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5277 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5278#endif
5279 /* Set the PMKSA ID Cache for this interface */
5280 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5281 if (is_zero_ether_addr(bssid)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005282 hdd_err("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005283 break;
5284 }
5285 updatePMKCache = true;
5286 /*
5287 * For right now, I assume setASSOCIATE() has passed
5288 * in the bssid.
5289 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305290 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305291 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305292 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005293 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5294 }
5295
5296 if (updatePMKCache) {
5297 /*
5298 * Calling csr_roam_set_pmkid_cache to configure the
5299 * PMKIDs into the cache.
5300 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005301 hdd_info("Calling sme_roam_set_pmkid_cache with cache entry %d.",
5302 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005303 /* Finally set the PMKSA ID Cache in CSR */
5304 result =
5305 sme_roam_set_pmkid_cache(halHandle,
5306 pAdapter->sessionId,
5307 PMKIDCache,
5308 dot11RSNIE.pmkid_count,
5309 false);
5310 }
5311 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5312 /* Validity checks */
5313 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5314 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005315 hdd_err("Invalid DOT11F WPA IE length :%d",
5316 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005317 return -EINVAL;
5318 }
5319 /* Skip past the EID and length byte - and four byte WiFi OUI */
5320 pRsnIe = gen_ie + 2 + 4;
5321 RSNIeLen = gen_ie_len - (2 + 4);
5322 /* Unpack the WPA IE */
5323 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
5324 pRsnIe, RSNIeLen, &dot11WPAIE);
5325 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005326 hdd_info("WPA unicast cipher suite count: %d",
5327 dot11WPAIE.unicast_cipher_count);
5328 hdd_info("WPA authentication suite count: %d",
5329 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330 /* dot11WPAIE.auth_suite_count */
5331 /* Just translate the FIRST one */
5332 *pAuthType =
5333 hdd_translate_wpa_to_csr_auth_type(
5334 dot11WPAIE.auth_suites[0]);
5335 /* dot11WPAIE.unicast_cipher_count */
5336 *pEncryptType =
5337 hdd_translate_wpa_to_csr_encryption_type(
5338 dot11WPAIE.unicast_ciphers[0]);
5339 /* dot11WPAIE.unicast_cipher_count */
5340 *mcEncryptType =
5341 hdd_translate_wpa_to_csr_encryption_type(
5342 dot11WPAIE.multicast_cipher);
5343 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005344 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005345 return -EINVAL;
5346 }
5347 return 0;
5348}
5349
5350/**
5351 * hdd_set_genie_to_csr() - set genie to csr
5352 * @pAdapter: pointer to adapter
5353 * @RSNAuthType: pointer to auth type
5354 *
5355 * Return: 0 on success, error number otherwise
5356 */
5357int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5358{
5359 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5360 uint32_t status = 0;
5361 eCsrEncryptionType RSNEncryptType;
5362 eCsrEncryptionType mcRSNEncryptType;
5363#ifdef WLAN_FEATURE_11W
5364 uint8_t RSNMfpRequired = 0;
5365 uint8_t RSNMfpCapable = 0;
5366#endif
5367 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5368 /* MAC address of assoc peer */
5369 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305370 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005371 pWextState->roamProfile.BSSIDs.bssid,
5372 sizeof(bssid));
5373 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5374 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5375 /* continue */
5376 } else {
5377 return 0;
5378 }
5379 /* The actual processing may eventually be more extensive than this. */
5380 /* Right now, just consume any PMKIDs that are sent in by the app. */
5381 status = hdd_process_genie(pAdapter, bssid,
5382 &RSNEncryptType,
5383 &mcRSNEncryptType, RSNAuthType,
5384#ifdef WLAN_FEATURE_11W
5385 &RSNMfpRequired, &RSNMfpCapable,
5386#endif
5387 pWextState->WPARSNIE[1] + 2,
5388 pWextState->WPARSNIE);
5389 if (status == 0) {
5390 /*
5391 * Now copy over all the security attributes
5392 * you have parsed out.
5393 */
5394 pWextState->roamProfile.EncryptionType.numEntries = 1;
5395 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5396
5397 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5398 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5399 mcRSNEncryptType;
5400
Krunal Sonibe766b02016-03-10 13:00:44 -08005401 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005402 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5403 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5404 /*
5405 * For wpa none supplicant sends the WPA IE with unicast
5406 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5407 * multicast cipher as either AES/TKIP based on group
5408 * cipher configuration mentioned in the
5409 * wpa_supplicant.conf.
5410 */
5411
5412 /* Set the unicast cipher same as multicast cipher */
5413 pWextState->roamProfile.EncryptionType.encryptionType[0]
5414 = mcRSNEncryptType;
5415 }
5416#ifdef WLAN_FEATURE_11W
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005417 hdd_info("RSNMfpRequired = %d, RSNMfpCapable = %d",
5418 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005419 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5420 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5421#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005422 hdd_info("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
5423 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005424 }
5425 return 0;
5426}
5427
5428/**
5429 * hdd_set_csr_auth_type() - set csr auth type
5430 * @pAdapter: pointer to adapter
5431 * @RSNAuthType: auth type
5432 *
5433 * Return: 0 on success, error number otherwise
5434 */
5435int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5436{
5437 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5438 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5439 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005440
5441 pRoamProfile->AuthType.numEntries = 1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005442 hdd_info("pHddStaCtx->conn_info.authType = %d",
5443 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005444
5445 switch (pHddStaCtx->conn_info.authType) {
5446 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5447#ifdef FEATURE_WLAN_ESE
5448 case eCSR_AUTH_TYPE_CCKM_WPA:
5449 case eCSR_AUTH_TYPE_CCKM_RSN:
5450#endif
5451 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5452
5453 pRoamProfile->AuthType.authType[0] =
5454 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5455 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5456
5457#ifdef FEATURE_WLAN_ESE
5458 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5459 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5460 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005461 hdd_info("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462 pRoamProfile->AuthType.authType[0] =
5463 eCSR_AUTH_TYPE_CCKM_WPA;
5464 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005465 hdd_info("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005466 pRoamProfile->AuthType.authType[0] =
5467 eCSR_AUTH_TYPE_CCKM_WPA;
5468 } else
5469#endif
5470 if ((pWextState->
5471 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5472 == IW_AUTH_KEY_MGMT_802_1X) {
5473 pRoamProfile->AuthType.authType[0] =
5474 eCSR_AUTH_TYPE_WPA;
5475 } else
5476 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5477 == IW_AUTH_KEY_MGMT_PSK) {
5478 pRoamProfile->AuthType.authType[0] =
5479 eCSR_AUTH_TYPE_WPA_PSK;
5480 } else {
5481 pRoamProfile->AuthType.authType[0] =
5482 eCSR_AUTH_TYPE_WPA_NONE;
5483 }
5484 }
5485 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5486#ifdef FEATURE_WLAN_ESE
5487 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5488 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5489 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005490 hdd_info("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005491 pRoamProfile->AuthType.authType[0] =
5492 eCSR_AUTH_TYPE_CCKM_RSN;
5493 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005494 hdd_info("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005495 pRoamProfile->AuthType.authType[0] =
5496 eCSR_AUTH_TYPE_CCKM_RSN;
5497 } else
5498#endif
5499
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005500 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5501 ((pWextState->
5502 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5503 == IW_AUTH_KEY_MGMT_802_1X)) {
5504 pRoamProfile->AuthType.authType[0] =
5505 eCSR_AUTH_TYPE_FT_RSN;
5506 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5507 &&
5508 ((pWextState->
5509 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5510 == IW_AUTH_KEY_MGMT_PSK)) {
5511 pRoamProfile->AuthType.authType[0] =
5512 eCSR_AUTH_TYPE_FT_RSN_PSK;
5513 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514
5515#ifdef WLAN_FEATURE_11W
5516 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5517 pRoamProfile->AuthType.authType[0] =
5518 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5519 } else if (RSNAuthType ==
5520 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5521 pRoamProfile->AuthType.authType[0] =
5522 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5523 } else
5524#endif
5525
5526 if ((pWextState->
5527 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5528 == IW_AUTH_KEY_MGMT_802_1X) {
5529 pRoamProfile->AuthType.authType[0] =
5530 eCSR_AUTH_TYPE_RSN;
5531 } else
5532 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5533 == IW_AUTH_KEY_MGMT_PSK) {
5534 pRoamProfile->AuthType.authType[0] =
5535 eCSR_AUTH_TYPE_RSN_PSK;
5536 } else {
5537 pRoamProfile->AuthType.authType[0] =
5538 eCSR_AUTH_TYPE_UNKNOWN;
5539 }
5540 }
5541 break;
5542
5543 case eCSR_AUTH_TYPE_SHARED_KEY:
5544
5545 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5546 break;
5547 default:
5548
5549#ifdef FEATURE_WLAN_ESE
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005550 hdd_info("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005551#endif /* FEATURE_WLAN_ESE */
5552 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5553 break;
5554 }
5555
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005556 hdd_info("Set roam Authtype to %d",
5557 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005559 return 0;
5560}
5561
5562/**
5563 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5564 * to the CSR roam profile.
5565 *
5566 * @dev: Pointer to the net device.
5567 * @info: Pointer to the iw_request_info.
5568 * @wrqu: Pointer to the iwreq_data.
5569 * @extra: Pointer to the data.
5570 *
5571 * Return: 0 for success, error number on failure
5572 */
5573static int __iw_set_essid(struct net_device *dev,
5574 struct iw_request_info *info,
5575 union iwreq_data *wrqu, char *extra)
5576{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005577 uint32_t status = 0;
5578 hdd_wext_state_t *pWextState;
5579 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5580 hdd_context_t *hdd_ctx;
5581 uint32_t roamId;
5582 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005583 eCsrAuthType RSNAuthType;
5584 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005585 int ret;
5586
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005587 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005588
5589 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5590 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305591 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 return ret;
5593
Jeff Johnson441e1f72017-02-07 08:50:49 -08005594 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5595 if (0 != ret)
5596 return ret;
5597
Krunal Sonibe766b02016-03-10 13:00:44 -08005598 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005599 pAdapter->device_mode != QDF_IBSS_MODE &&
5600 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005601 hdd_warn("device mode %s(%d) is not allowed",
5602 hdd_device_mode_to_string(pAdapter->device_mode),
5603 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005604 return -EINVAL;
5605 }
5606
5607 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5608
5609 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005610 hdd_info("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 return -EBUSY;
5612 }
5613 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5614 return -EINVAL;
5615
5616 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305617 /*Try disconnecting if already in connected state*/
5618 status = wlan_hdd_try_disconnect(pAdapter);
5619 if (0 > status) {
5620 hdd_err("Failed to disconnect the existing connection");
5621 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005622 }
5623
5624 /*
5625 * when cfg80211 defined, wpa_supplicant wext driver uses
5626 * zero-length, null-string ssid for force disconnection.
5627 * after disconnection (if previously connected) and cleaning ssid,
5628 * driver MUST return success.
5629 */
5630 if (0 == wrqu->essid.length)
5631 return 0;
5632
5633 status = hdd_wmm_get_uapsd_mask(pAdapter,
5634 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305635 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636 pWextState->roamProfile.uapsd_mask = 0;
5637
5638 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5639
5640 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5641 wrqu->essid.length;
5642
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305643 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005644 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305645 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005646 ssId), extra, wrqu->essid.length);
5647 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5648 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5649
5650 /* set gen ie */
5651 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5652
5653 /* set auth */
5654 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5655 }
5656#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005657 hdd_notice("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 if (pAdapter->wapi_info.nWapiMode) {
5659 switch (pAdapter->wapi_info.wapiAuthMode) {
5660 case WAPI_AUTH_MODE_PSK:
5661 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005662 hdd_notice("WAPI AUTH TYPE: PSK: %d",
5663 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005664 pRoamProfile->AuthType.numEntries = 1;
5665 pRoamProfile->AuthType.authType[0] =
5666 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5667 break;
5668 }
5669 case WAPI_AUTH_MODE_CERT:
5670 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005671 hdd_notice("WAPI AUTH TYPE: CERT: %d",
5672 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005673 pRoamProfile->AuthType.numEntries = 1;
5674 pRoamProfile->AuthType.authType[0] =
5675 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5676 break;
5677 }
5678 } /* End of switch */
5679 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5680 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005681 hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005682 pRoamProfile->EncryptionType.numEntries = 1;
5683 pRoamProfile->EncryptionType.encryptionType[0] =
5684 eCSR_ENCRYPT_TYPE_WPI;
5685 pRoamProfile->mcEncryptionType.numEntries = 1;
5686 pRoamProfile->mcEncryptionType.encryptionType[0] =
5687 eCSR_ENCRYPT_TYPE_WPI;
5688 }
5689 }
5690#endif /* FEATURE_WLAN_WAPI */
5691 /* if previous genIE is not NULL, update AssocIE */
5692 if (0 != pWextState->genIE.length) {
5693 memset(&pWextState->assocAddIE, 0,
5694 sizeof(pWextState->assocAddIE));
5695 memcpy(pWextState->assocAddIE.addIEdata,
5696 pWextState->genIE.addIEdata, pWextState->genIE.length);
5697 pWextState->assocAddIE.length = pWextState->genIE.length;
5698 pWextState->roamProfile.pAddIEAssoc =
5699 pWextState->assocAddIE.addIEdata;
5700 pWextState->roamProfile.nAddIEAssocLength =
5701 pWextState->assocAddIE.length;
5702
5703 /* clear previous genIE after use it */
5704 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5705 }
5706
5707 /*
5708 * Assumes it is not WPS Association by default, except when
5709 * pAddIEAssoc has WPS IE.
5710 */
5711 pWextState->roamProfile.bWPSAssociation = false;
5712
5713 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5714 pWextState->roamProfile.
5715 nAddIEAssocLength))
5716 pWextState->roamProfile.bWPSAssociation = true;
5717
5718 /* Disable auto BMPS entry by PMC until DHCP is done */
5719 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5720 true);
5721
5722 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5723
5724 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005725 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005726 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005727 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5728 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005729 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005730
Agrawal Ashish6b015762016-05-05 11:22:18 +05305731 /*
5732 * Change conn_state to connecting before sme_roam_connect(),
5733 * because sme_roam_connect() has a direct path to call
5734 * hdd_sme_roam_callback(), which will change the conn_state
5735 * If direct path, conn_state will be accordingly changed to
5736 * NotConnected or Associated by either
5737 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5738 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5739 * Connecting state will remain until it is completed.
5740 *
5741 * If connection state is not changed,
5742 * connection state will remain in eConnectionState_NotConnected state.
5743 * In hdd_association_completion_handler, "hddDisconInProgress" is
5744 * set to true if conn state is eConnectionState_NotConnected.
5745 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5746 * informed of connect result indication which is an issue.
5747 */
5748 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305749 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305750 hdd_conn_set_connection_state(pAdapter,
5751 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305752
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005753 status = sme_roam_connect(hHal, pAdapter->sessionId,
5754 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305755 if ((QDF_STATUS_SUCCESS != status) &&
5756 (QDF_STA_MODE == pAdapter->device_mode ||
5757 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5758 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5759 pAdapter->sessionId, status);
5760 /* change back to NotAssociated */
5761 hdd_conn_set_connection_state(pAdapter,
5762 eConnectionState_NotConnected);
5763 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005764 pRoamProfile->ChannelInfo.ChannelList = NULL;
5765 pRoamProfile->ChannelInfo.numOfChannels = 0;
5766
5767 EXIT();
5768 return status;
5769}
5770
5771/**
5772 * iw_set_essid() - set essid handler function
5773 * @dev: Pointer to the net device.
5774 * @info: Pointer to the iw_request_info.
5775 * @wrqu: Pointer to the iwreq_data.
5776 * @extra: Pointer to the data.
5777 *
5778 * Return: 0 for success, error number on failure
5779 */
5780int iw_set_essid(struct net_device *dev,
5781 struct iw_request_info *info,
5782 union iwreq_data *wrqu, char *extra)
5783{
5784 int ret;
5785
5786 cds_ssr_protect(__func__);
5787 ret = __iw_set_essid(dev, info, wrqu, extra);
5788 cds_ssr_unprotect(__func__);
5789
5790 return ret;
5791}
5792
5793/**
5794 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5795 * @dev: pointer to the net device
5796 * @info: pointer to the iw request info
5797 * @dwrq: pointer to iw_point
5798 * @extra: pointer to the data
5799 *
5800 * Return: 0 on success, error number otherwise
5801 */
5802static int __iw_get_essid(struct net_device *dev,
5803 struct iw_request_info *info,
5804 struct iw_point *dwrq, char *extra)
5805{
5806 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5807 hdd_context_t *hdd_ctx;
5808 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5809 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5810 int ret;
5811
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005812 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005813
5814 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5815 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305816 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005817 return ret;
5818
Jeff Johnson441e1f72017-02-07 08:50:49 -08005819 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5820 if (0 != ret)
5821 return ret;
5822
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005823 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5824 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5825 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5826 || pHddStaCtx->conn_info.connState ==
5827 eConnectionState_IbssDisconnected)
5828 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5829 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5830 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5831 dwrq->length);
5832 dwrq->flags = 1;
5833 } else {
5834 memset(extra, 0, dwrq->length);
5835 dwrq->length = 0;
5836 dwrq->flags = 0;
5837 }
5838 EXIT();
5839 return 0;
5840}
5841
5842/**
5843 * iw_get_essid() - get essid handler function
5844 * @dev: Pointer to the net device.
5845 * @info: Pointer to the iw_request_info.
5846 * @wrqu: Pointer to the iwreq_data.
5847 * @extra: Pointer to the data.
5848 *
5849 * Return: 0 for success, error number on failure
5850 */
5851int iw_get_essid(struct net_device *dev,
5852 struct iw_request_info *info,
5853 struct iw_point *wrqu, char *extra)
5854{
5855 int ret;
5856
5857 cds_ssr_protect(__func__);
5858 ret = __iw_get_essid(dev, info, wrqu, extra);
5859 cds_ssr_unprotect(__func__);
5860
5861 return ret;
5862}
5863
5864/**
5865 * __iw_set_auth() -
5866 * This function sets the auth type received from the wpa_supplicant
5867 * @dev: pointer to the net device
5868 * @info: pointer to the iw request info
5869 * @wrqu: pointer to iwreq_data
5870 * @extra: pointer to the data
5871 *
5872 * Return: 0 on success, error number otherwise
5873 */
5874static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5875 union iwreq_data *wrqu, char *extra)
5876{
5877 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5878 hdd_context_t *hdd_ctx;
5879 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5880 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5881 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5882 eCsrEncryptionType mcEncryptionType;
5883 eCsrEncryptionType ucEncryptionType;
5884 int ret;
5885
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005886 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005887
5888 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5889 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305890 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 return ret;
5892
Jeff Johnson441e1f72017-02-07 08:50:49 -08005893 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5894 if (0 != ret)
5895 return ret;
5896
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005897 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5898 case IW_AUTH_WPA_VERSION:
5899 pWextState->wpaVersion = wrqu->param.value;
5900 break;
5901
5902 case IW_AUTH_CIPHER_PAIRWISE:
5903 {
5904 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5905 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5906 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5907 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5908 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5909 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5910 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5911 if ((IW_AUTH_KEY_MGMT_802_1X
5912 ==
5913 (pWextState->
5914 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5915 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5916 pHddStaCtx->conn_info.authType))
5917 /*Dynamic WEP key */
5918 ucEncryptionType =
5919 eCSR_ENCRYPT_TYPE_WEP40;
5920 else
5921 /*Static WEP key */
5922 ucEncryptionType =
5923 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5924 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5925 if ((IW_AUTH_KEY_MGMT_802_1X
5926 ==
5927 (pWextState->
5928 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5929 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5930 pHddStaCtx->conn_info.authType))
5931 /*Dynamic WEP key */
5932 ucEncryptionType =
5933 eCSR_ENCRYPT_TYPE_WEP104;
5934 else
5935 /*Static WEP key */
5936 ucEncryptionType =
5937 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5938 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005939 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
5940 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005941 return -EINVAL;
5942 }
5943
5944 pRoamProfile->EncryptionType.numEntries = 1;
5945 pRoamProfile->EncryptionType.encryptionType[0] =
5946 ucEncryptionType;
5947 }
5948 break;
5949 case IW_AUTH_CIPHER_GROUP:
5950 {
5951 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5952 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5953 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5954 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5955 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5956 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5957 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5958 if ((IW_AUTH_KEY_MGMT_802_1X
5959 ==
5960 (pWextState->
5961 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5962 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5963 pHddStaCtx->conn_info.authType))
5964 mcEncryptionType =
5965 eCSR_ENCRYPT_TYPE_WEP40;
5966 else
5967 mcEncryptionType =
5968 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5969 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5970 /* Dynamic WEP keys won't work with shared keys */
5971 if ((IW_AUTH_KEY_MGMT_802_1X
5972 ==
5973 (pWextState->
5974 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5975 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5976 pHddStaCtx->conn_info.authType)) {
5977 mcEncryptionType =
5978 eCSR_ENCRYPT_TYPE_WEP104;
5979 } else {
5980 mcEncryptionType =
5981 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5982 }
5983 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005984 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005985 wrqu->param.value);
5986 return -EINVAL;
5987 }
5988
5989 pRoamProfile->mcEncryptionType.numEntries = 1;
5990 pRoamProfile->mcEncryptionType.encryptionType[0] =
5991 mcEncryptionType;
5992 }
5993 break;
5994
5995 case IW_AUTH_80211_AUTH_ALG:
5996 {
Jeff Johnson5a062372017-01-12 09:51:25 -08005997 /* Save the auth algo here and set auth type to SME
5998 * Roam profile in the iw_set_ap_address
5999 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006000 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6001 pHddStaCtx->conn_info.authType =
6002 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6003
6004 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6005 pHddStaCtx->conn_info.authType =
6006 eCSR_AUTH_TYPE_SHARED_KEY;
6007
6008 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6009 /*Not supported */
6010 pHddStaCtx->conn_info.authType =
6011 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6012 pWextState->roamProfile.AuthType.authType[0] =
6013 pHddStaCtx->conn_info.authType;
6014 }
6015 break;
6016
6017 case IW_AUTH_KEY_MGMT:
6018 {
6019#ifdef FEATURE_WLAN_ESE
6020#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6021 /*Check for CCKM AKM type */
6022 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006023 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006024 /* Set the CCKM bit in authKeyMgmt */
6025 /*
6026 * Right now, this breaks all ref to authKeyMgmt because
6027 * our code doesn't realize it is a "bitfield"
6028 */
6029 pWextState->authKeyMgmt |=
6030 IW_AUTH_KEY_MGMT_CCKM;
6031 /* Set the key management to 802.1X */
6032 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
6033 pWextState->isESEConnection = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006034 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6035 /* Save the key management */
6036 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006037 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006038 /* Save the key management anyway */
6039 pWextState->authKeyMgmt = wrqu->param.value;
6040 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6041 /* Save the key management */
6042 pWextState->authKeyMgmt |=
6043 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006044 }
6045#else
6046 /* Save the key management */
6047 pWextState->authKeyMgmt = wrqu->param.value;
6048#endif /* FEATURE_WLAN_ESE */
6049 }
6050 break;
6051
6052 case IW_AUTH_TKIP_COUNTERMEASURES:
6053 {
6054 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006055 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006056 wrqu->param.value);
6057 pWextState->mTKIPCounterMeasures =
6058 TKIP_COUNTER_MEASURE_STARTED;
6059 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006060 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006061 wrqu->param.value);
6062 pWextState->mTKIPCounterMeasures =
6063 TKIP_COUNTER_MEASURE_STOPED;
6064 }
6065 }
6066 break;
6067 case IW_AUTH_DROP_UNENCRYPTED:
6068 case IW_AUTH_WPA_ENABLED:
6069 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6070 case IW_AUTH_ROAMING_CONTROL:
6071 case IW_AUTH_PRIVACY_INVOKED:
6072
6073 default:
6074
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006075 hdd_warn("called with unsupported auth type %d",
6076 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 break;
6078 }
6079
6080 EXIT();
6081 return 0;
6082}
6083
6084/**
6085 * iw_set_auth() - set auth callback function
6086 * @dev: Pointer to the net device.
6087 * @info: Pointer to the iw_request_info.
6088 * @wrqu: Pointer to the iwreq_data.
6089 * @extra: Pointer to the data.
6090 *
6091 * Return: 0 for success, error number on failure.
6092 */
6093int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6094 union iwreq_data *wrqu, char *extra)
6095{
6096 int ret;
6097
6098 cds_ssr_protect(__func__);
6099 ret = __iw_set_auth(dev, info, wrqu, extra);
6100 cds_ssr_unprotect(__func__);
6101
6102 return ret;
6103}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006104/**
6105 * __iw_get_auth() -
6106 * This function returns the auth type to the wpa_supplicant
6107 * @dev: pointer to the net device
6108 * @info: pointer to the iw request info
6109 * @wrqu: pointer to iwreq_data
6110 * @extra: pointer to the data
6111 *
6112 * Return: 0 on success, error number otherwise
6113 */
6114static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6115 union iwreq_data *wrqu, char *extra)
6116{
6117 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6118 hdd_context_t *hdd_ctx;
6119 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6120 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6121 int ret;
6122
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006123 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006124
6125 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6126 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306127 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006128 return ret;
6129
Jeff Johnson441e1f72017-02-07 08:50:49 -08006130 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6131 if (0 != ret)
6132 return ret;
6133
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 switch (pRoamProfile->negotiatedAuthType) {
6135 case eCSR_AUTH_TYPE_WPA_NONE:
6136 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6137 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6138 break;
6139 case eCSR_AUTH_TYPE_WPA:
6140 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6141 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6142 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006143
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006145 case eCSR_AUTH_TYPE_RSN:
6146 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6147 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6148 break;
6149 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6150 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6151 break;
6152 case eCSR_AUTH_TYPE_SHARED_KEY:
6153 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6154 break;
6155 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006156 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006157 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6158 break;
6159 case eCSR_AUTH_TYPE_AUTOSWITCH:
6160 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6161 break;
6162 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006163 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006164 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6165 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006166
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006167 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006168 case eCSR_AUTH_TYPE_RSN_PSK:
6169#ifdef WLAN_FEATURE_11W
6170 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6171 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6172#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006173 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006174 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6175 return -EIO;
6176 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006177 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006178 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6179 return -EIO;
6180 }
6181 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6182 switch (pRoamProfile->negotiatedUCEncryptionType) {
6183 case eCSR_ENCRYPT_TYPE_NONE:
6184 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6185 break;
6186 case eCSR_ENCRYPT_TYPE_WEP40:
6187 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6188 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6189 break;
6190 case eCSR_ENCRYPT_TYPE_TKIP:
6191 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6192 break;
6193 case eCSR_ENCRYPT_TYPE_WEP104:
6194 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6195 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6196 break;
6197 case eCSR_ENCRYPT_TYPE_AES:
6198 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6199 break;
6200 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006201 hdd_notice("called with unknown auth type %d",
6202 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006203 return -EIO;
6204 }
6205 }
6206
6207 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6208 switch (pRoamProfile->negotiatedMCEncryptionType) {
6209 case eCSR_ENCRYPT_TYPE_NONE:
6210 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6211 break;
6212 case eCSR_ENCRYPT_TYPE_WEP40:
6213 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6214 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6215 break;
6216 case eCSR_ENCRYPT_TYPE_TKIP:
6217 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6218 break;
6219 case eCSR_ENCRYPT_TYPE_WEP104:
6220 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6221 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6222 break;
6223 case eCSR_ENCRYPT_TYPE_AES:
6224 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6225 break;
6226 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006227 hdd_info("called with unknown auth type %d",
6228 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006229 return -EIO;
6230 }
6231 }
6232
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006233 hdd_info("called with auth type %d",
6234 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006235 EXIT();
6236 return 0;
6237}
6238
6239/**
6240 * iw_get_auth() - get auth callback function
6241 * @dev: Pointer to the net device.
6242 * @info: Pointer to the iw_request_info.
6243 * @wrqu: Pointer to the iwreq_data.
6244 * @extra: Pointer to the data.
6245 *
6246 * Return: 0 for success, error number on failure.
6247 */
6248int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6249 union iwreq_data *wrqu, char *extra)
6250{
6251 int ret;
6252
6253 cds_ssr_protect(__func__);
6254 ret = __iw_get_auth(dev, info, wrqu, extra);
6255 cds_ssr_unprotect(__func__);
6256
6257 return ret;
6258}
6259
6260/**
6261 * __iw_set_ap_address() - set ap address
6262 * @dev: pointer to the net device
6263 * @info: pointer to the iw request info
6264 * @wrqu: pointer to iwreq_data
6265 * @extra: pointer to the data
6266 *
6267 * This function updates the HDD global station context connection info
6268 * BSSID with the MAC address received from the wpa_supplicant.
6269 *
6270 * Return: 0 on success, error number otherwise
6271 */
6272static int __iw_set_ap_address(struct net_device *dev,
6273 struct iw_request_info *info,
6274 union iwreq_data *wrqu, char *extra)
6275{
6276
6277 hdd_adapter_t *adapter;
6278 hdd_context_t *hdd_ctx;
6279 hdd_station_ctx_t *pHddStaCtx =
6280 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6281 uint8_t *pMacAddress = NULL;
6282 int ret;
6283
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006284 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006285
6286 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6287
6288 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6289 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306290 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006291 return ret;
6292
Jeff Johnson441e1f72017-02-07 08:50:49 -08006293 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6294 if (0 != ret)
6295 return ret;
6296
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006297 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006298 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306299 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306300 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006301 EXIT();
6302
6303 return 0;
6304}
6305
6306/**
6307 * iw_set_ap_address() - set ap addresses callback function
6308 * @dev: Pointer to the net device.
6309 * @info: Pointer to the iw_request_info.
6310 * @wrqu: Pointer to the iwreq_data.
6311 * @extra: Pointer to the data.
6312 *
6313 * Return: 0 for success, error number on failure.
6314 */
6315int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6316 union iwreq_data *wrqu, char *extra)
6317{
6318 int ret;
6319
6320 cds_ssr_protect(__func__);
6321 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6322 cds_ssr_unprotect(__func__);
6323
6324 return ret;
6325}
6326
6327/**
6328 * __iw_get_ap_address() - get ap address
6329 * @dev: pointer to the net device
6330 * @info: pointer to the iw request info
6331 * @wrqu: pointer to iwreq_data
6332 * @extra: pointer to the data
6333 *
6334 * This function returns currently associated BSSID.
6335 *
6336 * Return: 0 on success, error number otherwise
6337 */
6338static int __iw_get_ap_address(struct net_device *dev,
6339 struct iw_request_info *info,
6340 union iwreq_data *wrqu, char *extra)
6341{
6342 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6343 hdd_context_t *hdd_ctx;
6344 hdd_station_ctx_t *pHddStaCtx =
6345 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6346 int ret;
6347
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006348 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006349
6350 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6351 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306352 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006353 return ret;
6354
Jeff Johnson441e1f72017-02-07 08:50:49 -08006355 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6356 if (0 != ret)
6357 return ret;
6358
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006359 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6360 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306361 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306363 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006364 } else {
6365 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6366 }
6367 EXIT();
6368 return 0;
6369}
6370
6371/**
6372 * iw_get_ap_address() - get ap addresses callback function
6373 * @dev: Pointer to the net device.
6374 * @info: Pointer to the iw_request_info.
6375 * @wrqu: Pointer to the iwreq_data.
6376 * @extra: Pointer to the data.
6377 *
6378 * Return: 0 for success, error number on failure.
6379 */
6380int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6381 union iwreq_data *wrqu, char *extra)
6382{
6383 int ret;
6384
6385 cds_ssr_protect(__func__);
6386 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6387 cds_ssr_unprotect(__func__);
6388
6389 return ret;
6390}