blob: e6dd1fa1f693e113e6bb1ed3396f555ccb9f938e [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>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080063
64/* These are needed to recognize WPA and RSN suite types */
65#define HDD_WPA_OUI_SIZE 4
66#define HDD_RSN_OUI_SIZE 4
67uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
68uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
69uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
70uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
71uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
72uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
73
74#ifdef FEATURE_WLAN_ESE
75/* CCKM */
76uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
77/* CCKM */
78uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
79#endif /* FEATURE_WLAN_ESE */
80
81/* group cipher */
82uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
83
84/* WEP-40 or RSN */
85uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
86
87/* TKIP or RSN-PSK */
88uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
89
90/* Reserved */
91uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
92
93/* AES-CCMP */
94uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
95
96/* WEP-104 */
97uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
98
99#ifdef WLAN_FEATURE_11W
100/* RSN-PSK-SHA256 */
101uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
102
103/* RSN-8021X-SHA256 */
104uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
105#endif
106
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800107/* Offset where the EID-Len-IE, start. */
108#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
109#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800110
111#define BEACON_FRAME_IES_OFFSET 12
112#define HDD_PEER_AUTHORIZE_WAIT 10
113
114/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700115 * beacon_filter_table - table of IEs used for beacon filtering
116 */
117static const int beacon_filter_table[] = {
118 SIR_MAC_DS_PARAM_SET_EID,
119 SIR_MAC_ERP_INFO_EID,
120 SIR_MAC_EDCA_PARAM_SET_EID,
121 SIR_MAC_QOS_CAPABILITY_EID,
122 SIR_MAC_HT_INFO_EID,
123 SIR_MAC_VHT_OPMODE_EID,
124 SIR_MAC_VHT_OPERATION_EID,
125};
126
127/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800128 * hdd_conn_set_authenticated() - set authentication state
129 * @pAdapter: pointer to the adapter
130 * @authState: authentication state
131 *
132 * This function updates the global HDD station context
133 * authentication state.
134 *
135 * Return: none
136 */
137static void
138hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
139{
140 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
141 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
142
143 /* save the new connection state */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700144 hdd_notice("Authenticated state Changed from oldState:%d to State:%d",
145 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800146 pHddStaCtx->conn_info.uIsAuthenticated = authState;
147
148 /* Check is pending ROC request or not when auth state changed */
149 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
150}
151
152/**
153 * hdd_conn_set_connection_state() - set connection state
154 * @pAdapter: pointer to the adapter
155 * @connState: connection state
156 *
157 * This function updates the global HDD station context connection state.
158 *
159 * Return: none
160 */
161void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
162 eConnectionState connState)
163{
164 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
165 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
166
167 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530168 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
169 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
170 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800171 pHddStaCtx->conn_info.connState = connState;
172
173 /* Check is pending ROC request or not when connection state changed */
174 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
175}
176
177/**
178 * hdd_conn_get_connection_state() - get connection state
179 * @pAdapter: pointer to the adapter
180 * @pConnState: pointer to connection state
181 *
182 * This function updates the global HDD station context connection state.
183 *
184 * Return: true if (Infra Associated or IBSS Connected)
185 * and sets output parameter pConnState;
186 * false otherwise
187 */
188static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
189 eConnectionState *pConnState)
190{
191 bool fConnected = false;
192 eConnectionState connState;
193
194 /* get the connection state. */
195 connState = pHddStaCtx->conn_info.connState;
196
197 if (eConnectionState_Associated == connState ||
198 eConnectionState_IbssConnected == connState ||
199 eConnectionState_IbssDisconnected == connState) {
200 fConnected = true;
201 }
202
203 if (pConnState)
204 *pConnState = connState;
205
206 return fConnected;
207}
208
209/**
210 * hdd_is_connecting() - Function to check connection progress
211 * @hdd_sta_ctx: pointer to global HDD Station context
212 *
213 * Return: true if connecting, false otherwise
214 */
215bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
216{
217 return hdd_sta_ctx->conn_info.connState ==
218 eConnectionState_Connecting;
219}
220
221/**
222 * hdd_conn_is_connected() - Function to check connection status
223 * @pHddStaCtx: pointer to global HDD Station context
224 *
225 * Return: false if any errors encountered, true otherwise
226 */
227bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
228{
229 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
230}
231
232/**
233 * hdd_conn_get_connected_band() - get current connection radio band
234 * @pHddStaCtx: pointer to global HDD Station context
235 *
236 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
237 * eCSR_BAND_ALL if not connected
238 */
239eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
240{
241 uint8_t staChannel = 0;
242
243 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
244 staChannel = pHddStaCtx->conn_info.operationChannel;
245
246 if (staChannel > 0 && staChannel < 14)
247 return eCSR_BAND_24;
248 else if (staChannel >= 36 && staChannel <= 184)
249 return eCSR_BAND_5G;
250 else /* If station is not connected return as eCSR_BAND_ALL */
251 return eCSR_BAND_ALL;
252}
253
254/**
255 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
256 * @pHddStaCtx: pointer to global HDD Station context
257 * @pConnectedCipherAlgo: pointer to connected cipher algo
258 *
259 * Return: false if any errors encountered, true otherwise
260 */
261static inline bool
262hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
263 eCsrEncryptionType *pConnectedCipherAlgo)
264{
265 bool fConnected = false;
266
267 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
268
269 if (pConnectedCipherAlgo)
270 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
271
272 return fConnected;
273}
274
275/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700276 * hdd_remove_beacon_filter() - remove beacon filter
277 * @adapter: Pointer to the hdd adapter
278 *
279 * Return: 0 on success and errno on failure
280 */
281static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
282{
283 QDF_STATUS status;
284 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
285
286 status = sme_remove_beacon_filter(hdd_ctx->hHal,
287 adapter->sessionId);
288 if (!QDF_IS_STATUS_SUCCESS(status)) {
289 hdd_err("sme_remove_beacon_filter() failed");
290 return -EFAULT;
291 }
292
293 return 0;
294}
295
296/**
297 * hdd_add_beacon_filter() - add beacon filter
298 * @adapter: Pointer to the hdd adapter
299 *
300 * Return: 0 on success and errno on failure
301 */
302static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
303{
304 int i;
305 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
306 QDF_STATUS status;
307 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
308
309 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530310 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700311 (unsigned long int *)ie_map);
312
313 status = sme_add_beacon_filter(hdd_ctx->hHal,
314 adapter->sessionId, ie_map);
315 if (!QDF_IS_STATUS_SUCCESS(status)) {
316 hdd_err("sme_add_beacon_filter() failed");
317 return -EFAULT;
318 }
319 return 0;
320}
321
322/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530323 * hdd_copy_vht_caps()- copy vht caps info from roam info to
324 * hdd station context.
325 * @hdd_sta_ctx: pointer to hdd station context
326 * @roam_info: pointer to roam info
327 *
328 * Return: None
329 */
330static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
331 tCsrRoamInfo *roam_info)
332{
333 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
334 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
335 uint32_t i, temp_ht_cap;
336
337 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
338
339 if (roam_ht_cap->advCodingCap)
340 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
341 if (roam_ht_cap->supportedChannelWidthSet)
342 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
343 temp_ht_cap = roam_ht_cap->mimoPowerSave &
344 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
345 if (temp_ht_cap)
346 hdd_ht_cap->cap_info |=
347 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
348 if (roam_ht_cap->greenField)
349 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
350 if (roam_ht_cap->shortGI20MHz)
351 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
352 if (roam_ht_cap->shortGI40MHz)
353 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
354 if (roam_ht_cap->txSTBC)
355 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
356 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
357 IEEE80211_HT_CAP_RX_STBC_SHIFT);
358 if (temp_ht_cap)
359 hdd_ht_cap->cap_info |=
360 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
361 if (roam_ht_cap->delayedBA)
362 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
363 if (roam_ht_cap->maximalAMSDUsize)
364 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
365 if (roam_ht_cap->dsssCckMode40MHz)
366 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
367 if (roam_ht_cap->psmp)
368 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
369 if (roam_ht_cap->stbcControlFrame)
370 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
371 if (roam_ht_cap->lsigTXOPProtection)
372 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
373
374 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
375 if (roam_ht_cap->maxRxAMPDUFactor)
376 hdd_ht_cap->ampdu_params_info |=
377 IEEE80211_HT_AMPDU_PARM_FACTOR;
378 temp_ht_cap = roam_ht_cap->mpduDensity &
379 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
380 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
381 if (temp_ht_cap)
382 hdd_ht_cap->ampdu_params_info |=
383 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
384
385 /* 802.11n HT extended capabilities masks */
386 if (roam_ht_cap->pco)
387 hdd_ht_cap->extended_ht_cap_info |=
388 IEEE80211_HT_EXT_CAP_PCO;
389 temp_ht_cap = roam_ht_cap->transitionTime &
390 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
391 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
392 if (temp_ht_cap)
393 hdd_ht_cap->extended_ht_cap_info |=
394 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
395 temp_ht_cap = roam_ht_cap->mcsFeedback &
396 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
397 if (temp_ht_cap)
398 hdd_ht_cap->extended_ht_cap_info |=
399 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
400
401 /* tx_bf_cap_info capabilities */
402 if (roam_ht_cap->txBF)
403 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
404 if (roam_ht_cap->rxStaggeredSounding)
405 hdd_ht_cap->tx_BF_cap_info |=
406 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
407 if (roam_ht_cap->txStaggeredSounding)
408 hdd_ht_cap->tx_BF_cap_info |=
409 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
410 if (roam_ht_cap->rxZLF)
411 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
412 if (roam_ht_cap->txZLF)
413 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
414 if (roam_ht_cap->implicitTxBF)
415 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
416 temp_ht_cap = roam_ht_cap->calibration &
417 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
418 if (temp_ht_cap)
419 hdd_ht_cap->tx_BF_cap_info |=
420 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
421 if (roam_ht_cap->explicitCSITxBF)
422 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
423 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
424 hdd_ht_cap->tx_BF_cap_info |=
425 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
426 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
427 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
428 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
429 if (temp_ht_cap)
430 hdd_ht_cap->tx_BF_cap_info |=
431 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
432 temp_ht_cap =
433 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
434 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
435 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
436 if (temp_ht_cap)
437 hdd_ht_cap->tx_BF_cap_info |=
438 temp_ht_cap <<
439 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
440 temp_ht_cap =
441 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
442 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
443 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
444 if (temp_ht_cap)
445 hdd_ht_cap->tx_BF_cap_info |=
446 temp_ht_cap <<
447 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
448 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
449 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
450 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
451 if (temp_ht_cap)
452 hdd_ht_cap->tx_BF_cap_info |=
453 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
454 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
455 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
456 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
457 if (temp_ht_cap)
458 hdd_ht_cap->tx_BF_cap_info |=
459 temp_ht_cap <<
460 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
461 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
462 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
463 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
464 if (temp_ht_cap)
465 hdd_ht_cap->tx_BF_cap_info |=
466 temp_ht_cap <<
467 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
468
469 /* antenna selection */
470 if (roam_ht_cap->antennaSelection)
471 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
472 if (roam_ht_cap->explicitCSIFeedbackTx)
473 hdd_ht_cap->antenna_selection_info |=
474 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
475 if (roam_ht_cap->antennaIndicesFeedbackTx)
476 hdd_ht_cap->antenna_selection_info |=
477 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
478 if (roam_ht_cap->explicitCSIFeedback)
479 hdd_ht_cap->antenna_selection_info |=
480 ANTENNA_SEL_INFO_EXP_CSI_FB;
481 if (roam_ht_cap->antennaIndicesFeedback)
482 hdd_ht_cap->antenna_selection_info |=
483 ANTENNA_SEL_INFO_ANT_ID_FB;
484 if (roam_ht_cap->rxAS)
485 hdd_ht_cap->antenna_selection_info |=
486 ANTENNA_SEL_INFO_RX_AS;
487 if (roam_ht_cap->txSoundingPPDUs)
488 hdd_ht_cap->antenna_selection_info |=
489 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
490
491 /* mcs data rate */
492 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
493 hdd_ht_cap->mcs.rx_mask[i] =
494 roam_ht_cap->supportedMCSSet[i];
495 hdd_ht_cap->mcs.rx_highest =
496 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
497 ((short) (roam_ht_cap->supportedMCSSet[10]));
498 hdd_ht_cap->mcs.tx_params =
499 roam_ht_cap->supportedMCSSet[12];
500}
501
502#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
503#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
504#define VHT_CAP_RXSTBC_MASK_SHIFT 8
505#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
506#define VHT_CAP_BEAMFORMEE_STS_MASK \
507 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
508#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
509#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
510 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
511#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
512#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
513 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
514#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
515
516/**
517 * hdd_copy_ht_caps()- copy ht caps info from roam info to
518 * hdd station context.
519 * @hdd_sta_ctx: pointer to hdd station context
520 * @roam_info: pointer to roam info
521 *
522 * Return: None
523 */
524static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
525 tCsrRoamInfo *roam_info)
526{
527 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
528 struct ieee80211_vht_cap *hdd_vht_cap =
529 &hdd_sta_ctx->conn_info.vht_caps;
530 uint32_t temp_vht_cap;
531
532 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
533
534 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
535 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
536 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
537 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
538 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
539 if (temp_vht_cap)
540 if (roam_vht_cap->supportedChannelWidthSet &
541 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
542 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
543 hdd_vht_cap->vht_cap_info |=
544 temp_vht_cap <<
545 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
546 if (roam_vht_cap->supportedChannelWidthSet &
547 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
548 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
549 hdd_vht_cap->vht_cap_info |=
550 temp_vht_cap <<
551 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
552 if (roam_vht_cap->ldpcCodingCap)
553 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
554 if (roam_vht_cap->shortGI80MHz)
555 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
556 if (roam_vht_cap->shortGI160and80plus80MHz)
557 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
558 if (roam_vht_cap->txSTBC)
559 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
560 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
561 VHT_CAP_RXSTBC_MASK_SHIFT);
562 if (temp_vht_cap)
563 hdd_vht_cap->vht_cap_info |=
564 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
565 if (roam_vht_cap->suBeamFormerCap)
566 hdd_vht_cap->vht_cap_info |=
567 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
568 if (roam_vht_cap->suBeamformeeCap)
569 hdd_vht_cap->vht_cap_info |=
570 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
571 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
572 (VHT_CAP_BEAMFORMEE_STS_MASK);
573 if (temp_vht_cap)
574 hdd_vht_cap->vht_cap_info |=
575 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
576 temp_vht_cap = roam_vht_cap->numSoundingDim &
577 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
578 if (temp_vht_cap)
579 hdd_vht_cap->vht_cap_info |=
580 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
581 if (roam_vht_cap->muBeamformerCap)
582 hdd_vht_cap->vht_cap_info |=
583 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
584 if (roam_vht_cap->muBeamformeeCap)
585 hdd_vht_cap->vht_cap_info |=
586 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
587 if (roam_vht_cap->vhtTXOPPS)
588 hdd_vht_cap->vht_cap_info |=
589 IEEE80211_VHT_CAP_VHT_TXOP_PS;
590 if (roam_vht_cap->htcVHTCap)
591 hdd_vht_cap->vht_cap_info |=
592 IEEE80211_VHT_CAP_HTC_VHT;
593 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
594 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
595 if (temp_vht_cap)
596 hdd_vht_cap->vht_cap_info |=
597 temp_vht_cap <<
598 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
599 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
600 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
601 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
602 if (temp_vht_cap)
603 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
604 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
605 if (roam_vht_cap->rxAntPattern)
606 hdd_vht_cap->vht_cap_info |=
607 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
608 if (roam_vht_cap->txAntPattern)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
611 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
612 hdd_vht_cap->supp_mcs.rx_highest =
613 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
614 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
615 hdd_vht_cap->supp_mcs.tx_highest =
616 ((uint16_t)roam_vht_cap->txSupDataRate);
617}
618
619/* ht param */
620#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
621#define HT_PARAM_SERVICE_INT_GRAN 0xe0
622#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
623
624/* operatinon mode */
625#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
626
627/* stbc_param */
628#define HT_STBC_PARAM_MCS 0x007f
629
630/**
631 * hdd_copy_ht_operation()- copy HT operation element from roam info to
632 * hdd station context.
633 * @hdd_sta_ctx: pointer to hdd station context
634 * @roam_info: pointer to roam info
635 *
636 * Return: None
637 */
638static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
639 tCsrRoamInfo *roam_info)
640{
641 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
642 struct ieee80211_ht_operation *hdd_ht_ops =
643 &hdd_sta_ctx->conn_info.ht_operation;
644 uint32_t i, temp_ht_ops;
645
646 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
647
648 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
649
650 /* HT_PARAMS */
651 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
652 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
653 if (temp_ht_ops)
654 hdd_ht_ops->ht_param |= temp_ht_ops;
655 else
656 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
657 if (roam_ht_ops->recommendedTxWidthSet)
658 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
659 if (roam_ht_ops->rifsMode)
660 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
661 if (roam_ht_ops->controlledAccessOnly)
662 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
663 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
664 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
665 if (temp_ht_ops)
666 hdd_ht_ops->ht_param |= temp_ht_ops <<
667 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
668
669 /* operation mode */
670 temp_ht_ops = roam_ht_ops->opMode &
671 IEEE80211_HT_OP_MODE_PROTECTION;
672 switch (temp_ht_ops) {
673 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
674 hdd_ht_ops->operation_mode |=
675 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
676 break;
677 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
678 hdd_ht_ops->operation_mode |=
679 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
680 break;
681 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
682 hdd_ht_ops->operation_mode |=
683 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
684 break;
685 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
686 default:
687 hdd_ht_ops->operation_mode |=
688 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
689 }
690 if (roam_ht_ops->nonGFDevicesPresent)
691 hdd_ht_ops->operation_mode |=
692 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
693 if (roam_ht_ops->transmitBurstLimit)
694 hdd_ht_ops->operation_mode |=
695 HT_OP_MODE_TX_BURST_LIMIT;
696 if (roam_ht_ops->obssNonHTStaPresent)
697 hdd_ht_ops->operation_mode |=
698 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
699
700 /* stbc_param */
701 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
702 HT_STBC_PARAM_MCS;
703 if (temp_ht_ops)
704 hdd_ht_ops->stbc_param |= temp_ht_ops;
705 if (roam_ht_ops->dualCTSProtection)
706 hdd_ht_ops->stbc_param |=
707 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
708 if (roam_ht_ops->secondaryBeacon)
709 hdd_ht_ops->stbc_param |=
710 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
711 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
712 hdd_ht_ops->stbc_param |=
713 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
714 if (roam_ht_ops->pcoActive)
715 hdd_ht_ops->stbc_param |=
716 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
717 if (roam_ht_ops->pcoPhase)
718 hdd_ht_ops->stbc_param |=
719 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
720
721 /* basic MCs set */
722 for (i = 0; i < 16; ++i)
723 hdd_ht_ops->basic_set[i] =
724 roam_ht_ops->basicMCSSet[i];
725}
726
727/**
728 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
729 * hdd station context.
730 * @hdd_sta_ctx: pointer to hdd station context
731 * @roam_info: pointer to roam info
732 *
733 * Return: None
734 */
735static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
736 tCsrRoamInfo *roam_info)
737{
738 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
739 struct ieee80211_vht_operation *hdd_vht_ops =
740 &hdd_sta_ctx->conn_info.vht_operation;
741
742 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
743
744 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
745 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
746 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
747 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
748}
749
750
751/**
752 * hdd_save_bss_info() - save connection info in hdd sta ctx
753 * @adapter: Pointer to adapter
754 * @roam_info: pointer to roam info
755 *
756 * Return: None
757 */
758static void hdd_save_bss_info(hdd_adapter_t *adapter,
759 tCsrRoamInfo *roam_info)
760{
761 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
762
763 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
764 hdd_sta_ctx->conn_info.operationChannel);
765 if (roam_info->vht_caps.present) {
766 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
767 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
768 } else {
769 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
770 }
771 if (roam_info->ht_caps.present) {
772 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
773 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
774 } else {
775 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
776 }
777 if (roam_info->reassoc)
778 hdd_sta_ctx->conn_info.roam_count++;
779 if (roam_info->hs20vendor_ie.present) {
780 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
781 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
782 &roam_info->hs20vendor_ie,
783 sizeof(roam_info->hs20vendor_ie));
784 } else {
785 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
786 }
787 if (roam_info->ht_operation.present) {
788 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
789 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
790 } else {
791 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
792 }
793 if (roam_info->vht_operation.present) {
794 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
795 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
796 } else {
797 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
798 }
799}
800
801/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800802 * hdd_conn_save_connect_info() - save current connection information
803 * @pAdapter: pointer to adapter
804 * @pRoamInfo: pointer to roam info
805 * @eBssType: bss type
806 *
807 * Return: none
808 */
809static void
810hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
811 eCsrRoamBssType eBssType)
812{
813 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
814 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
815
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530816 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800817
818 if (pRoamInfo) {
819 /* Save the BSSID for the connection */
820 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530821 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530822 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 &pRoamInfo->bssid);
824
825 /*
826 * Save the Station ID for this station from
827 * the 'Roam Info'. For IBSS mode, staId is
828 * assigned in NEW_PEER_IND. For reassoc,
829 * the staID doesn't change and it may be invalid
830 * in this structure so no change here.
831 */
832 if (!pRoamInfo->fReassocReq) {
833 pHddStaCtx->conn_info.staId[0] =
834 pRoamInfo->staId;
835 }
836 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530837 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800838 &pRoamInfo->bssid);
839 } else {
840 /*
841 * can't happen. We need a valid IBSS or Infra setting
842 * in the BSSDescription or we can't function.
843 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530844 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800845 }
846
847 /* notify WMM */
848 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
849
850 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530851 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800852 } else {
853 /* Get Multicast Encryption Type */
854 encryptType =
855 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
856 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
857 /* Get Unicast Encryption Type */
858 encryptType =
859 pRoamInfo->u.pConnectedProfile->EncryptionType;
860 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
861
862 pHddStaCtx->conn_info.authType =
863 pRoamInfo->u.pConnectedProfile->AuthType;
864
865 pHddStaCtx->conn_info.operationChannel =
866 pRoamInfo->u.pConnectedProfile->operationChannel;
867
868 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530869 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800870 &pRoamInfo->u.pConnectedProfile->SSID,
871 sizeof(tSirMacSSid));
872
873 /* Save dot11mode in which STA associated to AP */
874 pHddStaCtx->conn_info.dot11Mode =
875 pRoamInfo->u.pConnectedProfile->dot11Mode;
876
877 pHddStaCtx->conn_info.proxyARPService =
878 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530879
880 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
881
882 pHddStaCtx->conn_info.rate_flags =
883 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530885 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800886 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887}
888
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800889/**
890 * hdd_send_ft_assoc_response() - send fast transition assoc response
891 * @dev: pointer to net device
892 * @pAdapter: pointer to adapter
893 * @pCsrRoamInfo: pointer to roam info
894 *
895 * Send the 11R key information to the supplicant. Only then can the supplicant
896 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
897 * for the same purpose.)
898 *
899 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
900 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
901 * This is the Assoc Response.
902 *
903 * Return: none
904 */
905static void
906hdd_send_ft_assoc_response(struct net_device *dev,
907 hdd_adapter_t *pAdapter,
908 tCsrRoamInfo *pCsrRoamInfo)
909{
910 union iwreq_data wrqu;
911 char *buff;
912 unsigned int len = 0;
913 u8 *pFTAssocRsp = NULL;
914
915 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700916 hdd_err("pCsrRoamInfo->nAssocRspLength=%d",
917 (int)pCsrRoamInfo->nAssocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918 return;
919 }
920
921 pFTAssocRsp =
922 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
923 pCsrRoamInfo->nAssocReqLength);
924 if (pFTAssocRsp == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700925 hdd_err("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 return;
927 }
928 /* pFTAssocRsp needs to point to the IEs */
929 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700930 hdd_notice("AssocRsp is now at %02x%02x",
931 (unsigned int)pFTAssocRsp[0],
932 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933
934 /* We need to send the IEs to the supplicant. */
935 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
936 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700937 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800938 return;
939 }
940 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
941 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
942 wrqu.data.length = len;
943 memset(buff, 0, IW_GENERIC_IE_MAX);
944 memcpy(buff, pFTAssocRsp, len);
945 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
946
947 kfree(buff);
948}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800949
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800950/**
951 * hdd_send_ft_event() - send fast transition event
952 * @pAdapter: pointer to adapter
953 *
954 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
955 * FT events to the supplicant. At the reception of Auth2 we send the RIC
956 * followed by the auth response IEs to the supplicant.
957 * Once both are received in the supplicant, an FT event is generated
958 * to the supplicant.
959 *
960 * Return: none
961 */
962static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
963{
964 uint16_t auth_resp_len = 0;
965 uint32_t ric_ies_length = 0;
966 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
967
968#if defined(KERNEL_SUPPORT_11R_CFG80211)
969 struct cfg80211_ft_event_params ftEvent;
970 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
971 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
972 struct net_device *dev = pAdapter->dev;
973#else
974 char *buff;
975 union iwreq_data wrqu;
976 uint16_t str_len;
977#endif
978
979#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530980 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
981 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800982
983 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
984 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
985 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700986 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800987 }
988
989 ftEvent.ric_ies = ricIe;
990 ftEvent.ric_ies_len = ric_ies_length;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700991 hdd_notice("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800992
993 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
994 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
995 &auth_resp_len);
996
997 if (auth_resp_len == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700998 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800999 return;
1000 }
1001
1002 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1003
1004 ftEvent.target_ap = ftIe;
1005
Anurag Chouhan6d760662016-02-20 16:05:43 +05301006 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1007 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001008
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001009 hdd_notice("ftEvent.ies_len %zu", ftEvent.ies_len);
1010 hdd_notice("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1011 hdd_notice("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001012 ftEvent.target_ap[0], ftEvent.target_ap[1],
1013 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1014 ftEvent.target_ap[5]);
1015
1016 (void)cfg80211_ft_event(dev, &ftEvent);
1017
1018#else
1019 /* We need to send the IEs to the supplicant */
1020 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1021 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001022 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 return;
1024 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301025 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001026
1027 /* Sme needs to send the RIC IEs first */
1028 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1029 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1030 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1031 &ric_ies_length);
1032 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001033 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034 } else {
1035 wrqu.data.length = str_len + ric_ies_length;
1036 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1037 }
1038
1039 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301040 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001041 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1042 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1043 (u8 *) &buff[str_len],
1044 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1045
1046 if (auth_resp_len == 0) {
1047 kfree(buff);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001048 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 return;
1050 }
1051
1052 wrqu.data.length = str_len + auth_resp_len;
1053 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1054
1055 kfree(buff);
1056#endif
1057}
1058
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059#ifdef FEATURE_WLAN_ESE
1060/**
1061 * hdd_send_new_ap_channel_info() - send new ap channel info
1062 * @dev: pointer to net device
1063 * @pAdapter: pointer to adapter
1064 * @pCsrRoamInfo: pointer to roam info
1065 *
1066 * Send the ESE required "new AP Channel info" to the supplicant.
1067 * (This keeps the supplicant "up to date" on the current channel.)
1068 *
1069 * The current (new AP) channel information is passed in.
1070 *
1071 * Return: none
1072 */
1073static void
1074hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1075 tCsrRoamInfo *pCsrRoamInfo)
1076{
1077 union iwreq_data wrqu;
1078 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1079
1080 if (descriptor == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001081 hdd_err("pCsrRoamInfo->pBssDesc(%p)", descriptor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001082 return;
1083 }
1084 /*
1085 * Send the Channel event, the supplicant needs this to generate
1086 * the Adjacent AP report.
1087 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001088 hdd_warn("Sending up an SIOCGIWFREQ, channelId(%d)",
1089 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001090 memset(&wrqu, '\0', sizeof(wrqu));
1091 wrqu.freq.m = descriptor->channelId;
1092 wrqu.freq.e = 0;
1093 wrqu.freq.i = 0;
1094 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1095}
1096
1097#endif /* FEATURE_WLAN_ESE */
1098
1099/**
1100 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1101 * @pAdapter: pointer to adapter
1102 * @pCsrRoamInfo: pointer to roam info
1103 *
1104 * Return: none
1105 */
1106static void
1107hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1108 tCsrRoamInfo *pCsrRoamInfo)
1109{
1110 union iwreq_data wrqu;
1111 u8 *pBeaconIes;
1112 u8 currentLen = 0;
1113 char *buff;
1114 int totalIeLen = 0, currentOffset = 0, strLen;
1115
1116 memset(&wrqu, '\0', sizeof(wrqu));
1117
1118 if (0 == pCsrRoamInfo->nBeaconLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001119 hdd_warn("pCsrRoamInfo->nBeaconFrameLength = 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001120 return;
1121 }
1122 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1123 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001124 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125 return;
1126 }
1127 /* pBeaconIes needs to point to the IEs */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001128 hdd_notice("Beacon IEs is now at %02x%02x",
1129 (unsigned int)pBeaconIes[0],
1130 (unsigned int)pBeaconIes[1]);
1131 hdd_notice("Beacon IEs length = %d",
1132 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001133
1134 /* We need to send the IEs to the supplicant. */
1135 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
1136 if (buff == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001137 hdd_err("kmalloc unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001138 return;
1139 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301140 qdf_mem_zero(buff, IW_CUSTOM_MAX);
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
1170 kfree(buff);
1171}
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{
1183 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1184 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1185 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1186 union iwreq_data wrqu;
1187 int we_event;
1188 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301189 struct qdf_mac_addr peerMacAddr;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301190 QDF_STATUS qdf_status;
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)
1202 if (pCsrRoamInfo->roamSynchInProgress)
1203 /* change logging before release */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001204 hdd_info("LFR3:hdd_send_association_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001205#endif
1206 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Abhishek Singh1c676222016-05-09 14:20:28 +05301207 tSirSmeChanInfo chan_info;
1208
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001209 if (!pCsrRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001210 hdd_err("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001211 return;
1212 }
1213
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001214 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
1215 cds_incr_active_session(pAdapter->device_mode,
1216 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001217 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1218 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1219
1220#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001221 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001222 if (global_p2p_connection_status ==
1223 P2P_CLIENT_CONNECTING_STATE_1) {
1224 global_p2p_connection_status =
1225 P2P_CLIENT_CONNECTED_STATE_1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001226 hdd_err("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 } else if (global_p2p_connection_status ==
1228 P2P_CLIENT_CONNECTING_STATE_2) {
1229 global_p2p_connection_status =
1230 P2P_CLIENT_COMPLETED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001231 hdd_err("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001232 }
1233 }
1234#endif
1235 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1236 MAC_ADDRESS_STR "\n",
1237 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1238 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1239 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1240
1241 /*
1242 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1243 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001244 * fFTEnable is true.
1245 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 if ((pRoamProfile->AuthType.authType[0] ==
1248 eCSR_AUTH_TYPE_FT_RSN_PSK)
1249 || (pRoamProfile->AuthType.authType[0] ==
1250 eCSR_AUTH_TYPE_FT_RSN)
1251#ifdef FEATURE_WLAN_ESE
1252 || (pRoamProfile->AuthType.authType[0] ==
1253 eCSR_AUTH_TYPE_CCKM_RSN)
1254 || (pRoamProfile->AuthType.authType[0] ==
1255 eCSR_AUTH_TYPE_CCKM_WPA)
1256#endif
1257 ) {
1258 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1259 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301260 qdf_copy_macaddr(&peerMacAddr,
1261 &pHddStaCtx->conn_info.bssId);
1262 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1263 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1264 chan_info.info = pCsrRoamInfo->chan_info.info;
1265 chan_info.band_center_freq1 =
1266 pCsrRoamInfo->chan_info.band_center_freq1;
1267 chan_info.band_center_freq2 =
1268 pCsrRoamInfo->chan_info.band_center_freq2;
1269 chan_info.reg_info_1 =
1270 pCsrRoamInfo->chan_info.reg_info_1;
1271 chan_info.reg_info_2 =
1272 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301273
1274 qdf_status = hdd_add_peer_object(pAdapter->hdd_vdev,
1275 pAdapter->device_mode,
1276 peerMacAddr.bytes);
1277 if (QDF_IS_STATUS_ERROR(qdf_status))
1278 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1279 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1280
Abhishek Singh1c676222016-05-09 14:20:28 +05301281 /* send peer status indication to oem app */
1282 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
1283 ePeerConnected,
1284 pCsrRoamInfo->
1285 timingMeasCap,
1286 pAdapter->sessionId,
1287 &chan_info,
1288 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001289 /* Update tdls module about connection event */
1290 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001291
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001292#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001293#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001294 /* start timer in sta/p2p_cli */
1295 spin_lock_bh(&pHddCtx->bus_bw_lock);
1296 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1297 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001298 cdp_get_intra_bss_fwd_pkts_count(
1299 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301300 &pAdapter->prev_fwd_tx_packets,
1301 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1303 hdd_start_bus_bw_compute_timer(pAdapter);
1304#endif
1305#endif
1306 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1307 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001308 cds_update_connection_info(pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001309 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
1310 ETH_ALEN);
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301311 hdd_err("wlan: new IBSS connection to " MAC_ADDRESS_STR,
1312 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301313
1314 qdf_status = hdd_add_peer_object(pAdapter->hdd_vdev,
1315 QDF_IBSS_MODE,
1316 pCsrRoamInfo->bssid.bytes);
1317 if (QDF_IS_STATUS_ERROR(qdf_status))
1318 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1319 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001320 } else { /* Not Associated */
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301321 hdd_err("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001322 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301323 cds_decr_session_set_pcl(pAdapter->device_mode,
1324 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001325
1326#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1327 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1328#endif
1329
Abhishek Singh1c676222016-05-09 14:20:28 +05301330 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1331 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301332 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 &pHddStaCtx->conn_info.bssId);
1334
1335 /* send peer status indication to oem app */
1336 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301337 ePeerDisconnected, 0,
1338 pAdapter->sessionId,
1339 NULL,
1340 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301342
1343 qdf_status = hdd_remove_peer_object(pAdapter->hdd_vdev,
1344 peerMacAddr.bytes);
1345 if (QDF_IS_STATUS_ERROR(qdf_status))
1346 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1347 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1348
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001349 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001350 /* Update tdls module about the disconnection event */
1351 wlan_hdd_tdls_notify_disconnect(pAdapter);
1352
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001353#ifdef MSM_PLATFORM
1354 /* stop timer in sta/p2p_cli */
1355 spin_lock_bh(&pHddCtx->bus_bw_lock);
1356 pAdapter->prev_tx_packets = 0;
1357 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301358 pAdapter->prev_fwd_tx_packets = 0;
1359 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001360 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1361 hdd_stop_bus_bw_compute_timer(pAdapter);
1362#endif
1363 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001364 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001365 /* Send SCC/MCC Switching event to IPA */
1366 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1367
1368 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001369 /* During the WLAN uninitialization,supplicant is stopped before the
1370 * driver so not sending the status of the connection to supplicant
1371 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001372 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001373 wireless_send_event(dev, we_event, &wrqu, msg);
1374#ifdef FEATURE_WLAN_ESE
1375 if (eConnectionState_Associated ==
1376 pHddStaCtx->conn_info.connState) {
1377 if ((pRoamProfile->AuthType.authType[0] ==
1378 eCSR_AUTH_TYPE_CCKM_RSN) ||
1379 (pRoamProfile->AuthType.authType[0] ==
1380 eCSR_AUTH_TYPE_CCKM_WPA))
1381 hdd_send_new_ap_channel_info(dev, pAdapter,
1382 pCsrRoamInfo);
1383 }
1384#endif
1385 }
1386}
1387
1388/**
1389 * hdd_conn_remove_connect_info() - remove connection info
1390 * @pHddStaCtx: pointer to global HDD station context
1391 * @pCsrRoamInfo: pointer to roam info
1392 *
1393 * Return: none
1394 */
1395static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1396{
1397 /* Remove staId, bssId and peerMacAddress */
1398 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301399 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1400 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301401 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001402
1403 /* Clear all security settings */
1404 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1405 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1406 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1407
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301408 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1409 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411 pHddStaCtx->conn_info.proxyARPService = 0;
1412
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301413 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001414}
1415
1416/**
1417 * hdd_roam_deregister_sta() - deregister station
1418 * @pAdapter: pointer to adapter
1419 * @staId: station identifier
1420 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301421 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001422 */
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001423QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001424{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301425 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001426 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1427
1428 if (eConnectionState_IbssDisconnected ==
1429 pHddStaCtx->conn_info.connState) {
1430 /*
1431 * Do not set the carrier off when the last peer leaves.
1432 * We will set the carrier off while stopping the IBSS.
1433 */
1434 }
1435
Leo Changfdb45c32016-10-28 11:09:23 -07001436 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
1437 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301438 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001439 hdd_err("cdp_peer_clear() failed for staID %d. Status(%d) [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301440 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001441 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301442 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001443}
1444
1445/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301446 * hdd_print_bss_info() - print bss info
1447 * @hdd_sta_ctx: pointer to hdd station context
1448 *
1449 * Return: None
1450 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001451static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301452{
1453 uint32_t *cap_info;
1454
1455 hdd_info("WIFI DATA LOGGER");
1456 hdd_info("channel: %d",
1457 hdd_sta_ctx->conn_info.freq);
1458 hdd_info("dot11mode: %d",
1459 hdd_sta_ctx->conn_info.dot11Mode);
1460 hdd_info("AKM: %d",
1461 hdd_sta_ctx->conn_info.authType);
1462 hdd_info("ssid: %.*s",
1463 hdd_sta_ctx->conn_info.SSID.SSID.length,
1464 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1465 hdd_info("roam count: %d",
1466 hdd_sta_ctx->conn_info.roam_count);
1467 hdd_info("ant_info: %d",
1468 hdd_sta_ctx->conn_info.txrate.nss);
1469 hdd_info("datarate legacy %d",
1470 hdd_sta_ctx->conn_info.txrate.legacy);
1471 hdd_info("datarate mcs: %d",
1472 hdd_sta_ctx->conn_info.txrate.mcs);
1473 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1474 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1475 hdd_info("ht caps: %x", *cap_info);
1476 }
1477 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1478 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1479 hdd_info("vht caps: %x", *cap_info);
1480 }
1481 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1482 hdd_info("hs20 info: %x",
1483 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1484 hdd_info("signal: %d",
1485 hdd_sta_ctx->conn_info.signal);
1486 hdd_info("noise: %d",
1487 hdd_sta_ctx->conn_info.noise);
1488}
1489
1490/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001491 * hdd_dis_connect_handler() - disconnect event handler
1492 * @pAdapter: pointer to adapter
1493 * @pRoamInfo: pointer to roam info
1494 * @roamId: roam identifier
1495 * @roamStatus: roam status
1496 * @roamResult: roam result
1497 *
1498 * This function handles disconnect event:
1499 * 1. Disable transmit queues;
1500 * 2. Clean up internal connection states and data structures;
1501 * 3. Send disconnect indication to supplicant.
1502 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301503 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001504 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301505static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001506 tCsrRoamInfo *pRoamInfo,
1507 uint32_t roamId,
1508 eRoamCmdStatus roamStatus,
1509 eCsrRoamResult roamResult)
1510{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301511 QDF_STATUS status = QDF_STATUS_SUCCESS;
1512 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513 struct net_device *dev = pAdapter->dev;
1514 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1515 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1516 uint8_t sta_id;
1517 bool sendDisconInd = true;
1518
1519 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001520 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301521 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001522 }
1523 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001524 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001525 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1526 WLAN_CONTROL_PATH);
1527
1528 if (hdd_ipa_is_enabled(pHddCtx))
1529 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001530 HDD_IPA_STA_DISCONNECT,
1531 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001532
1533#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1534 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1535#endif
1536
Nirav Shah1da77682016-05-03 20:16:39 +05301537 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1538 pAdapter->sessionId,
1539 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001540
1541 /* HDD has initiated disconnect, do not send disconnect indication
1542 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301543 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001544 * to cfg80211_disconnected.
1545 */
1546 if ((eConnectionState_Disconnecting ==
1547 pHddStaCtx->conn_info.connState) ||
1548 (eConnectionState_NotConnected ==
1549 pHddStaCtx->conn_info.connState)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001550 hdd_notice("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001551 sendDisconInd = false;
1552 }
1553
1554 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1555 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001556 hdd_conn_set_connection_state(pAdapter,
1557 eConnectionState_Disconnecting);
1558 }
1559
1560 hdd_clear_roam_profile_ie(pAdapter);
1561 hdd_wmm_init(pAdapter);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301562 hdd_info("Invoking packetdump deregistration API");
1563 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001564
1565 /* indicate 'disconnect' status to wpa_supplicant... */
1566 hdd_send_association_event(dev, pRoamInfo);
1567 /* indicate disconnected event to nl80211 */
1568 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1569 /*
1570 * Only send indication to kernel if not initiated
1571 * by kernel
1572 */
1573 if (sendDisconInd) {
1574 /*
1575 * To avoid wpa_supplicant sending "HANGED" CMD
1576 * to ICS UI.
1577 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001578 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1579 if (pRoamInfo->reasonCode ==
1580 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1581 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301582 wlan_hdd_cfg80211_indicate_disconnect(
1583 dev, false,
1584 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001585 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301586 wlan_hdd_cfg80211_indicate_disconnect(
1587 dev, false,
1588 WLAN_REASON_UNSPECIFIED
1589 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001590 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001591
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301592 hdd_info("sent disconnected event to nl80211, reason code %d",
1593 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1594 pRoamInfo->reasonCode :
1595 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001596 }
1597 /*
1598 * During the WLAN uninitialization,supplicant is stopped
1599 * before the driver so not sending the status of the
1600 * connection to supplicant.
1601 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001602 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001604 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001605 if (global_p2p_connection_status ==
1606 P2P_CLIENT_CONNECTED_STATE_1) {
1607 global_p2p_connection_status =
1608 P2P_CLIENT_DISCONNECTED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001609 hdd_err("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001610 } else if (global_p2p_connection_status ==
1611 P2P_CLIENT_COMPLETED_STATE) {
1612 global_p2p_connection_status =
1613 P2P_NOT_ACTIVE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001614 hdd_err("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001615 }
1616 }
1617#endif
1618
1619 }
1620 }
1621
1622 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001624 if (hdd_remove_beacon_filter(pAdapter) != 0)
1625 hdd_err("hdd_remove_beacon_filter() failed");
1626
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001627 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301628 uint8_t i;
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001629 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001630 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301631 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301632 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1633 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301634 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001635 }
1636 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301637 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001638 for (i = 0; i < MAX_PEERS; i++) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301639 if (0 == pHddStaCtx->conn_info.staId[i])
1640 continue;
1641 sta_id = pHddStaCtx->conn_info.staId[i];
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001642 hdd_info("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301643 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301644 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001645 hdd_err("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301646 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301647 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301648 }
1649 /* set the staid and peer mac as 0, all other
1650 * reset are done in hdd_connRemoveConnectInfo.
1651 */
1652 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301653 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301654 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301655 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1656 pHddCtx->sta_to_adapter[sta_id] = NULL;
1657 }
1658 } else {
1659 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhc9941602016-08-09 16:06:22 +05301660
1661 /* clear scan cache for Link Lost */
1662 if (pRoamInfo && !pRoamInfo->reasonCode &&
1663 (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult)) {
1664 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1665 pHddStaCtx->conn_info.bssId.bytes);
1666 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1667 pHddStaCtx->conn_info.bssId.bytes);
1668 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301669 /* We should clear all sta register with TL,
1670 * for now, only one.
1671 */
1672 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301673 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001674 hdd_err("hdd_roam_deregister_sta() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301675 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301676 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301677 }
1678 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 /* Clear saved connection information in HDD */
1681 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
1683#ifdef WLAN_FEATURE_GTK_OFFLOAD
Krunal Sonibe766b02016-03-10 13:00:44 -08001684 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1685 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001686 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1687 sizeof(tSirGtkOffloadParams));
1688 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
1689 }
1690#endif
1691
1692#ifdef FEATURE_WLAN_TDLS
1693 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1694 wlan_hdd_tdls_disconnection_callback(pAdapter);
1695#endif
1696
Krunal Sonibe766b02016-03-10 13:00:44 -08001697 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1698 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1700 (pAdapter),
1701 pAdapter->sessionId);
1702 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301703 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001704 /* Unblock anyone waiting for disconnect to complete */
1705 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301706 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001707 return status;
1708}
1709
1710/**
1711 * hdd_set_peer_authorized_event() - set peer_authorized_event
1712 * @vdev_id: vdevid
1713 *
1714 * Return: None
1715 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001716static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001717{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301718 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001719 hdd_adapter_t *adapter = NULL;
1720
1721 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1722 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001723 hdd_err("Invalid vdev_id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001724 }
1725 complete(&adapter->sta_authorized_event);
1726}
1727
1728/**
1729 * hdd_change_peer_state() - change peer state
1730 * @pAdapter: HDD adapter
1731 * @sta_state: peer state
1732 * @roam_synch_in_progress: roam synch in progress
1733 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301734 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001735 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301736QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001737 uint8_t sta_id,
1738 enum ol_txrx_peer_state sta_state,
1739 bool roam_synch_in_progress)
1740{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301741 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001742 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001743 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1744 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1745 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001746
1747 if (!pdev) {
1748 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301749 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 }
1751
1752 if (sta_id >= WLAN_MAX_STA_COUNT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001753 hdd_err("Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301754 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001755 }
1756
Leo Changfdb45c32016-10-28 11:09:23 -07001757 peer = cdp_peer_find_by_local_id(soc, pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001758 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301759 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760
Leo Changfdb45c32016-10-28 11:09:23 -07001761 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001762 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001763 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001764 return QDF_STATUS_E_FAULT;
1765 }
1766
Leo Changfdb45c32016-10-28 11:09:23 -07001767 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301768 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001769 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301770 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001771 }
1772#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1773 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301774 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001775#endif
1776
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001777 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1779 /* make sure event is reset */
1780 INIT_COMPLETION(pAdapter->sta_authorized_event);
1781#endif
1782
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001783 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001784 hdd_set_peer_authorized_event,
1785 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301786 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001787 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301788 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001789 }
1790
Krunal Sonibe766b02016-03-10 13:00:44 -08001791 if (pAdapter->device_mode == QDF_STA_MODE ||
1792 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001793#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001794 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001795 unsigned long rc;
1796
1797 /* wait for event from firmware to set the event */
1798 rc = wait_for_completion_timeout(
1799 &pAdapter->sta_authorized_event,
1800 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1801 if (!rc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001802 hdd_notice("timeout waiting for sta_authorized_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001803 }
Leo Changfdb45c32016-10-28 11:09:23 -07001804 vdev = cdp_peer_get_vdev(soc, peer);
1805 cdp_fc_vdev_unpause(soc, vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001806 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807#endif
1808 }
1809 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301810 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001811}
1812
1813/**
1814 * hdd_roam_register_sta() - register station
1815 * @pAdapter: pointer to adapter
1816 * @pRoamInfo: pointer to roam info
1817 * @staId: station identifier
1818 * @pPeerMacAddress: peer MAC address
1819 * @pBssDesc: pointer to BSS description
1820 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301821 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001822 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001823QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001824 tCsrRoamInfo *pRoamInfo,
1825 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301826 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001827 tSirBssDescription *pBssDesc)
1828{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301829 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 struct ol_txrx_desc_type staDesc = { 0 };
1831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001832 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001833 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1834 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001835
1836 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838
1839 /* Get the Station ID from the one saved during the association */
1840 staDesc.sta_id = staId;
1841
1842 /* set the QoS field appropriately */
1843 if (hdd_wmm_is_active(pAdapter))
1844 staDesc.is_qos_enabled = 1;
1845 else
1846 staDesc.is_qos_enabled = 0;
1847
1848#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001849 hdd_notice("WAPI STA Registered: %d",
1850 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001851 if (pAdapter->wapi_info.fIsWapiSta)
1852 staDesc.is_wapi_supported = 1;
1853 else
1854 staDesc.is_wapi_supported = 0;
1855#endif /* FEATURE_WLAN_WAPI */
1856
Dhanashri Atre50141c52016-04-07 13:15:29 -07001857 /* Register the vdev transmit and receive functions */
1858 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1859 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001860
1861 pAdapter->txrx_vdev = cdp_get_vdev_from_vdev_id(soc, pdev,
1862 pAdapter->sessionId);
1863 if (!pAdapter->txrx_vdev) {
1864 hdd_err("%s find vdev fail", __func__);
1865 return QDF_STATUS_E_FAILURE;
1866 }
1867
1868 txrx_ops.tx.tx = NULL;
1869 cdp_vdev_register(soc, pAdapter->txrx_vdev, pAdapter, &txrx_ops);
1870 if (!txrx_ops.tx.tx) {
1871 hdd_err("%s vdev register fail", __func__);
1872 return QDF_STATUS_E_FAILURE;
1873 }
1874
Dhanashri Atre50141c52016-04-07 13:15:29 -07001875 pAdapter->tx_fn = txrx_ops.tx.tx;
Leo Changfdb45c32016-10-28 11:09:23 -07001876 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301877 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001878 hdd_warn("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001879 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301880 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001881 }
1882
1883 if (!pRoamInfo->fAuthRequired) {
1884 /*
1885 * Connections that do not need Upper layer auth, transition
1886 * TLSHIM directly to 'Authenticated' state
1887 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301888 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001889 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001890 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001891#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1892 pRoamInfo->roamSynchInProgress
1893#else
1894 false
1895#endif
1896 );
1897
1898 hdd_conn_set_authenticated(pAdapter, true);
1899 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001900 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001901 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301902 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001903 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001904 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001905#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1906 pRoamInfo->roamSynchInProgress
1907#else
1908 false
1909#endif
1910 );
1911 hdd_conn_set_authenticated(pAdapter, false);
1912 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301913 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001914}
1915
1916/**
1917 * hdd_send_re_assoc_event() - send reassoc event
1918 * @dev: pointer to net device
1919 * @pAdapter: pointer to adapter
1920 * @pCsrRoamInfo: pointer to roam info
1921 * @reqRsnIe: pointer to RSN Information element
1922 * @reqRsnLength: length of RSN IE
1923 *
1924 * Return: none
1925 */
1926static void hdd_send_re_assoc_event(struct net_device *dev,
1927 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1928 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1929{
1930 unsigned int len = 0;
1931 u8 *pFTAssocRsp = NULL;
1932 uint8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Naveen Rawat14298b92015-11-25 16:27:41 -08001933 uint8_t *assoc_req_ies = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001934 uint32_t rspRsnLength = 0;
1935 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001936 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1937 uint8_t *buf_ptr, ssid_ie_len;
1938 struct cfg80211_bss *bss = NULL;
1939 uint8_t *final_req_ie = NULL;
1940 tCsrRoamConnectedProfile roam_profile;
1941 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1942
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001943 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001945 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001946 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001947 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001948 }
1949
Naveen Rawat14298b92015-11-25 16:27:41 -08001950 if (!assoc_req_ies) {
1951 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001952 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001953 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001955 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001956 goto done;
1957 }
1958
1959 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001960 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 goto done;
1962 }
1963
1964 pFTAssocRsp =
1965 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1966 pCsrRoamInfo->nAssocReqLength);
1967 if (pFTAssocRsp == NULL)
1968 goto done;
1969
1970 /* pFTAssocRsp needs to point to the IEs */
1971 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001972 hdd_info("AssocRsp is now at %02x%02x",
1973 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001974
1975 /*
1976 * Active session count is decremented upon disconnection, but during
1977 * roaming, there is no disconnect indication and hence active session
1978 * count is not decremented.
1979 * After roaming is completed, active session count is incremented
1980 * as a part of connect indication but effectively after roaming the
1981 * active session count should still be the same and hence upon
1982 * successful reassoc decrement the active session count here.
1983 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001984 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301985 cds_decr_session_set_pcl(pAdapter->device_mode,
1986 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987
1988 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
1989 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1990 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301991 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1992 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001993
1994 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1995 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001996 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
1997 &roam_profile);
1998 bss = cfg80211_get_bss(pAdapter->wdev.wiphy, chan,
1999 pCsrRoamInfo->bssid.bytes,
2000 &roam_profile.SSID.ssId[0], roam_profile.SSID.length,
Ryan Hsu535d16a2016-01-18 16:45:12 -08002001#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002002 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Ryan Hsu535d16a2016-01-18 16:45:12 -08002003#else
2004 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
2005#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006
2007 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002008 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002009 buf_ptr = buf_ssid_ie;
2010 *buf_ptr = SIR_MAC_SSID_EID;
2011 buf_ptr++;
2012 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2013 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302014 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002015 roam_profile.SSID.length);
2016 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08002017 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302018 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002019 buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 final_req_ie = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
2021 if (final_req_ie == NULL)
2022 goto done;
2023 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002025 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302026 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2027 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2028 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002029 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002030 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302031 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002032 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002033 cfg80211_roamed_bss(dev, bss,
2034 final_req_ie, (ssid_ie_len + reqRsnLength),
2035 rspRsnIe, rspRsnLength, GFP_KERNEL);
2036
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302037 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002038 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2039 pCsrRoamInfo->nAssocReqLength);
2040
2041 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302042 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002043 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2044
Prakash Dhavali989127d2016-11-29 14:56:44 +05302045 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002046 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2047 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002048 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002050 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002051 if (final_req_ie)
2052 kfree(final_req_ie);
2053 kfree(rspRsnIe);
Naveen Rawat14298b92015-11-25 16:27:41 -08002054 kfree(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002055}
2056
2057/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302058 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002059 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302060 *
2061 * Return: roam sync status if roaming offloaded else false
2062 */
2063#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002064bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302065{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002066 if (roaminfo)
2067 return roaminfo->roamSynchInProgress;
2068 else
2069 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302070}
2071#endif
2072
2073
2074/**
2075 * hdd_change_sta_state_authenticated()-
2076 * This function changes STA state to authenticated
2077 * @adapter: pointer to the adapter structure.
2078 * @roaminfo: pointer to the RoamInfo structure.
2079 *
2080 * This is called from hdd_RoamSetKeyCompleteHandler
2081 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2082 *
2083 * Return: 0 on success and errno on failure
2084 */
2085static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2086 tCsrRoamInfo *roaminfo)
2087{
2088 int ret;
Dustin Brownf660fb42016-09-09 12:04:00 -07002089 uint32_t timeout;
Govind Singhedc5cda2015-10-23 17:11:35 +05302090 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002091 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302092
Dustin Brownf660fb42016-09-09 12:04:00 -07002093 timeout = hddstactx->hdd_ReassocScenario ?
2094 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002095 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002096
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002097 hdd_info("Changing TL state to AUTHENTICATED for StaId= %d",
2098 hddstactx->conn_info.staId[0]);
Govind Singhedc5cda2015-10-23 17:11:35 +05302099
2100 /* Connections that do not need Upper layer authentication,
2101 * transition TL to 'Authenticated' state after the keys are set
2102 */
2103 ret = hdd_change_peer_state(adapter,
2104 hddstactx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002105 OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302106 hdd_is_roam_sync_in_progress(roaminfo));
2107 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002108 if ((QDF_STA_MODE == adapter->device_mode) ||
2109 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302110 sme_ps_enable_auto_ps_timer(
2111 WLAN_HDD_GET_HAL_CTX(adapter),
2112 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002113 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302114 }
2115
2116 return ret;
2117}
2118
2119/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002120 * hdd_roam_set_key_complete_handler() - Update the security parameters
2121 * @pAdapter: pointer to adapter
2122 * @pRoamInfo: pointer to roam info
2123 * @roamId: roam id
2124 * @roamStatus: roam status
2125 * @roamResult: roam result
2126 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302127 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002128 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302129static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002130 tCsrRoamInfo *pRoamInfo,
2131 uint32_t roamId,
2132 eRoamCmdStatus roamStatus,
2133 eCsrRoamResult roamResult)
2134{
2135 eCsrEncryptionType connectedCipherAlgo;
2136 bool fConnected = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302137 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002138 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302139 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(pAdapter);
2140 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
2141
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 ENTER();
2143
2144 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002145 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302146 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002147 }
2148 /*
2149 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2150 * then go to 'authenticated'. For all other authentication types
2151 * (those that do not require upper layer authentication) we can put TL
2152 * directly into 'authenticated' state.
2153 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002154 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002155 MAC_ADDRESS_STR, roamStatus, roamResult,
2156 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2157
2158 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2159 &connectedCipherAlgo);
2160 if (fConnected) {
Krunal Sonibe766b02016-03-10 13:00:44 -08002161 if (QDF_IBSS_MODE == pAdapter->device_mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002162 uint8_t staId;
2163
Anurag Chouhanc5548422016-02-24 18:33:27 +05302164 if (qdf_is_macaddr_broadcast(&pRoamInfo->peerMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 pHddStaCtx->roam_info.roamingState =
2166 HDD_ROAM_STATE_NONE;
2167 } else {
Deepak Dhamdhere5872c8c2016-06-02 15:51:47 -07002168 qdf_status = hdd_get_peer_sta_id(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 pHddStaCtx,
2170 &pRoamInfo->peerMac,
2171 &staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302172 if (QDF_STATUS_SUCCESS == qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002173 hdd_info("WLAN TL STA Ptk Installed for STAID=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002174 staId);
2175 pHddStaCtx->roam_info.roamingState =
2176 HDD_ROAM_STATE_NONE;
2177 }
2178 }
2179 } else {
2180 /*
2181 * TODO: Considering getting a state machine in
Govind Singhedc5cda2015-10-23 17:11:35 +05302182 * HDD later.This routine is invoked twice.
2183 * 1)set PTK 2)set GTK.The following if
2184 * statement will be TRUE when setting GTK.
2185 * At this time we don't handle the state in detail.
2186 * Related CR: 174048 - TL not in authenticated state
Jeff Johnson5a062372017-01-12 09:51:25 -08002187 */
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302188 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302189 pHddStaCtx->conn_info.gtk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302190 /*
2191 * PTK exchange happens in preauthentication
2192 * itself if key_mgmt is FT-PSK, ptk_installed
2193 * was false as there is no set PTK after
2194 * roaming. STA TL state moves to authenticated
2195 * only if ptk_installed is true. So, make
2196 * ptk_installed to true in case of 11R roaming.
2197 */
2198 if (csr_neighbor_roam_is11r_assoc(mac_ctx,
2199 pAdapter->sessionId))
2200 pHddStaCtx->conn_info.ptk_installed =
2201 true;
2202 } else {
Govind Singhedc5cda2015-10-23 17:11:35 +05302203 pHddStaCtx->conn_info.ptk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302204 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302205
2206 /* In WPA case move STA to authenticated when
2207 * ptk is installed.Earlier in WEP case STA
2208 * was moved to AUTHENTICATED prior to setting
2209 * the unicast key and it was resulting in sending
2210 * few un-encrypted packet. Now in WEP case
2211 * STA state will be moved to AUTHENTICATED
2212 * after we set the unicast and broadcast key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002213 */
Govind Singhedc5cda2015-10-23 17:11:35 +05302214 if ((pHddStaCtx->conn_info.ucEncryptionType ==
2215 eCSR_ENCRYPT_TYPE_WEP40) ||
2216 (pHddStaCtx->conn_info.ucEncryptionType ==
2217 eCSR_ENCRYPT_TYPE_WEP104) ||
2218 (pHddStaCtx->conn_info.ucEncryptionType ==
2219 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2220 (pHddStaCtx->conn_info.ucEncryptionType ==
2221 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2222 if (pHddStaCtx->conn_info.gtk_installed &&
2223 pHddStaCtx->conn_info.ptk_installed)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302224 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302225 hdd_change_sta_state_authenticated(pAdapter,
2226 pRoamInfo);
2227 } else if (pHddStaCtx->conn_info.ptk_installed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302228 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302229 hdd_change_sta_state_authenticated(pAdapter,
2230 pRoamInfo);
2231 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232
Govind Singhedc5cda2015-10-23 17:11:35 +05302233 if (pHddStaCtx->conn_info.gtk_installed &&
2234 pHddStaCtx->conn_info.ptk_installed) {
2235 pHddStaCtx->conn_info.gtk_installed = false;
2236 pHddStaCtx->conn_info.ptk_installed = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002237 }
2238
2239 pHddStaCtx->roam_info.roamingState =
Govind Singhedc5cda2015-10-23 17:11:35 +05302240 HDD_ROAM_STATE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002241 }
2242 } else {
2243 /*
2244 * possible disassoc after issuing set key and waiting
2245 * set key complete.
2246 */
2247 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2248 }
2249
2250 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302251 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002252}
2253
2254/**
2255 * hdd_perform_roam_set_key_complete() - perform set key complete
2256 * @pAdapter: pointer to adapter
2257 *
2258 * Return: none
2259 */
2260void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2261{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302262 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002263 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2264 tCsrRoamInfo roamInfo;
2265 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302266 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302267 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302268 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302269 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002270
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302271 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002272 hdd_roam_set_key_complete_handler(pAdapter,
2273 &roamInfo,
2274 pHddStaCtx->roam_info.roamId,
2275 pHddStaCtx->roam_info.roamStatus,
2276 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302277 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002278 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279
2280 pHddStaCtx->roam_info.deferKeyComplete = false;
2281}
2282
2283/**
2284 * hdd_association_completion_handler() - association completion handler
2285 * @pAdapter: pointer to adapter
2286 * @pRoamInfo: pointer to roam info
2287 * @roamId: roam id
2288 * @roamStatus: roam status
2289 * @roamResult: roam result
2290 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302291 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002292 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302293static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002294 tCsrRoamInfo *pRoamInfo,
2295 uint32_t roamId,
2296 eRoamCmdStatus roamStatus,
2297 eCsrRoamResult roamResult)
2298{
2299 struct net_device *dev = pAdapter->dev;
2300 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2301 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302302 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2304 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 bool hddDisconInProgress = false;
2307 unsigned long rc;
2308
2309 if (!pHddCtx) {
2310 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302311 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002312 }
2313
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302314 /* validate config */
2315 if (!pHddCtx->config) {
2316 hdd_err("config is NULL");
2317 return QDF_STATUS_E_NULL_VALUE;
2318 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002319 /* HDD has initiated disconnect, do not send connect result indication
2320 * to kernel as it will be handled by __cfg80211_disconnect.
2321 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302322 if (((eConnectionState_Disconnecting ==
2323 pHddStaCtx->conn_info.connState) ||
2324 (eConnectionState_NotConnected ==
2325 pHddStaCtx->conn_info.connState)) &&
2326 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2327 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002328 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 hddDisconInProgress = true;
2330 }
2331
2332 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2333 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002334 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302335 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002336 }
2337 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002338 hdd_conn_set_connection_state(pAdapter,
2339 eConnectionState_Associated);
2340 }
2341 /* Save the connection info from CSR... */
2342 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2343 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002344
2345 if (hdd_add_beacon_filter(pAdapter) != 0)
2346 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002347#ifdef FEATURE_WLAN_WAPI
2348 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2349 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2350 || pRoamInfo->u.pConnectedProfile->AuthType ==
2351 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2352 pAdapter->wapi_info.fIsWapiSta = 1;
2353 } else {
2354 pAdapter->wapi_info.fIsWapiSta = 0;
2355 }
2356#endif /* FEATURE_WLAN_WAPI */
2357
2358 /* Indicate 'connect' status to user space */
2359 hdd_send_association_event(dev, pRoamInfo);
2360
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002361 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002362 if (pHddCtx->miracast_value)
2363 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2364 }
2365
2366 /* Initialize the Linkup event completion variable */
2367 INIT_COMPLETION(pAdapter->linkup_event_var);
2368
2369 /*
2370 * Sometimes Switching ON the Carrier is taking time to activate
2371 * the device properly. Before allowing any packet to go up to
2372 * the application, device activation has to be ensured for
2373 * proper queue mapping by the kernel. we have registered net
2374 * device notifier for device change notification. With this we
2375 * will come to know that the device is getting
2376 * activated properly.
2377 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002378 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002379 /*
2380 * Enable Linkup Event Servicing which allows the net
2381 * device notifier to set the linkup event variable.
2382 */
2383 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002384
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002385 /* Switch on the Carrier to activate the device */
2386 wlan_hdd_netif_queue_control(pAdapter,
2387 WLAN_NETIF_CARRIER_ON,
2388 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002389
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002390 /*
2391 * Wait for the Link to up to ensure all the queues
2392 * are set properly by the kernel.
2393 */
2394 rc = wait_for_completion_timeout(
2395 &pAdapter->linkup_event_var,
2396 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2397 );
2398 if (!rc)
2399 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002401 /*
2402 * Disable Linkup Event Servicing - no more service
2403 * required from the net device notifier call.
2404 */
2405 pAdapter->isLinkUpSvcNeeded = false;
2406 } else {
2407 pHddStaCtx->ft_carrier_on = false;
2408 ft_carrier_on = true;
2409 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2411 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2412 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002413 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002414
2415 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2416
2417 if (hdd_ipa_is_enabled(pHddCtx))
2418 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002419 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002420 pRoamInfo->bssid.bytes);
2421
2422#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2423 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2424#endif
2425
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302426 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002427 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002428
Nirav Shah1da77682016-05-03 20:16:39 +05302429 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2430 pAdapter->sessionId,
2431 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2432
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002433 /*
2434 * For reassoc, the station is already registered, all we need
2435 * is to change the state of the STA in TL.
2436 * If authentication is required (WPA/WPA2/DWEP), change TL to
2437 * CONNECTED instead of AUTHENTICATED.
2438 */
2439 if (!pRoamInfo->fReassocReq) {
2440 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002441 u8 *pFTAssocRsp = NULL;
2442 unsigned int assocRsplen = 0;
2443 u8 *pFTAssocReq = NULL;
2444 unsigned int assocReqlen = 0;
2445 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2447 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2448
2449 /* add bss_id to cfg80211 data base */
2450 bss =
2451 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2452 pRoamInfo);
2453 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302454 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 wlan_hdd_netif_queue_control(pAdapter,
2456 WLAN_NETIF_CARRIER_OFF,
2457 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302458 if (!hddDisconInProgress) {
2459 /*
2460 * Here driver was not able to add bss
2461 * in cfg80211 database this can happen
2462 * if connected channel is not valid,
2463 * i.e reg domain was changed during
2464 * connection. Queue disconnect for the
2465 * session if disconnect is not in
2466 * progress.
2467 */
2468 hdd_err("Disconnecting...");
2469 sme_roam_disconnect(
2470 WLAN_HDD_GET_HAL_CTX(pAdapter),
2471 pAdapter->sessionId,
2472 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2473 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302474 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002476 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2477 eCSR_AUTH_TYPE_FT_RSN
2478 || pRoamInfo->u.pConnectedProfile->AuthType ==
2479 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2480
2481 /* Association Response */
2482 pFTAssocRsp =
2483 (u8 *) (pRoamInfo->pbFrames +
2484 pRoamInfo->nBeaconLength +
2485 pRoamInfo->nAssocReqLength);
2486 if (pFTAssocRsp != NULL) {
2487 /*
2488 * pFTAssocRsp needs to point to the IEs
2489 */
2490 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002491 hdd_info("AssocRsp is now at %02x%02x",
2492 (unsigned int)pFTAssocRsp[0],
2493 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002494 assocRsplen =
2495 pRoamInfo->nAssocRspLength -
2496 FT_ASSOC_RSP_IES_OFFSET;
2497 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002498 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002499 assocRsplen = 0;
2500 }
2501
2502 /* Association Request */
2503 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2504 pRoamInfo->nBeaconLength);
2505 if (pFTAssocReq != NULL) {
2506 if (!ft_carrier_on) {
2507 /*
2508 * pFTAssocReq needs to point to
2509 * the IEs
2510 */
2511 pFTAssocReq +=
2512 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002513 hdd_info("pFTAssocReq is now at %02x%02x",
2514 (unsigned int)
2515 pFTAssocReq[0],
2516 (unsigned int)
2517 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002518 assocReqlen =
2519 pRoamInfo->nAssocReqLength -
2520 FT_ASSOC_REQ_IES_OFFSET;
2521 } else {
2522 /*
2523 * This should contain only the
2524 * FTIEs
2525 */
2526 assocReqlen =
2527 pRoamInfo->nAssocReqLength;
2528 }
2529 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002530 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002531 assocReqlen = 0;
2532 }
2533
2534 if (ft_carrier_on) {
2535 if (!hddDisconInProgress) {
2536 /*
2537 * After roaming is completed,
2538 * active session count is
2539 * incremented as a part of
2540 * connect indication but
2541 * effectively the active
2542 * session count should still
2543 * be the same and hence upon
2544 * successful reassoc
2545 * decrement the active session
2546 * count here.
2547 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002548 if (!hdd_is_roam_sync_in_progress
2549 (pRoamInfo))
2550 cds_decr_session_set_pcl
2551 (pAdapter->device_mode,
2552 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002553 hdd_info("ft_carrier_on is %d, sending roamed indication",
2554 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002555 chan =
2556 ieee80211_get_channel
2557 (pAdapter->wdev.wiphy,
2558 (int)pRoamInfo->pBssDesc->
2559 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002560 hdd_info(
2561 "assocReqlen %d assocRsplen %d",
2562 assocReqlen,
2563 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002564
2565 hdd_notice(
2566 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302567 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302568 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302569 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002570 pFTAssocReq,
2571 assocReqlen);
2572
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002573 cfg80211_roamed(dev, chan,
2574 pRoamInfo->
2575 bssid.bytes,
2576 pFTAssocReq,
2577 assocReqlen,
2578 pFTAssocRsp,
2579 assocRsplen,
2580 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002581 wlan_hdd_send_roam_auth_event(
Prakash Dhavali989127d2016-11-29 14:56:44 +05302582 pAdapter,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002583 pRoamInfo->bssid.bytes,
2584 pFTAssocReq,
2585 assocReqlen,
2586 pFTAssocRsp,
2587 assocRsplen,
2588 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002589 }
2590 if (sme_get_ftptk_state
2591 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2592 pAdapter->sessionId)) {
2593 sme_set_ftptk_state
2594 (WLAN_HDD_GET_HAL_CTX
2595 (pAdapter),
2596 pAdapter->sessionId,
2597 false);
2598 pRoamInfo->fAuthRequired =
2599 false;
2600
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302601 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 roam_info.bssid,
2603 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302604 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302605 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606 roam_info.peerMac,
2607 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302608 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 pHddStaCtx->roam_info.roamId =
2610 roamId;
2611 pHddStaCtx->roam_info.
2612 roamStatus = roamStatus;
2613 pHddStaCtx->roam_info.
2614 deferKeyComplete = true;
2615 }
2616 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002617 hdd_info("ft_carrier_on is %d, sending connect indication",
2618 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302619 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002620 pRoamInfo->
2621 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302622 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002623 pFTAssocReq,
2624 assocReqlen,
2625 pFTAssocRsp,
2626 assocRsplen,
2627 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302628 GFP_KERNEL,
2629 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002631 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002632 /*
2633 * wpa supplicant expecting WPA/RSN IE in
2634 * connect result.
2635 */
2636 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2637 (pAdapter),
2638 pAdapter->sessionId,
2639 &reqRsnLength,
2640 reqRsnIe);
2641
2642 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2643 (pAdapter),
2644 pAdapter->sessionId,
2645 &rspRsnLength,
2646 rspRsnIe);
2647 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002648 if (ft_carrier_on)
2649 hdd_send_re_assoc_event(dev,
2650 pAdapter,
2651 pRoamInfo,
2652 reqRsnIe,
2653 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002654 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002655 hdd_info("sending connect indication to nl80211:for bssid "
2656 MAC_ADDRESS_STR
2657 " result:%d and Status:%d",
2658 MAC_ADDR_ARRAY
2659 (pRoamInfo->bssid.bytes),
2660 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002661
2662 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302663 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 pRoamInfo->
2665 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302666 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002667 reqRsnIe,
2668 reqRsnLength,
2669 rspRsnIe,
2670 rspRsnLength,
2671 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302672 GFP_KERNEL,
2673 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 }
2675 }
2676 }
2677 if (!hddDisconInProgress) {
2678 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002680 bss);
2681
2682 /*
2683 * Perform any WMM-related association
2684 * processing.
2685 */
2686 hdd_wmm_assoc(pAdapter, pRoamInfo,
2687 eCSR_BSS_TYPE_INFRASTRUCTURE);
2688
2689 /*
2690 * Start the Queue - Start tx queues before
2691 * hdd_roam_register_sta, since
2692 * hdd_roam_register_sta will flush any cached
2693 * data frames immediately.
2694 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002695 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002696 wlan_hdd_netif_queue_control(pAdapter,
2697 WLAN_WAKE_ALL_NETIF_QUEUE,
2698 WLAN_CONTROL_PATH);
2699
2700 /*
2701 * Register the Station with TL after associated
2702 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302703 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002704 pRoamInfo,
2705 pHddStaCtx->
2706 conn_info.
2707 staId[0],
2708 NULL,
2709 pRoamInfo->
2710 pBssDesc);
2711 }
2712 } else {
2713 /*
2714 * wpa supplicant expecting WPA/RSN IE in connect result
2715 * in case of reassociation also need to indicate it to
2716 * supplicant.
2717 */
2718 csr_roam_get_wpa_rsn_req_ie(
2719 WLAN_HDD_GET_HAL_CTX(pAdapter),
2720 pAdapter->sessionId,
2721 &reqRsnLength, reqRsnIe);
2722
2723 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2724 reqRsnIe, reqRsnLength);
2725 /* Reassoc successfully */
2726 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302727 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 hdd_change_peer_state(pAdapter,
2729 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002730 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002731#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2732 pRoamInfo->roamSynchInProgress
2733#else
2734 false
2735#endif
2736 );
2737 hdd_conn_set_authenticated(pAdapter, false);
2738 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002739 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2740 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302741 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002742 hdd_change_peer_state(pAdapter,
2743 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002744 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002745#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2746 pRoamInfo->roamSynchInProgress
2747#else
2748 false
2749#endif
2750 );
2751 hdd_conn_set_authenticated(pAdapter, true);
2752 }
2753
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302754 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002755 /*
2756 * Perform any WMM-related association
2757 * processing
2758 */
2759 hdd_wmm_assoc(pAdapter, pRoamInfo,
2760 eCSR_BSS_TYPE_INFRASTRUCTURE);
2761 }
2762
2763 /* Start the tx queues */
2764#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2765 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002766 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002768 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769 wlan_hdd_netif_queue_control(pAdapter,
2770 WLAN_WAKE_ALL_NETIF_QUEUE,
2771 WLAN_CONTROL_PATH);
2772 }
2773
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302774#ifdef FEATURE_WLAN_TDLS
2775 wlan_hdd_tdls_connection_callback(pAdapter);
2776#endif
2777
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302778 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002779 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302780 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002781 }
2782#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302783 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002784 sizeof(pAdapter->hdd_stats.hddPmfStats));
2785#endif
2786 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302787 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002788 hdd_wext_state_t *pWextState =
2789 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2790 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302791 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2792 " result:%d and Status:%d",
2793 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2794 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002795 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302796 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2797 " result:%d and Status:%d",
2798 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2799 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302800
2801 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2802 (pRoamInfo &&
2803 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2804 pRoamInfo->statusCode) ||
2805 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2806 pRoamInfo->statusCode) ||
2807 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2808 pRoamInfo->statusCode)))) {
2809 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2810 pRoamInfo ?
2811 pRoamInfo->bssid.bytes :
2812 pWextState->req_bssId.bytes);
2813 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2814 pRoamInfo ?
2815 pRoamInfo->bssid.bytes :
2816 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302817 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302818 }
2819
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002820 /*
2821 * CR465478: Only send up a connection failure result when CSR
2822 * has completed operation - with a ASSOCIATION_FAILURE status.
2823 */
2824 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2825 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302826 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002827 hdd_err("send connect failure to nl80211: for bssid "
2828 MAC_ADDRESS_STR
2829 " result:%d and Status:%d reasoncode %d",
2830 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2831 roamResult, roamStatus,
2832 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302833 pHddStaCtx->conn_info.assoc_status_code =
2834 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08002835 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002836 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002837 MAC_ADDRESS_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002838 " result:%d and Status:%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2840 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08002841 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05302842 hdd_err("Invoking packetdump deregistration API");
2843 wlan_deregister_txrx_packetdump();
2844
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002845 /* inform association failure event to nl80211 */
2846 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2847 roamResult) {
2848 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302849 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302851 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002852 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302853 GFP_KERNEL,
2854 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002855 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302856 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302858 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002859 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302860 GFP_KERNEL,
2861 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002862 } else {
Wu Gao77d28352016-11-23 17:50:56 +08002863 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302864 hdd_connect_result(dev,
2865 pRoamInfo->bssid.bytes,
2866 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08002867 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05302868 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002869 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302870 GFP_KERNEL,
2871 connect_timeout);
Wu Gao77d28352016-11-23 17:50:56 +08002872 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302873 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302875 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002876 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302877 GFP_KERNEL,
2878 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002879 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302880 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002881 } else if ((eCSR_ROAM_CANCELLED == roamStatus
2882 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05302883 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002884 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05302885 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002886 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302887 GFP_KERNEL,
2888 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002889 }
2890
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 /*
2892 * Set connection state to eConnectionState_NotConnected only
2893 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002894 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002895 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002896 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
2897 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002898 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 hdd_conn_set_connection_state(pAdapter,
2900 eConnectionState_NotConnected);
2901 }
2902 hdd_wmm_init(pAdapter);
2903
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002904 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002905 wlan_hdd_netif_queue_control(pAdapter,
2906 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2907 WLAN_CONTROL_PATH);
2908 }
2909
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302910 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302912 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913
Govind Singh24db1ed2015-12-18 15:54:59 +05302914 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2915 cds_force_sap_on_scc(roamResult,
2916 pRoamInfo->pBssDesc->channelId);
2917 } else {
2918 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302919 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302920 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002921
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302922 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923}
2924
2925/**
2926 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
2927 * @pAdapter: pointer to adapter
2928 * @pRoamInfo: pointer to roam info
2929 * @roamId: roam id
2930 * @roamStatus: roam status
2931 * @roamResult: roam result
2932 *
2933 * Here we update the status of the Ibss when we receive information that we
2934 * have started/joined an ibss session.
2935 *
2936 * Return: none
2937 */
2938static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
2939 tCsrRoamInfo *pRoamInfo,
2940 uint32_t roamId,
2941 eRoamCmdStatus roamStatus,
2942 eCsrRoamResult roamResult)
2943{
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002944 hdd_info("%s: id %d, status %d, result %d",
2945 pAdapter->dev->name, roamId,
2946 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002947
2948 switch (roamResult) {
2949 /* both IBSS Started and IBSS Join should come in here. */
2950 case eCSR_ROAM_RESULT_IBSS_STARTED:
2951 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
2952 case eCSR_ROAM_RESULT_IBSS_COALESCED:
2953 {
2954 hdd_context_t *pHddCtx =
2955 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302956 hdd_station_ctx_t *hdd_sta_ctx =
2957 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302958 struct qdf_mac_addr broadcastMacAddr =
2959 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002960
2961 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302962 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002963 return;
2964 }
2965
2966 /* When IBSS Started comes from CSR, we need to move
2967 * connection state to IBSS Disconnected (meaning no peers
2968 * are in the IBSS).
2969 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002970 hdd_conn_set_connection_state(pAdapter,
2971 eConnectionState_IbssDisconnected);
2972 /* notify wmm */
2973 hdd_wmm_connect(pAdapter, pRoamInfo,
2974 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302975
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07002976 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302977
2978 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 pAdapter;
2980 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302981 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002982 &broadcastMacAddr,
2983 pRoamInfo->pBssDesc);
2984
2985 if (pRoamInfo->pBssDesc) {
2986 struct cfg80211_bss *bss;
2987#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
2988 struct ieee80211_channel *chan;
2989 int chan_no;
2990 unsigned int freq;
2991#endif
2992 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002993 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
2994 pAdapter->dev->name,
2995 MAC_ADDR_ARRAY(
2996 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002997
2998 /* we must first give cfg80211 the BSS information */
2999 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3000 pRoamInfo);
3001 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003002 hdd_err("%s: unable to create IBSS entry",
3003 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003004 return;
3005 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003006 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003007 wlan_hdd_netif_queue_control(pAdapter,
3008 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3009 WLAN_CONTROL_PATH);
3010
3011#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3012 chan_no = pRoamInfo->pBssDesc->channelId;
3013
3014 if (chan_no <= 14)
3015 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003016 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 else
3018 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003019 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020
3021 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3022
3023 if (chan)
3024 cfg80211_ibss_joined(pAdapter->dev,
3025 bss->bssid, chan,
3026 GFP_KERNEL);
3027 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003028 hdd_err("%s: chanId: %d, can't find channel",
3029 pAdapter->dev->name,
3030 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003031#else
3032 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3033 GFP_KERNEL);
3034#endif
3035 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 bss);
3038 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003039 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003040 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07003041 pAdapter->sessionId);
3042 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3043 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003044 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003045 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003046 break;
3047 }
3048
3049 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3050 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003051 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003052 break;
3053 }
3054
3055 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003056 hdd_err("%s: unexpected result %d",
3057 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 break;
3059 }
3060
3061 return;
3062}
3063
3064/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003065 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3066 * @sta_ctx: pointer to hdd station context
3067 * @sta_id: station ID
3068 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003069 *
3070 * This information is passed to iwconfig later. The peer that joined
3071 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003072
3073 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003075bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3076 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003077{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003078 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003080 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3081 if (0 == sta_ctx->conn_info.staId[idx]) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003082 hdd_info("adding peer: %pM, sta_id: %d, at idx: %d",
3083 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003084 sta_ctx->conn_info.staId[idx] = sta_id;
3085 qdf_copy_macaddr(
3086 &sta_ctx->conn_info.peerMacAddress[idx],
3087 peer_mac_addr);
3088 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003089 }
3090 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003091 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092}
3093
3094/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003095 * hdd_delete_peer() - removes peer from hdd station context peer table
3096 * @sta_ctx: pointer to hdd station context
3097 * @sta_id: station ID
3098 *
3099 * Return: None
3100 */
3101void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3102{
3103 int i;
3104
3105 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3106 if (sta_id == sta_ctx->conn_info.staId[i]) {
3107 sta_ctx->conn_info.staId[i] = 0;
3108 return;
3109 }
3110 }
3111
3112 hdd_err(FL("sta_id %d is not present in peer table"), sta_id);
3113}
3114
3115/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003116 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3117 * @pAdapter: pointer to adapter
3118 * @staId: station id
3119 *
3120 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003121 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003122 * false otherwise.
3123 */
3124static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3125{
3126 bool fSuccess = false;
3127 int idx = 0;
3128 uint8_t valid_idx = 0;
3129 uint8_t del_idx = 0;
3130 uint8_t empty_slots = 0;
3131 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3132
Naveen Rawatc45d1622016-07-05 12:20:09 -07003133 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003134 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3135 pHddStaCtx->conn_info.staId[idx] = 0;
3136
Anurag Chouhanc5548422016-02-24 18:33:27 +05303137 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003138 peerMacAddress[idx]);
3139
3140 fSuccess = true;
3141
3142 /*
3143 * Note the deleted Index, if its 0 we need special
3144 * handling.
3145 */
3146 del_idx = idx;
3147
3148 empty_slots++;
3149 } else {
3150 if (pHddStaCtx->conn_info.staId[idx] != 0) {
3151 valid_idx = idx;
3152 } else {
3153 /* Found an empty slot */
3154 empty_slots++;
3155 }
3156 }
3157 }
3158
Naveen Rawatc45d1622016-07-05 12:20:09 -07003159 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003160 /* Last peer departed, set the IBSS state appropriately */
3161 pHddStaCtx->conn_info.connState =
3162 eConnectionState_IbssDisconnected;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003163 hdd_err("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003164 }
3165 /* Find next active staId, to have a valid sta trigger for TL. */
3166 if (fSuccess == true) {
3167 if (del_idx == 0) {
3168 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
3169 pHddStaCtx->conn_info.staId[0] =
3170 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303171 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003172 peerMacAddress[0],
3173 &pHddStaCtx->conn_info.
3174 peerMacAddress[valid_idx]);
3175
3176 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303177 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003178 peerMacAddress[valid_idx]);
3179 }
3180 }
3181 }
3182 return fSuccess;
3183}
3184
3185/**
3186 * roam_ibss_connect_handler() - IBSS connection handler
3187 * @pAdapter: pointer to adapter
3188 * @pRoamInfo: pointer to roam info
3189 *
3190 * We update the status of the IBSS to connected in this function.
3191 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303192 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003193 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303194static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195 tCsrRoamInfo *pRoamInfo)
3196{
3197 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003198 /*
3199 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3200 * a partner stations).
3201 */
3202 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3203
3204 /* Save the connection info from CSR... */
3205 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3206
3207 /* Send the bssid address to the wext. */
3208 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3209 /* add bss_id to cfg80211 data base */
3210 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3211 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003212 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003213 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303214 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003215 }
3216 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003217 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 bss);
3219
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303220 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003221}
3222
3223/**
3224 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3225 * @pAdapter: pointer to adapter
3226 * @pRoamInfo: pointer to roam info
3227 * @roamId: roam id
3228 * @roamStatus: roam status
3229 * @roamResult: roam result
3230 *
3231 * This function indicates the Mic failure to the supplicant
3232 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303233 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003234 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303235static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003236hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3237 tCsrRoamInfo *pRoamInfo,
3238 uint32_t roamId,
3239 eRoamCmdStatus roamStatus,
3240 eCsrRoamResult roamResult)
3241{
3242 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3243
3244 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3245 TKIP_COUNTER_MEASURE_STOPED ==
3246 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3247 struct iw_michaelmicfailure msg;
3248 union iwreq_data wreq;
3249 memset(&msg, '\0', sizeof(msg));
3250 msg.src_addr.sa_family = ARPHRD_ETHER;
3251 memcpy(msg.src_addr.sa_data,
3252 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3253 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003254 hdd_info("MIC MAC " MAC_ADDRESS_STR,
3255 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256
3257 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3258 msg.flags = IW_MICFAILURE_GROUP;
3259 else
3260 msg.flags = IW_MICFAILURE_PAIRWISE;
3261 memset(&wreq, 0, sizeof(wreq));
3262 wreq.data.length = sizeof(msg);
3263 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3264 (char *)&msg);
3265 /* inform mic failure to nl80211 */
3266 cfg80211_michael_mic_failure(pAdapter->dev,
3267 pRoamInfo->u.pMICFailureInfo->
3268 taMacAddr,
3269 ((pRoamInfo->u.pMICFailureInfo->
3270 multicast ==
3271 eSIR_TRUE) ?
3272 NL80211_KEYTYPE_GROUP :
3273 NL80211_KEYTYPE_PAIRWISE),
3274 pRoamInfo->u.pMICFailureInfo->
3275 keyId,
3276 pRoamInfo->u.pMICFailureInfo->TSC,
3277 GFP_KERNEL);
3278
3279 }
3280
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303281 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003282}
3283
3284/**
3285 * roam_roam_connect_status_update_handler() - IBSS connect status update
3286 * @pAdapter: pointer to adapter
3287 * @pRoamInfo: pointer to roam info
3288 * @roamId: roam id
3289 * @roamStatus: roam status
3290 * @roamResult: roam result
3291 *
3292 * The Ibss connection status is updated regularly here in this function.
3293 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303294 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303296static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003297roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3298 tCsrRoamInfo *pRoamInfo,
3299 uint32_t roamId,
3300 eRoamCmdStatus roamStatus,
3301 eCsrRoamResult roamResult)
3302{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303303 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003304 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003306 switch (roamResult) {
3307 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3308 {
3309 hdd_station_ctx_t *pHddStaCtx =
3310 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003311 struct station_info *stainfo;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003312
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303313 hdd_err("IBSS New Peer indication from SME "
3314 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3315 MAC_ADDRESS_STR " and stationID= %d",
3316 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3317 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3318 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003319
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003320 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3322 pRoamInfo->staId,
3323 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003324 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003325 break;
3326 }
3327
3328 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3329
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003330 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303331 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003332 pRoamInfo,
3333 pRoamInfo->staId,
3334 &pRoamInfo->peerMac,
3335 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303336 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003337 hdd_err("Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303338 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339 }
3340 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003341 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3342 if (stainfo == NULL) {
3343 hdd_err("memory allocation for station_info failed");
3344 return QDF_STATUS_E_NOMEM;
3345 }
3346 stainfo->filled = 0;
3347 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003348
3349 cfg80211_new_sta(pAdapter->dev,
3350 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003351 stainfo, GFP_KERNEL);
3352 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003353
3354 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
3355 pHddStaCtx->ibss_enc_key.encType
3356 || eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
3357 pHddStaCtx->ibss_enc_key.encType
3358 || eCSR_ENCRYPT_TYPE_TKIP ==
3359 pHddStaCtx->ibss_enc_key.encType
3360 || eCSR_ENCRYPT_TYPE_AES ==
3361 pHddStaCtx->ibss_enc_key.encType) {
3362 pHddStaCtx->ibss_enc_key.keyDirection =
3363 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303364 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003365 &pRoamInfo->peerMac);
3366
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003367 hdd_info("New peer joined set PTK encType=%d",
3368 pHddStaCtx->ibss_enc_key.encType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003369
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303370 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003371 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3372 (pAdapter),
3373 pAdapter->sessionId,
3374 &pHddStaCtx->ibss_enc_key,
3375 &roamId);
3376
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303377 if (QDF_STATUS_SUCCESS != qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003378 hdd_err("sme_roam_set_key failed, status=%d",
3379 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303380 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 }
3382 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003383 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 wlan_hdd_netif_queue_control(pAdapter,
3385 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3386 WLAN_CONTROL_PATH);
3387 break;
3388 }
3389
3390 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3391 {
3392
3393 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3394
3395 break;
3396 }
3397 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3398 {
3399 hdd_station_ctx_t *pHddStaCtx =
3400 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3401
3402 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003403 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003404
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303405 hdd_err("IBSS Peer Departed from SME "
3406 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3407 MAC_ADDRESS_STR " and stationID= %d",
3408 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3409 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3410 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411
3412 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3413
3414 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3415 pHddStaCtx->ibss_sta_generation++;
3416
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303417 qdf_status = hdd_remove_peer_object(pAdapter->hdd_vdev,
3418 pRoamInfo->peerMac.bytes);
3419 if (QDF_IS_STATUS_ERROR(qdf_status))
3420 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
3421 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3422
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 cfg80211_del_sta(pAdapter->dev,
3424 (const u8 *)&pRoamInfo->peerMac.bytes,
3425 GFP_KERNEL);
3426 break;
3427 }
3428 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3429 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003430 hdd_info("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003431 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003432 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 wlan_hdd_netif_queue_control(pAdapter,
3434 WLAN_NETIF_TX_DISABLE_N_CARRIER,
3435 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 hdd_conn_set_connection_state(pAdapter,
3437 eConnectionState_NotConnected);
3438
3439 /* Send the bssid address to the wext. */
3440 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3441 break;
3442 }
3443 default:
3444 break;
3445
3446 }
3447
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303448 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003449}
3450
3451#ifdef FEATURE_WLAN_TDLS
3452/**
3453 * hdd_roam_register_tdlssta() - register new TDLS station
3454 * @pAdapter: pointer to adapter
3455 * @peerMac: pointer to peer MAC address
3456 * @staId: station identifier
3457 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303458 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003459 *
3460 * Construct the staDesc and register with TL the new STA.
3461 * This is called as part of ADD_STA in the TDLS setup.
3462 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303463 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303465QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303467 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003468{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303469 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003471 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003472 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3473 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003474
3475 /*
3476 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3477 * be peer MAC, here we are working on direct Link
3478 */
3479 staDesc.sta_id = staId;
3480
3481 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303482 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483
Dhanashri Atre50141c52016-04-07 13:15:29 -07003484 /* Register the vdev transmit and receive functions */
3485 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3486 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003487 cdp_vdev_register(soc,
3488 cdp_get_vdev_from_vdev_id(soc, pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003489 pAdapter, &txrx_ops);
3490 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003491
3492 /* Register the Station with TL... */
Leo Changfdb45c32016-10-28 11:09:23 -07003493 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303494 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003495 hdd_err("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303496 qdf_status, qdf_status);
3497 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003498 }
3499
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303500 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501}
3502
3503/**
3504 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3505 * @pAdapter: pointer to adapter
3506 * @staId: station identifier
3507 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303508 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003509 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303510static QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 uint8_t staId)
3512{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303513 QDF_STATUS qdf_status;
Leo Changfdb45c32016-10-28 11:09:23 -07003514 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
3515 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303516 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003517 hdd_warn("cdp_peer_clear() failed for staID %d. Status=%d [0x%08X]",
3518 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003519 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303520 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003521}
3522
3523/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003524 * hdd_tdls_connection_tracker_update() - update connection tracker state
3525 * @adapter: pointer to adapter
3526 * @roam_info: pointer to roam info
3527 * @hdd_tdls_ctx: tdls context
3528 *
3529 * Return: QDF_STATUS enumeration
3530 */
3531static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3532 tCsrRoamInfo *roam_info,
3533 tdlsCtx_t *hdd_tdls_ctx)
3534{
3535 hddTdlsPeer_t *curr_peer;
3536 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3537
3538 curr_peer = wlan_hdd_tdls_find_peer(adapter,
3539 roam_info->peerMac.bytes, true);
3540
3541 if (!curr_peer) {
3542 hdd_err("curr_peer is null");
3543 return QDF_STATUS_E_FAILURE;
3544 }
3545
3546 mutex_lock(&hdd_ctx->tdls_lock);
3547
3548 if (eTDLS_LINK_CONNECTED ==
3549 curr_peer->link_status) {
3550 hdd_err("Received CONNECTION_TRACKER_NOTIFICATION "
3551 MAC_ADDRESS_STR
3552 " staId: %d, reason: %d",
3553 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3554 roam_info->staId,
3555 roam_info->reasonCode);
3556
3557 if (roam_info->reasonCode ==
3558 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3559 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003560 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3561 roam_info->reasonCode ==
3562 eWMI_TDLS_SCAN_STARTED_EVENT)
3563 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003564 else if (roam_info->reasonCode ==
3565 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3566 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003567 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3568 roam_info->reasonCode ==
3569 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3570 hdd_ctx->enable_tdls_connection_tracker = true;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003571
3572 } else {
3573 hdd_err("TDLS not connected, ignore notification, reason: %d",
3574 roam_info->reasonCode);
3575 }
3576
3577 mutex_unlock(&hdd_ctx->tdls_lock);
3578
3579 return QDF_STATUS_SUCCESS;
3580}
3581
3582
3583
3584
3585/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3587 * @pAdapter: pointer to adapter
3588 * @pRoamInfo: pointer to roam info
3589 * @roamId: roam id
3590 * @roamStatus: roam status
3591 * @roamResult: roam result
3592 *
3593 * HDD interface between SME and TL to ensure TDLS client registration with
3594 * TL in case of new TDLS client is added and deregistration at the time
3595 * TDLS client is deleted.
3596 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303597 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003598 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303599static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003600hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3601 tCsrRoamInfo *pRoamInfo,
3602 uint32_t roamId,
3603 eRoamCmdStatus roamStatus,
3604 eCsrRoamResult roamResult)
3605{
3606 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3607 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3608 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303609 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003610 uint8_t staIdx;
3611 hddTdlsPeer_t *curr_peer;
3612 uint32_t reason;
3613
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003614 hdd_info("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003615 roamResult ==
3616 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3617 ==
3618 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3619 roamResult ==
3620 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3621 : roamResult ==
3622 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3623 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3624 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3625 roamResult ==
3626 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3627 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3628 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3629 : roamResult ==
3630 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3631 : roamResult ==
3632 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3633 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3634 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3635
3636 if (!pHddTdlsCtx) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003637 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
3638 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003639 return status;
3640 }
3641
3642 switch (roamResult) {
3643 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3644 {
3645 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003646 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003647 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303648 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3649
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 } else {
3651 /*
3652 * Check if there is available index for this new TDLS
3653 * STA.
3654 */
3655 for (staIdx = 0;
3656 staIdx < pHddCtx->max_num_tdls_sta;
3657 staIdx++) {
3658 if (0 ==
3659 pHddCtx->tdlsConnInfo[staIdx].
3660 staId) {
3661 pHddCtx->tdlsConnInfo[staIdx].
3662 sessionId =
3663 pRoamInfo->sessionId;
3664 pHddCtx->tdlsConnInfo[staIdx].
3665 staId = pRoamInfo->staId;
3666
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003667 hdd_warn("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003668 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003669 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003670 staIdx,
3671 pHddCtx->
3672 tdlsConnInfo[staIdx].
3673 staId,
3674 MAC_ADDR_ARRAY
3675 (pRoamInfo->peerMac.bytes));
3676
Anurag Chouhanc5548422016-02-24 18:33:27 +05303677 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003678 tdlsConnInfo
3679 [staIdx].
3680 peerMac,
3681 &pRoamInfo->
3682 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303683 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003684 break;
3685 }
3686 }
3687 if (staIdx < pHddCtx->max_num_tdls_sta) {
3688 if (-1 ==
3689 wlan_hdd_tdls_set_sta_id(pAdapter,
3690 pRoamInfo->
3691 peerMac.bytes,
3692 pRoamInfo->
3693 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003694 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303695 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003696 }
3697
3698 (WLAN_HDD_GET_CTX(pAdapter))->
3699 sta_to_adapter[pRoamInfo->staId] =
3700 pAdapter;
3701 /*
3702 * store the ucast signature,
3703 * if required for further reference.
3704 */
3705
3706 wlan_hdd_tdls_set_signature(pAdapter,
3707 pRoamInfo->
3708 peerMac.bytes,
3709 pRoamInfo->
3710 ucastSig);
3711 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303712 status = QDF_STATUS_E_FAILURE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003713 hdd_err("no available slot in conn_info. staId %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003714 pRoamInfo->staId);
3715 }
3716 pAdapter->tdlsAddStaStatus = status;
3717 }
3718 complete(&pAdapter->tdls_add_station_comp);
3719 break;
3720 }
3721 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3722 {
3723 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003724 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003725 pRoamInfo->statusCode);
3726 }
3727 /* store the ucast signature which will be used later when
3728 * registering to TL
3729 */
3730 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3731 complete(&pAdapter->tdls_add_station_comp);
3732 break;
3733 }
3734 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3735 {
3736 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003737 hdd_err("Link Establish Request failed. status(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003738 pRoamInfo->statusCode);
3739 }
3740 complete(&pAdapter->tdls_link_establish_req_comp);
3741 break;
3742 }
3743 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3744 {
3745 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3746 staIdx++) {
3747 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3748 pRoamInfo->sessionId)
3749 && pRoamInfo->staId ==
3750 pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003751 hdd_warn("HDD: del STA IDX = %x",
3752 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003753
3754 curr_peer =
3755 wlan_hdd_tdls_find_peer(pAdapter,
3756 pRoamInfo->
3757 peerMac.bytes,
3758 true);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303759 if (NULL != curr_peer) {
3760 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3761 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3762 curr_peer->link_status);
3763 if (TDLS_IS_CONNECTED(curr_peer)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764 hdd_roam_deregister_tdlssta
3765 (pAdapter,
3766 pRoamInfo->staId);
3767 wlan_hdd_tdls_decrement_peer_count
3768 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303769 } else if (eTDLS_LINK_CONNECTING ==
3770 curr_peer->link_status) {
3771 hdd_roam_deregister_tdlssta
3772 (pAdapter,
3773 pRoamInfo->staId);
3774 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003775 }
3776 wlan_hdd_tdls_reset_peer(pAdapter,
3777 pRoamInfo->
3778 peerMac.bytes);
3779
3780 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3781 pHddCtx->tdlsConnInfo[staIdx].
3782 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303783 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003784 tdlsConnInfo[staIdx].
3785 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303786 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303787 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003788 break;
3789 }
3790 }
3791 complete(&pAdapter->tdls_del_station_comp);
3792 }
3793 break;
3794 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3795 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003796 hdd_err("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003797 pRoamInfo->reasonCode);
3798
3799 curr_peer =
3800 wlan_hdd_tdls_find_peer(pAdapter,
3801 pRoamInfo->peerMac.bytes, true);
3802 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
3803 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303804 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3805 curr_peer->peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303806 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003807 break;
3808 }
3809 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3810 {
3811 /* 0 staIdx is assigned to AP we dont want to touch that */
3812 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3813 staIdx++) {
3814 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3815 pRoamInfo->sessionId)
3816 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003817 hdd_warn("hdd_tdlsStatusUpdate: staIdx %d "
3818 MAC_ADDRESS_STR,
3819 pHddCtx->tdlsConnInfo[staIdx].
3820 staId,
3821 MAC_ADDR_ARRAY(pHddCtx->
3822 tdlsConnInfo
3823 [staIdx].
3824 peerMac.
3825 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 wlan_hdd_tdls_reset_peer(pAdapter,
3827 pHddCtx->
3828 tdlsConnInfo
3829 [staIdx].
3830 peerMac.bytes);
3831 hdd_roam_deregister_tdlssta(pAdapter,
3832 pHddCtx->
3833 tdlsConnInfo
3834 [staIdx].
3835 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303836 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003837 sizeof
3838 (smeTdlsPeerStateParams));
3839 smeTdlsPeerStateParams.vdevId =
3840 pHddCtx->tdlsConnInfo[staIdx].
3841 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303842 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003843 peerMacAddr,
3844 &pHddCtx->
3845 tdlsConnInfo[staIdx].
3846 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303847 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 smeTdlsPeerStateParams.peerState =
3849 eSME_TDLS_PEER_STATE_TEARDOWN;
3850
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003851 hdd_info("calling sme_update_tdls_peer_state for staIdx %d "
3852 MAC_ADDRESS_STR,
3853 pHddCtx->tdlsConnInfo[staIdx].
3854 staId,
3855 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003856 tdlsConnInfo
3857 [staIdx].
3858 peerMac.
3859 bytes));
3860 status =
3861 sme_update_tdls_peer_state(
3862 pHddCtx->hHal,
3863 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303864 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003865 hdd_err("sme_update_tdls_peer_state failed for "
3866 MAC_ADDRESS_STR,
3867 MAC_ADDR_ARRAY
3868 (pHddCtx->
3869 tdlsConnInfo[staIdx].
3870 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003871 }
3872 wlan_hdd_tdls_decrement_peer_count
3873 (pAdapter);
3874
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303875 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 tdlsConnInfo[staIdx].
3877 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303878 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003879 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3880 pHddCtx->tdlsConnInfo[staIdx].
3881 sessionId = 255;
3882
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303883 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003884 }
3885 }
3886 break;
3887 }
3888 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3889 {
3890 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07003891 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
3892 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303893 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003894 break;
3895 }
3896
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07003897 if (pHddCtx->tdls_nss_switch_in_progress) {
3898 hdd_err("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
3899 status = QDF_STATUS_SUCCESS;
3900 break;
3901 }
3902
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 curr_peer =
3904 wlan_hdd_tdls_get_peer(pAdapter,
Kabilan Kannan36090ce2016-05-03 19:28:44 -07003905 pRoamInfo->peerMac.bytes,
3906 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003907 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303908 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303909 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003910 } else {
3911 if (eTDLS_LINK_CONNECTED ==
3912 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003913 hdd_err("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003914 } else {
3915 /*
3916 * If external control is enabled then initiate
3917 * TDLS only if forced peer is set otherwise
3918 * ignore should Discover trigger from fw.
3919 */
3920 if (pHddCtx->config->
3921 fTDLSExternalControl
3922 && (false ==
3923 curr_peer->isForcedPeer)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003924 hdd_info("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303925 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003926 break;
3927 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003928 hdd_info("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 pHddCtx->config->
3930 fTDLSExternalControl,
3931 curr_peer->isForcedPeer,
3932 pRoamInfo->reasonCode);
3933 }
Nitesh Shah983e8f52016-11-25 12:36:29 +05303934 pHddTdlsCtx->curr_candidate = curr_peer;
3935 wlan_hdd_tdls_implicit_send_discovery_request(
3936 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003937 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303938 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003939 }
3940 break;
3941 }
3942
3943 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
3944 {
3945 curr_peer =
3946 wlan_hdd_tdls_find_peer(pAdapter,
3947 pRoamInfo->peerMac.bytes, true);
3948 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303949 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303950 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951 } else {
3952 if (eTDLS_LINK_CONNECTED ==
3953 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003954 hdd_err("Received SHOULD_TEARDOWN for peer "
3955 MAC_ADDRESS_STR
3956 " staId: %d, reason: %d",
3957 MAC_ADDR_ARRAY(pRoamInfo->
3958 peerMac.bytes),
3959 pRoamInfo->staId,
3960 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961
3962 if (pRoamInfo->reasonCode ==
3963 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
3964 pRoamInfo->reasonCode ==
3965 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
3966 pRoamInfo->reasonCode ==
3967 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
3968 pRoamInfo->reasonCode ==
3969 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
3970 reason =
3971 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
3972 } else
3973 reason =
3974 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
3975
3976 wlan_hdd_tdls_indicate_teardown
3977 (pHddTdlsCtx->pAdapter, curr_peer,
3978 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303979 hdd_send_wlan_tdls_teardown_event(
3980 eTDLS_TEARDOWN_BSS_DISCONNECT,
3981 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003982 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003983 hdd_err("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
3984 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003985 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303986 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 }
3988 break;
3989 }
3990
3991 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
3992 {
3993 curr_peer =
3994 wlan_hdd_tdls_find_peer(pAdapter,
3995 pRoamInfo->peerMac.bytes, true);
3996 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303997 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303998 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003999 } else {
4000 if (eTDLS_LINK_CONNECTED ==
4001 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004002 hdd_err("Received SHOULD_PEER_DISCONNECTED for peer "
4003 MAC_ADDRESS_STR
4004 " staId: %d, reason: %d",
4005 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4006 pRoamInfo->staId,
4007 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004008
4009 if (pRoamInfo->reasonCode ==
4010 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4011 pRoamInfo->reasonCode ==
4012 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4013 pRoamInfo->reasonCode ==
4014 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4015 pRoamInfo->reasonCode ==
4016 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4017 reason =
4018 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4019 } else
4020 reason =
4021 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4022
4023 wlan_hdd_tdls_indicate_teardown
4024 (pHddTdlsCtx->pAdapter, curr_peer,
4025 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304026 hdd_send_wlan_tdls_teardown_event(
4027 eTDLS_TEARDOWN_BSS_DISCONNECT,
4028 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004029 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004030 hdd_err("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
4031 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004032 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304033 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 }
4035 break;
4036 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004037
4038 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
4039 status = hdd_tdls_connection_tracker_update(pAdapter,
4040 pRoamInfo,
4041 pHddTdlsCtx);
4042 break;
4043
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004044 default:
4045 {
4046 break;
4047 }
4048 }
4049
4050 return status;
4051}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004052#else
4053
4054static inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
4055 uint8_t staId)
4056{
4057 return QDF_STATUS_SUCCESS;
4058}
4059
4060static inline QDF_STATUS
4061hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4062 tCsrRoamInfo *pRoamInfo,
4063 uint32_t roamId,
4064 eRoamCmdStatus roamStatus,
4065 eCsrRoamResult roamResult)
4066{
4067 return QDF_STATUS_SUCCESS;
4068}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004069#endif
4070
4071#ifdef WLAN_FEATURE_11W
4072/**
4073 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4074 * @pAdapter: pointer to the adapter
4075 * @nFrameLength: Length of the unprotected frame being passed
4076 * @pbFrames: Pointer to the frame buffer
4077 * @frameType: 802.11 frame type
4078 *
4079 * This function forwards the unprotected management frame to the supplicant.
4080 *
4081 * Return: nothing
4082 */
4083static void
4084hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4085 uint8_t *pbFrames, uint8_t frameType)
4086{
4087 uint8_t type = 0;
4088 uint8_t subType = 0;
4089
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004090 hdd_info("Frame Type = %d Frame Length = %d",
4091 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004092
4093 /* Sanity Checks */
4094 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004095 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 return;
4097 }
4098
4099 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004100 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004101 return;
4102 }
4103
4104 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004105 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 return;
4107 }
4108
4109 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004110 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004111 return;
4112 }
4113
4114 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004115 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004116 return;
4117 }
4118
4119 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4120 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4121
4122 /* Get pAdapter from Destination mac address of the frame */
4123 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4124#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4125 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4126 nFrameLength);
4127#else
4128 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4129 nFrameLength);
4130#endif
4131 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4132 } else if (type == SIR_MAC_MGMT_FRAME &&
4133 subType == SIR_MAC_MGMT_DEAUTH) {
4134#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4135 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4136 nFrameLength);
4137#else
4138 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4139 nFrameLength);
4140#endif
4141 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4142 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004143 hdd_err("Frame type %d and subtype %d are not valid",
4144 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004145 return;
4146 }
4147}
4148#endif
4149
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004150#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004151/**
4152 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4153 * @pAdapter: pointer to adapter
4154 * @tid: traffic identifier
4155 * @state: state
4156 * @measInterval: measurement interval
4157 *
4158 * This function sends traffic stream metrics IE information to
4159 * the supplicant via wireless event.
4160 *
4161 * Return: none
4162 */
4163static void
4164hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4165 uint8_t state, uint16_t measInterval)
4166{
4167 union iwreq_data wrqu;
4168 char buf[IW_CUSTOM_MAX + 1];
4169 int nBytes = 0;
4170
4171 if (NULL == pAdapter)
4172 return;
4173
4174 /* create the event */
4175 memset(&wrqu, '\0', sizeof(wrqu));
4176 memset(buf, '\0', sizeof(buf));
4177
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004178 hdd_info("TSM Ind tid(%d) state(%d) MeasInt(%d)",
4179 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004180
4181 nBytes =
4182 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4183 measInterval);
4184
4185 wrqu.data.pointer = buf;
4186 wrqu.data.length = nBytes;
4187 /* send the event */
4188 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4189}
4190
4191/**
4192 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4193 * @pAdapter: pointer to adapter
4194 * @pRoamInfo: pointer to roam info
4195 *
4196 * This function sends cckm preauth indication to the supplicant
4197 * via wireless custom event.
4198 *
4199 * Return: none
4200 */
4201static void
4202hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4203{
4204 union iwreq_data wrqu;
4205 char buf[IW_CUSTOM_MAX + 1];
4206 char *pos = buf;
4207 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4208
4209 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4210 return;
4211
4212 /* create the event */
4213 memset(&wrqu, '\0', sizeof(wrqu));
4214 memset(buf, '\0', sizeof(buf));
4215
4216 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004217 hdd_info("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
4218 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4219 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220
4221 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4222 pos += nBytes;
4223 freeBytes -= nBytes;
4224
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304225 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304226 pos += QDF_MAC_ADDR_SIZE;
4227 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004228
4229 nBytes = snprintf(pos, freeBytes, " %u:%u",
4230 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4231 freeBytes -= nBytes;
4232
4233 wrqu.data.pointer = buf;
4234 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4235
4236 /* send the event */
4237 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4238}
4239
4240/**
4241 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4242 * @pAdapter: pointer to adapter
4243 * @pRoamInfo: pointer to roam info
4244 *
4245 * Return: none
4246 */
4247static void
4248hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4249 tCsrRoamInfo *pRoamInfo)
4250{
4251 union iwreq_data wrqu;
4252 char buf[IW_CUSTOM_MAX + 1];
4253 int nBytes = 0;
4254
4255 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4256 return;
4257
4258 /* create the event */
4259 memset(&wrqu, '\0', sizeof(wrqu));
4260 memset(buf, '\0', sizeof(buf));
4261
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004262 hdd_info("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004263
4264 nBytes =
4265 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4266 pRoamInfo->tsmRoamDelay);
4267
4268 wrqu.data.pointer = buf;
4269 wrqu.data.length = nBytes;
4270
4271 /* send the event */
4272 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4273}
4274
4275/**
4276 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4277 * @pAdapter: pointer to adapter
4278 * @measurementToken: measurement token
4279 * @flag: flag
4280 * @numBss: number of bss
4281 *
4282 * If the measurement is none and no scan results found,
4283 * indicate the supplicant about measurement done.
4284 *
4285 * Return: none
4286 */
4287void
4288hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4289 const uint16_t measurementToken,
4290 const bool flag, const uint8_t numBss)
4291{
4292 union iwreq_data wrqu;
4293 char buf[IW_CUSTOM_MAX];
4294 char *pos = buf;
4295 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4296
4297 memset(&wrqu, '\0', sizeof(wrqu));
4298 memset(buf, '\0', sizeof(buf));
4299
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004300 hdd_info("CCXBCNREP=%d %d %d", measurementToken,
4301 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004302
4303 nBytes =
4304 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4305 flag, numBss);
4306
4307 wrqu.data.pointer = buf;
4308 wrqu.data.length = nBytes;
4309 /* send the event */
4310 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4311}
4312
4313/**
4314 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4315 * @pAdapter: pointer to adapter
4316 * @pRoamInfo: pointer to roam info
4317 *
4318 * If the measurement is none and no scan results found,
4319 * indicate the supplicant about measurement done.
4320 *
4321 * Return: none
4322 */
4323static void
4324hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4325 const tCsrRoamInfo *pRoamInfo)
4326{
4327 union iwreq_data wrqu;
4328 char buf[IW_CUSTOM_MAX];
4329 char *pos = buf;
4330 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4331 uint8_t i = 0, len = 0;
4332 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4333 uint8_t lastSent = 0, sendBss = 0;
4334 int bcnRepFieldSize =
4335 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4336 bcnReportFields);
4337 uint8_t ieLenByte = 1;
4338 /*
4339 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4340 */
4341#define ESEBCNREPHEADER_LEN (18)
4342
4343 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4344 return;
4345
4346 /*
4347 * Custom event can pass maximum of 256 bytes of data,
4348 * based on the IE len we need to identify how many BSS info can
4349 * be filled in to custom event data.
4350 */
4351 /*
4352 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4353 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4354 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4355 */
4356
4357 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4358 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004359 hdd_info("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004360 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004361 * indicate the supplicant about measurement done
4362 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004363 hdd_indicate_ese_bcn_report_no_results(
4364 pAdapter,
4365 pRoamInfo->pEseBcnReportRsp->
4366 measurementToken,
4367 pRoamInfo->pEseBcnReportRsp->flag,
4368 pRoamInfo->pEseBcnReportRsp->numBss);
4369 } else {
4370 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4371 memset(&wrqu, '\0', sizeof(wrqu));
4372 memset(buf, '\0', sizeof(buf));
4373 tot_bcn_ieLen = 0;
4374 sendBss = 0;
4375 pos = buf;
4376 freeBytes = IW_CUSTOM_MAX;
4377
4378 for (i = lastSent;
4379 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4380 len =
4381 bcnRepFieldSize + ieLenByte +
4382 pRoamInfo->pEseBcnReportRsp->
4383 bcnRepBssInfo[i].ieLen;
4384 if ((len + tot_bcn_ieLen) >
4385 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4386 break;
4387 }
4388 tot_bcn_ieLen += len;
4389 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004390 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4391 i, bcnRepFieldSize, 1,
4392 pRoamInfo->pEseBcnReportRsp->
4393 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004394 }
4395
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004396 hdd_info("Sending %d BSS Info", sendBss);
4397 hdd_info("CCXBCNREP=%d %d %d %d",
4398 pRoamInfo->pEseBcnReportRsp->measurementToken,
4399 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4400 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004401
4402 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4403 pRoamInfo->pEseBcnReportRsp->
4404 measurementToken,
4405 pRoamInfo->pEseBcnReportRsp->flag,
4406 sendBss);
4407 pos += nBytes;
4408 freeBytes -= nBytes;
4409
4410 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304411 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 sizeof(tot_bcn_ieLen));
4413 pos += sizeof(tot_bcn_ieLen);
4414 freeBytes -= sizeof(tot_bcn_ieLen);
4415
4416 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004417 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004418 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4419 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4420 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4421 pRoamInfo->pEseBcnReportRsp->
4422 bcnRepBssInfo[i +
4423 lastSent].bcnReportFields.
4424 ChanNum,
4425 pRoamInfo->pEseBcnReportRsp->
4426 bcnRepBssInfo[i +
4427 lastSent].bcnReportFields.
4428 Spare,
4429 pRoamInfo->pEseBcnReportRsp->
4430 bcnRepBssInfo[i +
4431 lastSent].bcnReportFields.
4432 MeasDuration,
4433 pRoamInfo->pEseBcnReportRsp->
4434 bcnRepBssInfo[i +
4435 lastSent].bcnReportFields.
4436 PhyType,
4437 pRoamInfo->pEseBcnReportRsp->
4438 bcnRepBssInfo[i +
4439 lastSent].bcnReportFields.
4440 RecvSigPower,
4441 pRoamInfo->pEseBcnReportRsp->
4442 bcnRepBssInfo[i +
4443 lastSent].bcnReportFields.
4444 ParentTsf,
4445 pRoamInfo->pEseBcnReportRsp->
4446 bcnRepBssInfo[i +
4447 lastSent].bcnReportFields.
4448 TargetTsf[0],
4449 pRoamInfo->pEseBcnReportRsp->
4450 bcnRepBssInfo[i +
4451 lastSent].bcnReportFields.
4452 TargetTsf[1],
4453 pRoamInfo->pEseBcnReportRsp->
4454 bcnRepBssInfo[i +
4455 lastSent].bcnReportFields.
4456 BcnInterval,
4457 pRoamInfo->pEseBcnReportRsp->
4458 bcnRepBssInfo[i +
4459 lastSent].bcnReportFields.
4460 CapabilityInfo,
4461 pRoamInfo->pEseBcnReportRsp->
4462 bcnRepBssInfo[i +
4463 lastSent].bcnReportFields.
4464 Bssid[0],
4465 pRoamInfo->pEseBcnReportRsp->
4466 bcnRepBssInfo[i +
4467 lastSent].bcnReportFields.
4468 Bssid[1],
4469 pRoamInfo->pEseBcnReportRsp->
4470 bcnRepBssInfo[i +
4471 lastSent].bcnReportFields.
4472 Bssid[2],
4473 pRoamInfo->pEseBcnReportRsp->
4474 bcnRepBssInfo[i +
4475 lastSent].bcnReportFields.
4476 Bssid[3],
4477 pRoamInfo->pEseBcnReportRsp->
4478 bcnRepBssInfo[i +
4479 lastSent].bcnReportFields.
4480 Bssid[4],
4481 pRoamInfo->pEseBcnReportRsp->
4482 bcnRepBssInfo[i +
4483 lastSent].bcnReportFields.
4484 Bssid[5]);
4485
4486 /* bcn report fields are copied */
4487 len =
4488 sizeof(pRoamInfo->pEseBcnReportRsp->
4489 bcnRepBssInfo[i +
4490 lastSent].
4491 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304492 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004493 (char *)&pRoamInfo->
4494 pEseBcnReportRsp->bcnRepBssInfo[i +
4495 lastSent].
4496 bcnReportFields, len);
4497 pos += len;
4498 freeBytes -= len;
4499
4500 /* Add 1 byte of ie len */
4501 len =
4502 pRoamInfo->pEseBcnReportRsp->
4503 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304504 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004505 pos += sizeof(len);
4506 freeBytes -= sizeof(len);
4507
4508 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304509 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004510 (char *)pRoamInfo->
4511 pEseBcnReportRsp->bcnRepBssInfo[i +
4512 lastSent].
4513 pBuf, len);
4514 pos += len;
4515 freeBytes -= len;
4516 }
4517
4518 wrqu.data.pointer = buf;
4519 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4520
4521 /* send the event */
4522 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4523 buf);
4524 lastSent += sendBss;
4525 }
4526 }
4527}
4528
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004529#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004530
4531/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304532 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4533 * @pHddStaCtx: Station Context
4534 *
4535 * API to check if the connection authentication type is 8021x_sha256.
4536 *
4537 * Return: bool
4538 */
4539#ifdef WLAN_FEATURE_11W
4540static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4541{
4542 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4543 pHddStaCtx->conn_info.authType;
4544}
4545#else
4546static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4547{
4548 return false;
4549}
4550#endif
4551
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304552/*
4553 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4554 * @adapter: Pointer to adapter context
4555 * @roam_info: Pointer to roam info
4556 *
4557 * Return: None
4558 */
4559static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4560 tCsrRoamInfo *roam_info)
4561{
4562 struct hdd_chan_change_params chan_change;
4563 struct cfg80211_bss *bss;
4564 struct net_device *dev = adapter->dev;
4565 struct wireless_dev *wdev = dev->ieee80211_ptr;
4566 struct wiphy *wiphy = wdev->wiphy;
4567 QDF_STATUS status;
4568
4569 hdd_info("channel switch for session:%d to channel:%d",
4570 adapter->sessionId, roam_info->chan_info.chan_id);
4571
4572 chan_change.chan = roam_info->chan_info.chan_id;
4573 chan_change.chan_params.ch_width =
4574 roam_info->chan_info.ch_width;
4575 chan_change.chan_params.sec_ch_offset =
4576 roam_info->chan_info.sec_ch_offset;
4577 chan_change.chan_params.center_freq_seg0 =
4578 roam_info->chan_info.band_center_freq1;
4579 chan_change.chan_params.center_freq_seg1 =
4580 roam_info->chan_info.band_center_freq2;
4581
4582 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4583 if (NULL == bss)
4584 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4585 else
4586 cfg80211_put_bss(wiphy, bss);
4587
4588 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4589 if (QDF_IS_STATUS_ERROR(status))
4590 hdd_err("channel change notification failed");
4591
4592 status = cds_set_hw_mode_on_channel_switch(adapter->sessionId);
4593 if (QDF_IS_STATUS_ERROR(status))
4594 hdd_info("set hw mode change not done");
4595}
4596
Komal Seelam98760ba2015-12-15 11:05:18 +05304597/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004598 * hdd_sme_roam_callback() - hdd sme roam callback
4599 * @pContext: pointer to adapter context
4600 * @pRoamInfo: pointer to roam info
4601 * @roamId: roam id
4602 * @roamStatus: roam status
4603 * @roamResult: roam result
4604 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304605 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004606 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304607QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004608hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4609 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4610{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304611 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004612 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4613 hdd_wext_state_t *pWextState = NULL;
4614 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304615 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004616 hdd_context_t *pHddCtx = NULL;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304617 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004619 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4620 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004621
4622 /* Sanity check */
4623 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004624 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304625 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004626 }
4627
4628 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4629 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4630
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304631 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304632 pAdapter->sessionId, roamStatus));
4633
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004634 switch (roamStatus) {
4635 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304636 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4637 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004638 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004639 break;
4640
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004641 /*
4642 * We did pre-auth,then we attempted a 11r or ese reassoc.
4643 * reassoc failed due to failure, timeout, reject from ap
4644 * in any case tell the OS, our carrier is off and mark
4645 * interface down.
4646 */
4647 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004648 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4649 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304650 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004651 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4652 roamStatus, roamResult);
4653 /*
4654 * Check if Mcast/Bcast Filters are set, if yes
4655 * clear the filters here.
4656 */
4657 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set ==
4658 true) {
4659 (WLAN_HDD_GET_CTX(pAdapter))->
4660 hdd_mcastbcast_filter_set = false;
4661 }
4662 pHddStaCtx->ft_carrier_on = false;
4663 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004664 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4665 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004666 break;
4667
4668 case eCSR_ROAM_FT_START:
4669 /*
4670 * When we roam for ESE and 11r, we dont want the OS to be
4671 * informed that the link is down. So mark the link ready for
4672 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4673 * be received. Where in we will not mark the link down
4674 * Also we want to stop tx at this point when we will be
4675 * doing disassoc at this time. This saves 30-60 msec
4676 * after reassoc.
4677 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004678 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004679 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4680 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004681 wlan_hdd_netif_queue_control(pAdapter,
4682 WLAN_NETIF_TX_DISABLE,
4683 WLAN_CONTROL_PATH);
4684 status = hdd_roam_deregister_sta(pAdapter,
4685 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304686 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304687 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688 pHddStaCtx->ft_carrier_on = true;
4689 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004690 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4691 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004692 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004693 case eCSR_ROAM_NAPI_OFF:
4694 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4695 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004696 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004697 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004699 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004700 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004701 wlan_hdd_netif_queue_control(pAdapter,
4702 WLAN_NETIF_TX_DISABLE,
4703 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004705 wlan_hdd_netif_queue_control(pAdapter,
4706 WLAN_NETIF_CARRIER_OFF,
4707 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004709 break;
4710 case eCSR_ROAM_LOSTLINK:
4711 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004712 hdd_info("Roaming started due to connection lost");
4713 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004714 wlan_hdd_netif_queue_control(pAdapter,
4715 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4716 WLAN_CONTROL_PATH);
4717 break;
4718 }
4719 case eCSR_ROAM_DISASSOCIATED:
4720 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004721 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304722 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004723 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4724 roamStatus, roamResult);
4725 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4726 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4727 if (pHddCtx->hdd_mcastbcast_filter_set == true) {
4728 hdd_conf_mcastbcast_filter(pHddCtx, false);
4729
4730 if (true ==
4731 pHddCtx->sus_res_mcastbcast_filter_valid) {
4732 pHddCtx->configuredMcastBcastFilter =
4733 pHddCtx->sus_res_mcastbcast_filter;
4734 pHddCtx->
4735 sus_res_mcastbcast_filter_valid =
4736 false;
4737 }
4738
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004739 hdd_info("offload: disassociation happening, restoring configuredMcastBcastFilter");
4740 hdd_info("McastBcastFilter = %d",
4741 pHddCtx->configuredMcastBcastFilter);
4742 hdd_info("offload: already called mcastbcast filter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004743 (WLAN_HDD_GET_CTX(pAdapter))->
4744 hdd_mcastbcast_filter_set = false;
4745 }
4746 /* Call to clear any MC Addr List filter applied after
4747 * successful connection.
4748 */
4749 wlan_hdd_set_mc_addr_list(pAdapter, false);
4750 }
4751 break;
4752 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004753 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304754 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004755 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4756 roamStatus, roamResult);
4757 break;
4758 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004759 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 /*
4761 * To Do - address probable memory leak with WEP encryption upon
4762 * successful association.
4763 */
4764 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4765 /* Clear saved connection information in HDD */
4766 hdd_conn_remove_connect_info(
4767 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4768 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304769 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004770 hdd_association_completion_handler(pAdapter, pRoamInfo,
4771 roamId, roamStatus,
4772 roamResult);
4773#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4774 if (pRoamInfo)
4775 pRoamInfo->roamSynchInProgress = false;
4776#endif
4777 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004778 case eCSR_ROAM_CANCELLED:
4779 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004780 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304781 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004782 pRoamInfo,
4783 roamId,
4784 roamStatus,
4785 roamResult);
4786 break;
4787 case eCSR_ROAM_IBSS_IND:
4788 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4789 roamStatus, roamResult);
4790 break;
4791
4792 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304793 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004794 roam_roam_connect_status_update_handler(pAdapter,
4795 pRoamInfo,
4796 roamId,
4797 roamStatus,
4798 roamResult);
4799 break;
4800
4801 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304802 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004803 hdd_roam_mic_error_indication_handler(pAdapter,
4804 pRoamInfo,
4805 roamId,
4806 roamStatus,
4807 roamResult);
4808 break;
4809
4810 case eCSR_ROAM_SET_KEY_COMPLETE:
4811 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304812 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004813 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4814 roamId, roamStatus,
4815 roamResult);
4816 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4817 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004818 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004819 pHddStaCtx->hdd_ReassocScenario,
4820 pAdapter->sessionId);
4821 }
4822 }
4823#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4824 if (pRoamInfo != NULL)
4825 pRoamInfo->roamSynchInProgress = false;
4826#endif
4827 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004828
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004829 case eCSR_ROAM_FT_RESPONSE:
4830 hdd_send_ft_event(pAdapter);
4831 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004832
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004833 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304834 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4835 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004836 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304837 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004838 wlan_hdd_cfg80211_pmksa_candidate_notify(
4839 pAdapter, pRoamInfo, 1, false);
4840 }
4841 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004842
4843#ifdef FEATURE_WLAN_LFR_METRICS
4844 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4845 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304846 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4848 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304849 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004850 }
4851 break;
4852 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4853 /*
4854 * This event will notify pre-auth completion in case of success
4855 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304856 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004857 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4858 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304859 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004860 }
4861 break;
4862 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4863 /*
4864 * This event will notify pre-auth completion incase of failure.
4865 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304866 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004867 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4868 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304869 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004870 }
4871 break;
4872 case eCSR_ROAM_HANDOVER_SUCCESS:
4873 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004874 * It will be only invoked on success
4875 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304876 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004877 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4878 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304879 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004880 }
4881 break;
4882#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004883 case eCSR_ROAM_REMAIN_CHAN_READY:
4884 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4885 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004886#ifdef FEATURE_WLAN_TDLS
4887 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304888 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004889 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4890 roamId,
4891 roamStatus,
4892 roamResult);
4893 break;
4894 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4895 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4896 pRoamInfo->reasonCode);
4897 break;
4898#endif
4899#ifdef WLAN_FEATURE_11W
4900 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4901 hdd_indicate_unprot_mgmt_frame(pAdapter,
4902 pRoamInfo->nFrameLength,
4903 pRoamInfo->pbFrames,
4904 pRoamInfo->frameType);
4905 break;
4906#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004907#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004908 case eCSR_ROAM_TSM_IE_IND:
4909 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4910 pRoamInfo->tsmIe.state,
4911 pRoamInfo->tsmIe.msmt_interval);
4912 break;
4913
4914 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4915 {
4916 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4917 pHddStaCtx->conn_info.authType
4918 || eCSR_AUTH_TYPE_CCKM_RSN ==
4919 pHddStaCtx->conn_info.authType) {
4920 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4921 }
4922 break;
4923 }
4924
4925 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4926 {
4927 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4928 break;
4929 }
4930
4931 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4932 {
4933 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4934 break;
4935 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004936#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304937 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304938 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304939 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304940
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304941 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4942 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
4943 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
4944 pAdapter, pRoamInfo->pBssDesc);
4945 if (NULL == bss_status)
4946 hdd_info("UPDATE_SCAN_RESULT returned NULL");
4947 else
4948 cfg80211_put_bss(
4949#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4950 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4951#endif
4952 bss_status);
4953 }
4954 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004955 case eCSR_ROAM_NDP_STATUS_UPDATE:
4956 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
4957 roamResult);
4958 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004959 case eCSR_ROAM_START:
4960 hdd_info("Process ROAM_START from firmware");
4961 wlan_hdd_netif_queue_control(pAdapter,
4962 WLAN_NETIF_TX_DISABLE,
4963 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004964 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004965 cds_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004966 hdd_set_roaming_in_progress(true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004967 cds_restart_opportunistic_timer(true);
4968 break;
4969 case eCSR_ROAM_ABORT:
4970 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004971 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004972 wlan_hdd_netif_queue_control(pAdapter,
4973 WLAN_WAKE_ALL_NETIF_QUEUE,
4974 WLAN_CONTROL_PATH);
4975 cds_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004976 hdd_set_roaming_in_progress(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004977 break;
4978
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004979 default:
4980 break;
4981 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304982 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004983}
4984
4985/**
4986 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4987 * @auth_suite: auth suite
4988 *
4989 * Return: eCsrAuthType enumeration
4990 */
4991eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4992{
4993 eCsrAuthType auth_type;
4994 /* is the auth type supported? */
4995 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4996 auth_type = eCSR_AUTH_TYPE_RSN;
4997 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4998 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004999 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005000 /* Check for 11r FT Authentication with PSK */
5001 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5002 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5003 /* Check for 11R FT Authentication with 802.1X */
5004 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5005 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005006#ifdef FEATURE_WLAN_ESE
5007 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5008 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5009 } else
5010#endif /* FEATURE_WLAN_ESE */
5011#ifdef WLAN_FEATURE_11W
5012 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5013 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5014 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5015 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5016 } else
5017#endif
5018 {
5019 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5020 }
5021 return auth_type;
5022}
5023
5024/**
5025 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5026 * @auth_suite: auth suite
5027 *
5028 * Return: eCsrAuthType enumeration
5029 */
5030eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5031{
5032 eCsrAuthType auth_type;
5033 /* is the auth type supported? */
5034 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5035 auth_type = eCSR_AUTH_TYPE_WPA;
5036 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5037 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5038 } else
5039#ifdef FEATURE_WLAN_ESE
5040 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5041 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5042 } else
5043#endif /* FEATURE_WLAN_ESE */
5044 {
5045 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5046 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005047 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005048 return auth_type;
5049}
5050
5051/**
5052 * hdd_translate_rsn_to_csr_encryption_type() -
5053 * Translate RSN to CSR encryption type
5054 * @cipher_suite: cipher suite
5055 *
5056 * Return: eCsrEncryptionType enumeration
5057 */
5058eCsrEncryptionType
5059hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5060{
5061 eCsrEncryptionType cipher_type;
5062
5063 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5064 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5065 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5066 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5067 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5068 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5069 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5070 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5071 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5072 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5073 else
5074 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5075
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005076 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005077 return cipher_type;
5078}
5079
5080/**
5081 * hdd_translate_wpa_to_csr_encryption_type() -
5082 * Translate WPA to CSR encryption type
5083 * @cipher_suite: cipher suite
5084 *
5085 * Return: eCsrEncryptionType enumeration
5086 */
5087eCsrEncryptionType
5088hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5089{
5090 eCsrEncryptionType cipher_type;
5091
5092 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5093 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5094 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5095 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5096 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5097 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5098 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5099 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5100 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5101 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5102 else
5103 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5104
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005105 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005106 return cipher_type;
5107}
5108
5109/**
5110 * hdd_process_genie() - process gen ie
5111 * @pAdapter: pointer to adapter
5112 * @bssid: pointer to mac address
5113 * @pEncryptType: pointer to encryption type
5114 * @mcEncryptType: pointer to multicast encryption type
5115 * @pAuthType: pointer to auth type
5116 *
5117 * Return: 0 on success, error number otherwise
5118 */
5119static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5120 u8 *bssid,
5121 eCsrEncryptionType *pEncryptType,
5122 eCsrEncryptionType *mcEncryptType,
5123 eCsrAuthType *pAuthType,
5124#ifdef WLAN_FEATURE_11W
5125 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5126#endif
5127 uint16_t gen_ie_len, uint8_t *gen_ie)
5128{
5129 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305130 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005131 tDot11fIERSN dot11RSNIE;
5132 tDot11fIEWPA dot11WPAIE;
5133 uint32_t i;
5134 uint8_t *pRsnIe;
5135 uint16_t RSNIeLen;
5136 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5137 bool updatePMKCache = false;
5138
5139 /*
5140 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5141 * setting present flag to 0.
5142 */
5143 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5144 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5145
5146 /* Type check */
5147 if (gen_ie[0] == DOT11F_EID_RSN) {
5148 /* Validity checks */
5149 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5150 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005151 hdd_err("Invalid DOT11F RSN IE length :%d",
5152 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005153 return -EINVAL;
5154 }
5155 /* Skip past the EID byte and length byte */
5156 pRsnIe = gen_ie + 2;
5157 RSNIeLen = gen_ie_len - 2;
5158 /* Unpack the RSN IE */
5159 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5160 pRsnIe, RSNIeLen, &dot11RSNIE);
5161 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005162 hdd_info("pairwise cipher suite count: %d",
5163 dot11RSNIE.pwise_cipher_suite_count);
5164 hdd_info("authentication suite count: %d",
5165 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166 /* dot11RSNIE.akm_suite_count */
5167 /* Just translate the FIRST one */
5168 *pAuthType =
5169 hdd_translate_rsn_to_csr_auth_type(
5170 dot11RSNIE.akm_suites[0]);
5171 /* dot11RSNIE.pwise_cipher_suite_count */
5172 *pEncryptType =
5173 hdd_translate_rsn_to_csr_encryption_type(
5174 dot11RSNIE.pwise_cipher_suites[0]);
5175 /* dot11RSNIE.gp_cipher_suite_count */
5176 *mcEncryptType =
5177 hdd_translate_rsn_to_csr_encryption_type(
5178 dot11RSNIE.gp_cipher_suite);
5179#ifdef WLAN_FEATURE_11W
5180 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5181 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5182#endif
5183 /* Set the PMKSA ID Cache for this interface */
5184 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5185 if (is_zero_ether_addr(bssid)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005186 hdd_err("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005187 break;
5188 }
5189 updatePMKCache = true;
5190 /*
5191 * For right now, I assume setASSOCIATE() has passed
5192 * in the bssid.
5193 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305194 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305195 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305196 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005197 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5198 }
5199
5200 if (updatePMKCache) {
5201 /*
5202 * Calling csr_roam_set_pmkid_cache to configure the
5203 * PMKIDs into the cache.
5204 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005205 hdd_info("Calling sme_roam_set_pmkid_cache with cache entry %d.",
5206 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005207 /* Finally set the PMKSA ID Cache in CSR */
5208 result =
5209 sme_roam_set_pmkid_cache(halHandle,
5210 pAdapter->sessionId,
5211 PMKIDCache,
5212 dot11RSNIE.pmkid_count,
5213 false);
5214 }
5215 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5216 /* Validity checks */
5217 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5218 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005219 hdd_err("Invalid DOT11F WPA IE length :%d",
5220 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005221 return -EINVAL;
5222 }
5223 /* Skip past the EID and length byte - and four byte WiFi OUI */
5224 pRsnIe = gen_ie + 2 + 4;
5225 RSNIeLen = gen_ie_len - (2 + 4);
5226 /* Unpack the WPA IE */
5227 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
5228 pRsnIe, RSNIeLen, &dot11WPAIE);
5229 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005230 hdd_info("WPA unicast cipher suite count: %d",
5231 dot11WPAIE.unicast_cipher_count);
5232 hdd_info("WPA authentication suite count: %d",
5233 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005234 /* dot11WPAIE.auth_suite_count */
5235 /* Just translate the FIRST one */
5236 *pAuthType =
5237 hdd_translate_wpa_to_csr_auth_type(
5238 dot11WPAIE.auth_suites[0]);
5239 /* dot11WPAIE.unicast_cipher_count */
5240 *pEncryptType =
5241 hdd_translate_wpa_to_csr_encryption_type(
5242 dot11WPAIE.unicast_ciphers[0]);
5243 /* dot11WPAIE.unicast_cipher_count */
5244 *mcEncryptType =
5245 hdd_translate_wpa_to_csr_encryption_type(
5246 dot11WPAIE.multicast_cipher);
5247 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005248 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 return -EINVAL;
5250 }
5251 return 0;
5252}
5253
5254/**
5255 * hdd_set_genie_to_csr() - set genie to csr
5256 * @pAdapter: pointer to adapter
5257 * @RSNAuthType: pointer to auth type
5258 *
5259 * Return: 0 on success, error number otherwise
5260 */
5261int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5262{
5263 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5264 uint32_t status = 0;
5265 eCsrEncryptionType RSNEncryptType;
5266 eCsrEncryptionType mcRSNEncryptType;
5267#ifdef WLAN_FEATURE_11W
5268 uint8_t RSNMfpRequired = 0;
5269 uint8_t RSNMfpCapable = 0;
5270#endif
5271 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5272 /* MAC address of assoc peer */
5273 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305274 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005275 pWextState->roamProfile.BSSIDs.bssid,
5276 sizeof(bssid));
5277 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5278 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5279 /* continue */
5280 } else {
5281 return 0;
5282 }
5283 /* The actual processing may eventually be more extensive than this. */
5284 /* Right now, just consume any PMKIDs that are sent in by the app. */
5285 status = hdd_process_genie(pAdapter, bssid,
5286 &RSNEncryptType,
5287 &mcRSNEncryptType, RSNAuthType,
5288#ifdef WLAN_FEATURE_11W
5289 &RSNMfpRequired, &RSNMfpCapable,
5290#endif
5291 pWextState->WPARSNIE[1] + 2,
5292 pWextState->WPARSNIE);
5293 if (status == 0) {
5294 /*
5295 * Now copy over all the security attributes
5296 * you have parsed out.
5297 */
5298 pWextState->roamProfile.EncryptionType.numEntries = 1;
5299 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5300
5301 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5302 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5303 mcRSNEncryptType;
5304
Krunal Sonibe766b02016-03-10 13:00:44 -08005305 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005306 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5307 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5308 /*
5309 * For wpa none supplicant sends the WPA IE with unicast
5310 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5311 * multicast cipher as either AES/TKIP based on group
5312 * cipher configuration mentioned in the
5313 * wpa_supplicant.conf.
5314 */
5315
5316 /* Set the unicast cipher same as multicast cipher */
5317 pWextState->roamProfile.EncryptionType.encryptionType[0]
5318 = mcRSNEncryptType;
5319 }
5320#ifdef WLAN_FEATURE_11W
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005321 hdd_info("RSNMfpRequired = %d, RSNMfpCapable = %d",
5322 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005323 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5324 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5325#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005326 hdd_info("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
5327 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005328 }
5329 return 0;
5330}
5331
5332/**
5333 * hdd_set_csr_auth_type() - set csr auth type
5334 * @pAdapter: pointer to adapter
5335 * @RSNAuthType: auth type
5336 *
5337 * Return: 0 on success, error number otherwise
5338 */
5339int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5340{
5341 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5342 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5343 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005344
5345 pRoamProfile->AuthType.numEntries = 1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005346 hdd_info("pHddStaCtx->conn_info.authType = %d",
5347 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005348
5349 switch (pHddStaCtx->conn_info.authType) {
5350 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5351#ifdef FEATURE_WLAN_ESE
5352 case eCSR_AUTH_TYPE_CCKM_WPA:
5353 case eCSR_AUTH_TYPE_CCKM_RSN:
5354#endif
5355 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5356
5357 pRoamProfile->AuthType.authType[0] =
5358 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5359 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5360
5361#ifdef FEATURE_WLAN_ESE
5362 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5363 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5364 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005365 hdd_info("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005366 pRoamProfile->AuthType.authType[0] =
5367 eCSR_AUTH_TYPE_CCKM_WPA;
5368 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005369 hdd_info("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005370 pRoamProfile->AuthType.authType[0] =
5371 eCSR_AUTH_TYPE_CCKM_WPA;
5372 } else
5373#endif
5374 if ((pWextState->
5375 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5376 == IW_AUTH_KEY_MGMT_802_1X) {
5377 pRoamProfile->AuthType.authType[0] =
5378 eCSR_AUTH_TYPE_WPA;
5379 } else
5380 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5381 == IW_AUTH_KEY_MGMT_PSK) {
5382 pRoamProfile->AuthType.authType[0] =
5383 eCSR_AUTH_TYPE_WPA_PSK;
5384 } else {
5385 pRoamProfile->AuthType.authType[0] =
5386 eCSR_AUTH_TYPE_WPA_NONE;
5387 }
5388 }
5389 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5390#ifdef FEATURE_WLAN_ESE
5391 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5392 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5393 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005394 hdd_info("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 pRoamProfile->AuthType.authType[0] =
5396 eCSR_AUTH_TYPE_CCKM_RSN;
5397 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005398 hdd_info("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005399 pRoamProfile->AuthType.authType[0] =
5400 eCSR_AUTH_TYPE_CCKM_RSN;
5401 } else
5402#endif
5403
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005404 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5405 ((pWextState->
5406 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5407 == IW_AUTH_KEY_MGMT_802_1X)) {
5408 pRoamProfile->AuthType.authType[0] =
5409 eCSR_AUTH_TYPE_FT_RSN;
5410 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5411 &&
5412 ((pWextState->
5413 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5414 == IW_AUTH_KEY_MGMT_PSK)) {
5415 pRoamProfile->AuthType.authType[0] =
5416 eCSR_AUTH_TYPE_FT_RSN_PSK;
5417 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418
5419#ifdef WLAN_FEATURE_11W
5420 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5421 pRoamProfile->AuthType.authType[0] =
5422 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5423 } else if (RSNAuthType ==
5424 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5425 pRoamProfile->AuthType.authType[0] =
5426 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5427 } else
5428#endif
5429
5430 if ((pWextState->
5431 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5432 == IW_AUTH_KEY_MGMT_802_1X) {
5433 pRoamProfile->AuthType.authType[0] =
5434 eCSR_AUTH_TYPE_RSN;
5435 } else
5436 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5437 == IW_AUTH_KEY_MGMT_PSK) {
5438 pRoamProfile->AuthType.authType[0] =
5439 eCSR_AUTH_TYPE_RSN_PSK;
5440 } else {
5441 pRoamProfile->AuthType.authType[0] =
5442 eCSR_AUTH_TYPE_UNKNOWN;
5443 }
5444 }
5445 break;
5446
5447 case eCSR_AUTH_TYPE_SHARED_KEY:
5448
5449 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5450 break;
5451 default:
5452
5453#ifdef FEATURE_WLAN_ESE
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005454 hdd_info("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005455#endif /* FEATURE_WLAN_ESE */
5456 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5457 break;
5458 }
5459
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005460 hdd_info("Set roam Authtype to %d",
5461 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005462
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005463 return 0;
5464}
5465
5466/**
5467 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5468 * to the CSR roam profile.
5469 *
5470 * @dev: Pointer to the net device.
5471 * @info: Pointer to the iw_request_info.
5472 * @wrqu: Pointer to the iwreq_data.
5473 * @extra: Pointer to the data.
5474 *
5475 * Return: 0 for success, error number on failure
5476 */
5477static int __iw_set_essid(struct net_device *dev,
5478 struct iw_request_info *info,
5479 union iwreq_data *wrqu, char *extra)
5480{
5481 unsigned long rc;
5482 uint32_t status = 0;
5483 hdd_wext_state_t *pWextState;
5484 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5485 hdd_context_t *hdd_ctx;
5486 uint32_t roamId;
5487 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005488 eCsrAuthType RSNAuthType;
5489 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5490 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5491 int ret;
5492
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005493 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005494
5495 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5496 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305497 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005498 return ret;
5499
Krunal Sonibe766b02016-03-10 13:00:44 -08005500 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005501 pAdapter->device_mode != QDF_IBSS_MODE &&
5502 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005503 hdd_warn("device mode %s(%d) is not allowed",
5504 hdd_device_mode_to_string(pAdapter->device_mode),
5505 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005506 return -EINVAL;
5507 }
5508
5509 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5510
5511 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005512 hdd_info("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005513 return -EBUSY;
5514 }
5515 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5516 return -EINVAL;
5517
5518 pRoamProfile = &pWextState->roamProfile;
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005519 if (hdd_conn_is_connected(pHddStaCtx) ||
5520 (pAdapter->device_mode == QDF_IBSS_MODE)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305521 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005522
5523 /* Need to issue a disconnect to CSR. */
5524 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305525 qdf_status = sme_roam_disconnect(hHal, pAdapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005526 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5527
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305528 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005529 rc = wait_for_completion_timeout(&pAdapter->
5530 disconnect_comp_var,
5531 msecs_to_jiffies
5532 (WLAN_WAIT_TIME_DISCONNECT));
5533 if (!rc)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005534 hdd_err("Disconnect event timed out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 }
5536 }
5537
5538 /*
5539 * when cfg80211 defined, wpa_supplicant wext driver uses
5540 * zero-length, null-string ssid for force disconnection.
5541 * after disconnection (if previously connected) and cleaning ssid,
5542 * driver MUST return success.
5543 */
5544 if (0 == wrqu->essid.length)
5545 return 0;
5546
5547 status = hdd_wmm_get_uapsd_mask(pAdapter,
5548 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305549 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550 pWextState->roamProfile.uapsd_mask = 0;
5551
5552 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5553
5554 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5555 wrqu->essid.length;
5556
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305557 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305559 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 ssId), extra, wrqu->essid.length);
5561 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5562 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5563
5564 /* set gen ie */
5565 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5566
5567 /* set auth */
5568 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5569 }
5570#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005571 hdd_notice("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005572 if (pAdapter->wapi_info.nWapiMode) {
5573 switch (pAdapter->wapi_info.wapiAuthMode) {
5574 case WAPI_AUTH_MODE_PSK:
5575 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005576 hdd_notice("WAPI AUTH TYPE: PSK: %d",
5577 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 pRoamProfile->AuthType.numEntries = 1;
5579 pRoamProfile->AuthType.authType[0] =
5580 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5581 break;
5582 }
5583 case WAPI_AUTH_MODE_CERT:
5584 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005585 hdd_notice("WAPI AUTH TYPE: CERT: %d",
5586 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 pRoamProfile->AuthType.numEntries = 1;
5588 pRoamProfile->AuthType.authType[0] =
5589 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5590 break;
5591 }
5592 } /* End of switch */
5593 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5594 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005595 hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005596 pRoamProfile->EncryptionType.numEntries = 1;
5597 pRoamProfile->EncryptionType.encryptionType[0] =
5598 eCSR_ENCRYPT_TYPE_WPI;
5599 pRoamProfile->mcEncryptionType.numEntries = 1;
5600 pRoamProfile->mcEncryptionType.encryptionType[0] =
5601 eCSR_ENCRYPT_TYPE_WPI;
5602 }
5603 }
5604#endif /* FEATURE_WLAN_WAPI */
5605 /* if previous genIE is not NULL, update AssocIE */
5606 if (0 != pWextState->genIE.length) {
5607 memset(&pWextState->assocAddIE, 0,
5608 sizeof(pWextState->assocAddIE));
5609 memcpy(pWextState->assocAddIE.addIEdata,
5610 pWextState->genIE.addIEdata, pWextState->genIE.length);
5611 pWextState->assocAddIE.length = pWextState->genIE.length;
5612 pWextState->roamProfile.pAddIEAssoc =
5613 pWextState->assocAddIE.addIEdata;
5614 pWextState->roamProfile.nAddIEAssocLength =
5615 pWextState->assocAddIE.length;
5616
5617 /* clear previous genIE after use it */
5618 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5619 }
5620
5621 /*
5622 * Assumes it is not WPS Association by default, except when
5623 * pAddIEAssoc has WPS IE.
5624 */
5625 pWextState->roamProfile.bWPSAssociation = false;
5626
5627 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5628 pWextState->roamProfile.
5629 nAddIEAssocLength))
5630 pWextState->roamProfile.bWPSAssociation = true;
5631
5632 /* Disable auto BMPS entry by PMC until DHCP is done */
5633 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5634 true);
5635
5636 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5637
5638 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005639 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005640 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005641 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5642 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005643 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005644
Agrawal Ashish6b015762016-05-05 11:22:18 +05305645 /*
5646 * Change conn_state to connecting before sme_roam_connect(),
5647 * because sme_roam_connect() has a direct path to call
5648 * hdd_sme_roam_callback(), which will change the conn_state
5649 * If direct path, conn_state will be accordingly changed to
5650 * NotConnected or Associated by either
5651 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5652 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5653 * Connecting state will remain until it is completed.
5654 *
5655 * If connection state is not changed,
5656 * connection state will remain in eConnectionState_NotConnected state.
5657 * In hdd_association_completion_handler, "hddDisconInProgress" is
5658 * set to true if conn state is eConnectionState_NotConnected.
5659 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5660 * informed of connect result indication which is an issue.
5661 */
5662 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305663 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305664 hdd_conn_set_connection_state(pAdapter,
5665 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305666
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005667 status = sme_roam_connect(hHal, pAdapter->sessionId,
5668 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305669 if ((QDF_STATUS_SUCCESS != status) &&
5670 (QDF_STA_MODE == pAdapter->device_mode ||
5671 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5672 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5673 pAdapter->sessionId, status);
5674 /* change back to NotAssociated */
5675 hdd_conn_set_connection_state(pAdapter,
5676 eConnectionState_NotConnected);
5677 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005678 pRoamProfile->ChannelInfo.ChannelList = NULL;
5679 pRoamProfile->ChannelInfo.numOfChannels = 0;
5680
5681 EXIT();
5682 return status;
5683}
5684
5685/**
5686 * iw_set_essid() - set essid handler function
5687 * @dev: Pointer to the net device.
5688 * @info: Pointer to the iw_request_info.
5689 * @wrqu: Pointer to the iwreq_data.
5690 * @extra: Pointer to the data.
5691 *
5692 * Return: 0 for success, error number on failure
5693 */
5694int iw_set_essid(struct net_device *dev,
5695 struct iw_request_info *info,
5696 union iwreq_data *wrqu, char *extra)
5697{
5698 int ret;
5699
5700 cds_ssr_protect(__func__);
5701 ret = __iw_set_essid(dev, info, wrqu, extra);
5702 cds_ssr_unprotect(__func__);
5703
5704 return ret;
5705}
5706
5707/**
5708 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5709 * @dev: pointer to the net device
5710 * @info: pointer to the iw request info
5711 * @dwrq: pointer to iw_point
5712 * @extra: pointer to the data
5713 *
5714 * Return: 0 on success, error number otherwise
5715 */
5716static int __iw_get_essid(struct net_device *dev,
5717 struct iw_request_info *info,
5718 struct iw_point *dwrq, char *extra)
5719{
5720 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5721 hdd_context_t *hdd_ctx;
5722 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5723 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5724 int ret;
5725
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005726 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005727
5728 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5729 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305730 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005731 return ret;
5732
5733 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5734 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5735 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5736 || pHddStaCtx->conn_info.connState ==
5737 eConnectionState_IbssDisconnected)
5738 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5739 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5740 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5741 dwrq->length);
5742 dwrq->flags = 1;
5743 } else {
5744 memset(extra, 0, dwrq->length);
5745 dwrq->length = 0;
5746 dwrq->flags = 0;
5747 }
5748 EXIT();
5749 return 0;
5750}
5751
5752/**
5753 * iw_get_essid() - get essid handler function
5754 * @dev: Pointer to the net device.
5755 * @info: Pointer to the iw_request_info.
5756 * @wrqu: Pointer to the iwreq_data.
5757 * @extra: Pointer to the data.
5758 *
5759 * Return: 0 for success, error number on failure
5760 */
5761int iw_get_essid(struct net_device *dev,
5762 struct iw_request_info *info,
5763 struct iw_point *wrqu, char *extra)
5764{
5765 int ret;
5766
5767 cds_ssr_protect(__func__);
5768 ret = __iw_get_essid(dev, info, wrqu, extra);
5769 cds_ssr_unprotect(__func__);
5770
5771 return ret;
5772}
5773
5774/**
5775 * __iw_set_auth() -
5776 * This function sets the auth type received from the wpa_supplicant
5777 * @dev: pointer to the net device
5778 * @info: pointer to the iw request info
5779 * @wrqu: pointer to iwreq_data
5780 * @extra: pointer to the data
5781 *
5782 * Return: 0 on success, error number otherwise
5783 */
5784static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5785 union iwreq_data *wrqu, char *extra)
5786{
5787 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5788 hdd_context_t *hdd_ctx;
5789 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5790 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5791 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5792 eCsrEncryptionType mcEncryptionType;
5793 eCsrEncryptionType ucEncryptionType;
5794 int ret;
5795
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005796 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005797
5798 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5799 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305800 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005801 return ret;
5802
5803 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5804 case IW_AUTH_WPA_VERSION:
5805 pWextState->wpaVersion = wrqu->param.value;
5806 break;
5807
5808 case IW_AUTH_CIPHER_PAIRWISE:
5809 {
5810 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5811 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5812 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5813 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5814 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5815 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5816 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5817 if ((IW_AUTH_KEY_MGMT_802_1X
5818 ==
5819 (pWextState->
5820 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5821 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5822 pHddStaCtx->conn_info.authType))
5823 /*Dynamic WEP key */
5824 ucEncryptionType =
5825 eCSR_ENCRYPT_TYPE_WEP40;
5826 else
5827 /*Static WEP key */
5828 ucEncryptionType =
5829 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5830 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5831 if ((IW_AUTH_KEY_MGMT_802_1X
5832 ==
5833 (pWextState->
5834 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5835 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5836 pHddStaCtx->conn_info.authType))
5837 /*Dynamic WEP key */
5838 ucEncryptionType =
5839 eCSR_ENCRYPT_TYPE_WEP104;
5840 else
5841 /*Static WEP key */
5842 ucEncryptionType =
5843 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5844 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005845 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
5846 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005847 return -EINVAL;
5848 }
5849
5850 pRoamProfile->EncryptionType.numEntries = 1;
5851 pRoamProfile->EncryptionType.encryptionType[0] =
5852 ucEncryptionType;
5853 }
5854 break;
5855 case IW_AUTH_CIPHER_GROUP:
5856 {
5857 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5858 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5859 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5860 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5861 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5862 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5863 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5864 if ((IW_AUTH_KEY_MGMT_802_1X
5865 ==
5866 (pWextState->
5867 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5868 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5869 pHddStaCtx->conn_info.authType))
5870 mcEncryptionType =
5871 eCSR_ENCRYPT_TYPE_WEP40;
5872 else
5873 mcEncryptionType =
5874 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5875 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5876 /* Dynamic WEP keys won't work with shared keys */
5877 if ((IW_AUTH_KEY_MGMT_802_1X
5878 ==
5879 (pWextState->
5880 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5881 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5882 pHddStaCtx->conn_info.authType)) {
5883 mcEncryptionType =
5884 eCSR_ENCRYPT_TYPE_WEP104;
5885 } else {
5886 mcEncryptionType =
5887 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5888 }
5889 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005890 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005891 wrqu->param.value);
5892 return -EINVAL;
5893 }
5894
5895 pRoamProfile->mcEncryptionType.numEntries = 1;
5896 pRoamProfile->mcEncryptionType.encryptionType[0] =
5897 mcEncryptionType;
5898 }
5899 break;
5900
5901 case IW_AUTH_80211_AUTH_ALG:
5902 {
Jeff Johnson5a062372017-01-12 09:51:25 -08005903 /* Save the auth algo here and set auth type to SME
5904 * Roam profile in the iw_set_ap_address
5905 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005906 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5907 pHddStaCtx->conn_info.authType =
5908 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5909
5910 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5911 pHddStaCtx->conn_info.authType =
5912 eCSR_AUTH_TYPE_SHARED_KEY;
5913
5914 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5915 /*Not supported */
5916 pHddStaCtx->conn_info.authType =
5917 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5918 pWextState->roamProfile.AuthType.authType[0] =
5919 pHddStaCtx->conn_info.authType;
5920 }
5921 break;
5922
5923 case IW_AUTH_KEY_MGMT:
5924 {
5925#ifdef FEATURE_WLAN_ESE
5926#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5927 /*Check for CCKM AKM type */
5928 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005929 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005930 /* Set the CCKM bit in authKeyMgmt */
5931 /*
5932 * Right now, this breaks all ref to authKeyMgmt because
5933 * our code doesn't realize it is a "bitfield"
5934 */
5935 pWextState->authKeyMgmt |=
5936 IW_AUTH_KEY_MGMT_CCKM;
5937 /* Set the key management to 802.1X */
5938 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5939 pWextState->isESEConnection = true;
5940 /*
5941 * This is test code. I need to actually KNOW whether
5942 * this is an RSN Assoc or WPA.
5943 */
5944 pWextState->collectedAuthType =
5945 eCSR_AUTH_TYPE_CCKM_RSN;
5946 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5947 /* Save the key management */
5948 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5949 pWextState->collectedAuthType =
5950 eCSR_AUTH_TYPE_RSN;
5951 } else
5952 if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5953 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE;
5954 /* Save the key management anyway */
5955 pWextState->authKeyMgmt = wrqu->param.value;
5956 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
5957 /* Save the key management */
5958 pWextState->authKeyMgmt |=
5959 IW_AUTH_KEY_MGMT_802_1X;
5960 pWextState->collectedAuthType =
5961 eCSR_AUTH_TYPE_RSN;
5962 }
5963#else
5964 /* Save the key management */
5965 pWextState->authKeyMgmt = wrqu->param.value;
5966#endif /* FEATURE_WLAN_ESE */
5967 }
5968 break;
5969
5970 case IW_AUTH_TKIP_COUNTERMEASURES:
5971 {
5972 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005973 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005974 wrqu->param.value);
5975 pWextState->mTKIPCounterMeasures =
5976 TKIP_COUNTER_MEASURE_STARTED;
5977 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005978 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005979 wrqu->param.value);
5980 pWextState->mTKIPCounterMeasures =
5981 TKIP_COUNTER_MEASURE_STOPED;
5982 }
5983 }
5984 break;
5985 case IW_AUTH_DROP_UNENCRYPTED:
5986 case IW_AUTH_WPA_ENABLED:
5987 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5988 case IW_AUTH_ROAMING_CONTROL:
5989 case IW_AUTH_PRIVACY_INVOKED:
5990
5991 default:
5992
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005993 hdd_warn("called with unsupported auth type %d",
5994 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005995 break;
5996 }
5997
5998 EXIT();
5999 return 0;
6000}
6001
6002/**
6003 * iw_set_auth() - set auth callback function
6004 * @dev: Pointer to the net device.
6005 * @info: Pointer to the iw_request_info.
6006 * @wrqu: Pointer to the iwreq_data.
6007 * @extra: Pointer to the data.
6008 *
6009 * Return: 0 for success, error number on failure.
6010 */
6011int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6012 union iwreq_data *wrqu, char *extra)
6013{
6014 int ret;
6015
6016 cds_ssr_protect(__func__);
6017 ret = __iw_set_auth(dev, info, wrqu, extra);
6018 cds_ssr_unprotect(__func__);
6019
6020 return ret;
6021}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006022/**
6023 * __iw_get_auth() -
6024 * This function returns the auth type to the wpa_supplicant
6025 * @dev: pointer to the net device
6026 * @info: pointer to the iw request info
6027 * @wrqu: pointer to iwreq_data
6028 * @extra: pointer to the data
6029 *
6030 * Return: 0 on success, error number otherwise
6031 */
6032static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6033 union iwreq_data *wrqu, char *extra)
6034{
6035 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6036 hdd_context_t *hdd_ctx;
6037 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6038 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6039 int ret;
6040
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006041 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006042
6043 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6044 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306045 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006046 return ret;
6047
6048 switch (pRoamProfile->negotiatedAuthType) {
6049 case eCSR_AUTH_TYPE_WPA_NONE:
6050 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6051 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6052 break;
6053 case eCSR_AUTH_TYPE_WPA:
6054 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6055 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6056 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006059 case eCSR_AUTH_TYPE_RSN:
6060 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6061 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6062 break;
6063 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6064 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6065 break;
6066 case eCSR_AUTH_TYPE_SHARED_KEY:
6067 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6068 break;
6069 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006070 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006071 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6072 break;
6073 case eCSR_AUTH_TYPE_AUTOSWITCH:
6074 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6075 break;
6076 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006077 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006078 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6079 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006080
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006082 case eCSR_AUTH_TYPE_RSN_PSK:
6083#ifdef WLAN_FEATURE_11W
6084 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6085 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6086#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006087 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006088 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6089 return -EIO;
6090 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006091 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006092 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6093 return -EIO;
6094 }
6095 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6096 switch (pRoamProfile->negotiatedUCEncryptionType) {
6097 case eCSR_ENCRYPT_TYPE_NONE:
6098 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6099 break;
6100 case eCSR_ENCRYPT_TYPE_WEP40:
6101 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6102 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6103 break;
6104 case eCSR_ENCRYPT_TYPE_TKIP:
6105 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6106 break;
6107 case eCSR_ENCRYPT_TYPE_WEP104:
6108 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6109 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6110 break;
6111 case eCSR_ENCRYPT_TYPE_AES:
6112 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6113 break;
6114 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006115 hdd_notice("called with unknown auth type %d",
6116 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006117 return -EIO;
6118 }
6119 }
6120
6121 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6122 switch (pRoamProfile->negotiatedMCEncryptionType) {
6123 case eCSR_ENCRYPT_TYPE_NONE:
6124 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6125 break;
6126 case eCSR_ENCRYPT_TYPE_WEP40:
6127 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6128 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6129 break;
6130 case eCSR_ENCRYPT_TYPE_TKIP:
6131 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6132 break;
6133 case eCSR_ENCRYPT_TYPE_WEP104:
6134 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6135 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6136 break;
6137 case eCSR_ENCRYPT_TYPE_AES:
6138 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6139 break;
6140 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006141 hdd_info("called with unknown auth type %d",
6142 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006143 return -EIO;
6144 }
6145 }
6146
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006147 hdd_info("called with auth type %d",
6148 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006149 EXIT();
6150 return 0;
6151}
6152
6153/**
6154 * iw_get_auth() - get auth callback function
6155 * @dev: Pointer to the net device.
6156 * @info: Pointer to the iw_request_info.
6157 * @wrqu: Pointer to the iwreq_data.
6158 * @extra: Pointer to the data.
6159 *
6160 * Return: 0 for success, error number on failure.
6161 */
6162int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6163 union iwreq_data *wrqu, char *extra)
6164{
6165 int ret;
6166
6167 cds_ssr_protect(__func__);
6168 ret = __iw_get_auth(dev, info, wrqu, extra);
6169 cds_ssr_unprotect(__func__);
6170
6171 return ret;
6172}
6173
6174/**
6175 * __iw_set_ap_address() - set ap address
6176 * @dev: pointer to the net device
6177 * @info: pointer to the iw request info
6178 * @wrqu: pointer to iwreq_data
6179 * @extra: pointer to the data
6180 *
6181 * This function updates the HDD global station context connection info
6182 * BSSID with the MAC address received from the wpa_supplicant.
6183 *
6184 * Return: 0 on success, error number otherwise
6185 */
6186static int __iw_set_ap_address(struct net_device *dev,
6187 struct iw_request_info *info,
6188 union iwreq_data *wrqu, char *extra)
6189{
6190
6191 hdd_adapter_t *adapter;
6192 hdd_context_t *hdd_ctx;
6193 hdd_station_ctx_t *pHddStaCtx =
6194 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6195 uint8_t *pMacAddress = NULL;
6196 int ret;
6197
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006198 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006199
6200 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6201
6202 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6203 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306204 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006205 return ret;
6206
6207 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006208 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306209 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306210 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006211 EXIT();
6212
6213 return 0;
6214}
6215
6216/**
6217 * iw_set_ap_address() - set ap addresses callback function
6218 * @dev: Pointer to the net device.
6219 * @info: Pointer to the iw_request_info.
6220 * @wrqu: Pointer to the iwreq_data.
6221 * @extra: Pointer to the data.
6222 *
6223 * Return: 0 for success, error number on failure.
6224 */
6225int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6226 union iwreq_data *wrqu, char *extra)
6227{
6228 int ret;
6229
6230 cds_ssr_protect(__func__);
6231 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6232 cds_ssr_unprotect(__func__);
6233
6234 return ret;
6235}
6236
6237/**
6238 * __iw_get_ap_address() - get ap address
6239 * @dev: pointer to the net device
6240 * @info: pointer to the iw request info
6241 * @wrqu: pointer to iwreq_data
6242 * @extra: pointer to the data
6243 *
6244 * This function returns currently associated BSSID.
6245 *
6246 * Return: 0 on success, error number otherwise
6247 */
6248static int __iw_get_ap_address(struct net_device *dev,
6249 struct iw_request_info *info,
6250 union iwreq_data *wrqu, char *extra)
6251{
6252 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6253 hdd_context_t *hdd_ctx;
6254 hdd_station_ctx_t *pHddStaCtx =
6255 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6256 int ret;
6257
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006258 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006259
6260 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6261 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306262 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263 return ret;
6264
6265 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6266 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306267 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006268 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306269 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006270 } else {
6271 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6272 }
6273 EXIT();
6274 return 0;
6275}
6276
6277/**
6278 * iw_get_ap_address() - get ap addresses callback function
6279 * @dev: Pointer to the net device.
6280 * @info: Pointer to the iw_request_info.
6281 * @wrqu: Pointer to the iwreq_data.
6282 * @extra: Pointer to the data.
6283 *
6284 * Return: 0 for success, error number on failure.
6285 */
6286int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6287 union iwreq_data *wrqu, char *extra)
6288{
6289 int ret;
6290
6291 cds_ssr_protect(__func__);
6292 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6293 cds_ssr_unprotect(__func__);
6294
6295 return ret;
6296}