blob: 34dfdfc3b2be795bb11ccd6b66203e93d865735e [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;
1369 /*During the WLAN uninitialization,supplicant is stopped before the
1370 driver so not sending the status of the connection to supplicant */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001371 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372 wireless_send_event(dev, we_event, &wrqu, msg);
1373#ifdef FEATURE_WLAN_ESE
1374 if (eConnectionState_Associated ==
1375 pHddStaCtx->conn_info.connState) {
1376 if ((pRoamProfile->AuthType.authType[0] ==
1377 eCSR_AUTH_TYPE_CCKM_RSN) ||
1378 (pRoamProfile->AuthType.authType[0] ==
1379 eCSR_AUTH_TYPE_CCKM_WPA))
1380 hdd_send_new_ap_channel_info(dev, pAdapter,
1381 pCsrRoamInfo);
1382 }
1383#endif
1384 }
1385}
1386
1387/**
1388 * hdd_conn_remove_connect_info() - remove connection info
1389 * @pHddStaCtx: pointer to global HDD station context
1390 * @pCsrRoamInfo: pointer to roam info
1391 *
1392 * Return: none
1393 */
1394static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1395{
1396 /* Remove staId, bssId and peerMacAddress */
1397 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301398 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1399 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301400 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001401
1402 /* Clear all security settings */
1403 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1404 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1405 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1406
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301407 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1408 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 pHddStaCtx->conn_info.proxyARPService = 0;
1411
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301412 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001413}
1414
1415/**
1416 * hdd_roam_deregister_sta() - deregister station
1417 * @pAdapter: pointer to adapter
1418 * @staId: station identifier
1419 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301420 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001421 */
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001422QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301424 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1426
1427 if (eConnectionState_IbssDisconnected ==
1428 pHddStaCtx->conn_info.connState) {
1429 /*
1430 * Do not set the carrier off when the last peer leaves.
1431 * We will set the carrier off while stopping the IBSS.
1432 */
1433 }
1434
Leo Changfdb45c32016-10-28 11:09:23 -07001435 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
1436 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301437 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001438 hdd_err("cdp_peer_clear() failed for staID %d. Status(%d) [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301439 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301441 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442}
1443
1444/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301445 * hdd_print_bss_info() - print bss info
1446 * @hdd_sta_ctx: pointer to hdd station context
1447 *
1448 * Return: None
1449 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001450static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301451{
1452 uint32_t *cap_info;
1453
1454 hdd_info("WIFI DATA LOGGER");
1455 hdd_info("channel: %d",
1456 hdd_sta_ctx->conn_info.freq);
1457 hdd_info("dot11mode: %d",
1458 hdd_sta_ctx->conn_info.dot11Mode);
1459 hdd_info("AKM: %d",
1460 hdd_sta_ctx->conn_info.authType);
1461 hdd_info("ssid: %.*s",
1462 hdd_sta_ctx->conn_info.SSID.SSID.length,
1463 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1464 hdd_info("roam count: %d",
1465 hdd_sta_ctx->conn_info.roam_count);
1466 hdd_info("ant_info: %d",
1467 hdd_sta_ctx->conn_info.txrate.nss);
1468 hdd_info("datarate legacy %d",
1469 hdd_sta_ctx->conn_info.txrate.legacy);
1470 hdd_info("datarate mcs: %d",
1471 hdd_sta_ctx->conn_info.txrate.mcs);
1472 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1473 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1474 hdd_info("ht caps: %x", *cap_info);
1475 }
1476 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1477 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1478 hdd_info("vht caps: %x", *cap_info);
1479 }
1480 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1481 hdd_info("hs20 info: %x",
1482 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1483 hdd_info("signal: %d",
1484 hdd_sta_ctx->conn_info.signal);
1485 hdd_info("noise: %d",
1486 hdd_sta_ctx->conn_info.noise);
1487}
1488
1489/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001490 * hdd_dis_connect_handler() - disconnect event handler
1491 * @pAdapter: pointer to adapter
1492 * @pRoamInfo: pointer to roam info
1493 * @roamId: roam identifier
1494 * @roamStatus: roam status
1495 * @roamResult: roam result
1496 *
1497 * This function handles disconnect event:
1498 * 1. Disable transmit queues;
1499 * 2. Clean up internal connection states and data structures;
1500 * 3. Send disconnect indication to supplicant.
1501 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301502 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001503 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301504static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 tCsrRoamInfo *pRoamInfo,
1506 uint32_t roamId,
1507 eRoamCmdStatus roamStatus,
1508 eCsrRoamResult roamResult)
1509{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301510 QDF_STATUS status = QDF_STATUS_SUCCESS;
1511 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512 struct net_device *dev = pAdapter->dev;
1513 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1514 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1515 uint8_t sta_id;
1516 bool sendDisconInd = true;
1517
1518 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001519 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301520 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 }
1522 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001523 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001524 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1525 WLAN_CONTROL_PATH);
1526
1527 if (hdd_ipa_is_enabled(pHddCtx))
1528 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001529 HDD_IPA_STA_DISCONNECT,
1530 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531
1532#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1533 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1534#endif
1535
Nirav Shah1da77682016-05-03 20:16:39 +05301536 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1537 pAdapter->sessionId,
1538 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539
1540 /* HDD has initiated disconnect, do not send disconnect indication
1541 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301542 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001543 * to cfg80211_disconnected.
1544 */
1545 if ((eConnectionState_Disconnecting ==
1546 pHddStaCtx->conn_info.connState) ||
1547 (eConnectionState_NotConnected ==
1548 pHddStaCtx->conn_info.connState)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001549 hdd_notice("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001550 sendDisconInd = false;
1551 }
1552
1553 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1554 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555 hdd_conn_set_connection_state(pAdapter,
1556 eConnectionState_Disconnecting);
1557 }
1558
1559 hdd_clear_roam_profile_ie(pAdapter);
1560 hdd_wmm_init(pAdapter);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301561 hdd_info("Invoking packetdump deregistration API");
1562 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001563
1564 /* indicate 'disconnect' status to wpa_supplicant... */
1565 hdd_send_association_event(dev, pRoamInfo);
1566 /* indicate disconnected event to nl80211 */
1567 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1568 /*
1569 * Only send indication to kernel if not initiated
1570 * by kernel
1571 */
1572 if (sendDisconInd) {
1573 /*
1574 * To avoid wpa_supplicant sending "HANGED" CMD
1575 * to ICS UI.
1576 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001577 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1578 if (pRoamInfo->reasonCode ==
1579 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1580 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301581 wlan_hdd_cfg80211_indicate_disconnect(
1582 dev, false,
1583 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001584 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301585 wlan_hdd_cfg80211_indicate_disconnect(
1586 dev, false,
1587 WLAN_REASON_UNSPECIFIED
1588 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001589 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001590
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301591 hdd_info("sent disconnected event to nl80211, reason code %d",
1592 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1593 pRoamInfo->reasonCode :
1594 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001595 }
1596 /*
1597 * During the WLAN uninitialization,supplicant is stopped
1598 * before the driver so not sending the status of the
1599 * connection to supplicant.
1600 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001601 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001602#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001603 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604 if (global_p2p_connection_status ==
1605 P2P_CLIENT_CONNECTED_STATE_1) {
1606 global_p2p_connection_status =
1607 P2P_CLIENT_DISCONNECTED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001608 hdd_err("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001609 } else if (global_p2p_connection_status ==
1610 P2P_CLIENT_COMPLETED_STATE) {
1611 global_p2p_connection_status =
1612 P2P_NOT_ACTIVE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001613 hdd_err("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001614 }
1615 }
1616#endif
1617
1618 }
1619 }
1620
1621 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001622 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001623 if (hdd_remove_beacon_filter(pAdapter) != 0)
1624 hdd_err("hdd_remove_beacon_filter() failed");
1625
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001626 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301627 uint8_t i;
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001628 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301630 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301631 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1632 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301633 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001634 }
1635 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301636 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001637 for (i = 0; i < MAX_PEERS; i++) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301638 if (0 == pHddStaCtx->conn_info.staId[i])
1639 continue;
1640 sta_id = pHddStaCtx->conn_info.staId[i];
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001641 hdd_info("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301642 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301643 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001644 hdd_err("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301645 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301646 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301647 }
1648 /* set the staid and peer mac as 0, all other
1649 * reset are done in hdd_connRemoveConnectInfo.
1650 */
1651 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301652 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301653 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301654 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1655 pHddCtx->sta_to_adapter[sta_id] = NULL;
1656 }
1657 } else {
1658 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhc9941602016-08-09 16:06:22 +05301659
1660 /* clear scan cache for Link Lost */
1661 if (pRoamInfo && !pRoamInfo->reasonCode &&
1662 (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult)) {
1663 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1664 pHddStaCtx->conn_info.bssId.bytes);
1665 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1666 pHddStaCtx->conn_info.bssId.bytes);
1667 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301668 /* We should clear all sta register with TL,
1669 * for now, only one.
1670 */
1671 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301672 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001673 hdd_err("hdd_roam_deregister_sta() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301674 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301675 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301676 }
1677 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001678 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001679 /* Clear saved connection information in HDD */
1680 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
1682#ifdef WLAN_FEATURE_GTK_OFFLOAD
Krunal Sonibe766b02016-03-10 13:00:44 -08001683 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1684 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001685 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1686 sizeof(tSirGtkOffloadParams));
1687 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
1688 }
1689#endif
1690
1691#ifdef FEATURE_WLAN_TDLS
1692 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1693 wlan_hdd_tdls_disconnection_callback(pAdapter);
1694#endif
1695
Krunal Sonibe766b02016-03-10 13:00:44 -08001696 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1697 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001698 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1699 (pAdapter),
1700 pAdapter->sessionId);
1701 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301702 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 /* Unblock anyone waiting for disconnect to complete */
1704 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301705 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001706 return status;
1707}
1708
1709/**
1710 * hdd_set_peer_authorized_event() - set peer_authorized_event
1711 * @vdev_id: vdevid
1712 *
1713 * Return: None
1714 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001715static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001716{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301717 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718 hdd_adapter_t *adapter = NULL;
1719
1720 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1721 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001722 hdd_err("Invalid vdev_id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001723 }
1724 complete(&adapter->sta_authorized_event);
1725}
1726
1727/**
1728 * hdd_change_peer_state() - change peer state
1729 * @pAdapter: HDD adapter
1730 * @sta_state: peer state
1731 * @roam_synch_in_progress: roam synch in progress
1732 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301733 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301735QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 uint8_t sta_id,
1737 enum ol_txrx_peer_state sta_state,
1738 bool roam_synch_in_progress)
1739{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301740 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001741 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001742 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1743 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1744 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001745
1746 if (!pdev) {
1747 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301748 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001749 }
1750
1751 if (sta_id >= WLAN_MAX_STA_COUNT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001752 hdd_err("Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301753 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754 }
1755
Leo Changfdb45c32016-10-28 11:09:23 -07001756 peer = cdp_peer_find_by_local_id(soc, pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001757 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301758 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759
Leo Changfdb45c32016-10-28 11:09:23 -07001760 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001761 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001762 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001763 return QDF_STATUS_E_FAULT;
1764 }
1765
Leo Changfdb45c32016-10-28 11:09:23 -07001766 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301767 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001768 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301769 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001770 }
1771#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1772 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301773 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774#endif
1775
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001776 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001777#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1778 /* make sure event is reset */
1779 INIT_COMPLETION(pAdapter->sta_authorized_event);
1780#endif
1781
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001782 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001783 hdd_set_peer_authorized_event,
1784 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301785 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001786 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301787 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001788 }
1789
Krunal Sonibe766b02016-03-10 13:00:44 -08001790 if (pAdapter->device_mode == QDF_STA_MODE ||
1791 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001792#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001793 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 unsigned long rc;
1795
1796 /* wait for event from firmware to set the event */
1797 rc = wait_for_completion_timeout(
1798 &pAdapter->sta_authorized_event,
1799 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1800 if (!rc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001801 hdd_notice("timeout waiting for sta_authorized_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001802 }
Leo Changfdb45c32016-10-28 11:09:23 -07001803 vdev = cdp_peer_get_vdev(soc, peer);
1804 cdp_fc_vdev_unpause(soc, vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001805 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001806#endif
1807 }
1808 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301809 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001810}
1811
1812/**
1813 * hdd_roam_register_sta() - register station
1814 * @pAdapter: pointer to adapter
1815 * @pRoamInfo: pointer to roam info
1816 * @staId: station identifier
1817 * @pPeerMacAddress: peer MAC address
1818 * @pBssDesc: pointer to BSS description
1819 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301820 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001822QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 tCsrRoamInfo *pRoamInfo,
1824 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301825 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001826 tSirBssDescription *pBssDesc)
1827{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301828 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001829 struct ol_txrx_desc_type staDesc = { 0 };
1830 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001831 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001832 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1833 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834
1835 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301836 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001837
1838 /* Get the Station ID from the one saved during the association */
1839 staDesc.sta_id = staId;
1840
1841 /* set the QoS field appropriately */
1842 if (hdd_wmm_is_active(pAdapter))
1843 staDesc.is_qos_enabled = 1;
1844 else
1845 staDesc.is_qos_enabled = 0;
1846
1847#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001848 hdd_notice("WAPI STA Registered: %d",
1849 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001850 if (pAdapter->wapi_info.fIsWapiSta)
1851 staDesc.is_wapi_supported = 1;
1852 else
1853 staDesc.is_wapi_supported = 0;
1854#endif /* FEATURE_WLAN_WAPI */
1855
Dhanashri Atre50141c52016-04-07 13:15:29 -07001856 /* Register the vdev transmit and receive functions */
1857 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1858 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001859
1860 pAdapter->txrx_vdev = cdp_get_vdev_from_vdev_id(soc, pdev,
1861 pAdapter->sessionId);
1862 if (!pAdapter->txrx_vdev) {
1863 hdd_err("%s find vdev fail", __func__);
1864 return QDF_STATUS_E_FAILURE;
1865 }
1866
1867 txrx_ops.tx.tx = NULL;
1868 cdp_vdev_register(soc, pAdapter->txrx_vdev, pAdapter, &txrx_ops);
1869 if (!txrx_ops.tx.tx) {
1870 hdd_err("%s vdev register fail", __func__);
1871 return QDF_STATUS_E_FAILURE;
1872 }
1873
Dhanashri Atre50141c52016-04-07 13:15:29 -07001874 pAdapter->tx_fn = txrx_ops.tx.tx;
Leo Changfdb45c32016-10-28 11:09:23 -07001875 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301876 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001877 hdd_warn("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001878 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301879 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001880 }
1881
1882 if (!pRoamInfo->fAuthRequired) {
1883 /*
1884 * Connections that do not need Upper layer auth, transition
1885 * TLSHIM directly to 'Authenticated' state
1886 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301887 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001888 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001889 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1891 pRoamInfo->roamSynchInProgress
1892#else
1893 false
1894#endif
1895 );
1896
1897 hdd_conn_set_authenticated(pAdapter, true);
1898 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001899 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001900 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301901 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001903 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1905 pRoamInfo->roamSynchInProgress
1906#else
1907 false
1908#endif
1909 );
1910 hdd_conn_set_authenticated(pAdapter, false);
1911 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301912 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001913}
1914
1915/**
1916 * hdd_send_re_assoc_event() - send reassoc event
1917 * @dev: pointer to net device
1918 * @pAdapter: pointer to adapter
1919 * @pCsrRoamInfo: pointer to roam info
1920 * @reqRsnIe: pointer to RSN Information element
1921 * @reqRsnLength: length of RSN IE
1922 *
1923 * Return: none
1924 */
1925static void hdd_send_re_assoc_event(struct net_device *dev,
1926 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1927 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1928{
1929 unsigned int len = 0;
1930 u8 *pFTAssocRsp = NULL;
1931 uint8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Naveen Rawat14298b92015-11-25 16:27:41 -08001932 uint8_t *assoc_req_ies = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 uint32_t rspRsnLength = 0;
1934 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1936 uint8_t *buf_ptr, ssid_ie_len;
1937 struct cfg80211_bss *bss = NULL;
1938 uint8_t *final_req_ie = NULL;
1939 tCsrRoamConnectedProfile roam_profile;
1940 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1941
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001942 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1943
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001944 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001945 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001946 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 }
1948
Naveen Rawat14298b92015-11-25 16:27:41 -08001949 if (!assoc_req_ies) {
1950 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001951 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001952 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001953 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001954 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 goto done;
1956 }
1957
1958 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001959 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 goto done;
1961 }
1962
1963 pFTAssocRsp =
1964 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1965 pCsrRoamInfo->nAssocReqLength);
1966 if (pFTAssocRsp == NULL)
1967 goto done;
1968
1969 /* pFTAssocRsp needs to point to the IEs */
1970 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001971 hdd_info("AssocRsp is now at %02x%02x",
1972 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001973
1974 /*
1975 * Active session count is decremented upon disconnection, but during
1976 * roaming, there is no disconnect indication and hence active session
1977 * count is not decremented.
1978 * After roaming is completed, active session count is incremented
1979 * as a part of connect indication but effectively after roaming the
1980 * active session count should still be the same and hence upon
1981 * successful reassoc decrement the active session count here.
1982 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001983 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301984 cds_decr_session_set_pcl(pAdapter->device_mode,
1985 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001986
1987 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
1988 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1989 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301990 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1991 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001992
1993 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1994 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
1996 &roam_profile);
1997 bss = cfg80211_get_bss(pAdapter->wdev.wiphy, chan,
1998 pCsrRoamInfo->bssid.bytes,
1999 &roam_profile.SSID.ssId[0], roam_profile.SSID.length,
Ryan Hsu535d16a2016-01-18 16:45:12 -08002000#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002001 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Ryan Hsu535d16a2016-01-18 16:45:12 -08002002#else
2003 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
2004#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002005
2006 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002007 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 buf_ptr = buf_ssid_ie;
2009 *buf_ptr = SIR_MAC_SSID_EID;
2010 buf_ptr++;
2011 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2012 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302013 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002014 roam_profile.SSID.length);
2015 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08002016 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302017 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002018 buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 final_req_ie = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
2020 if (final_req_ie == NULL)
2021 goto done;
2022 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302023 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002024 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302025 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2026 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2027 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002028 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002029 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302030 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002031 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002032 cfg80211_roamed_bss(dev, bss,
2033 final_req_ie, (ssid_ie_len + reqRsnLength),
2034 rspRsnIe, rspRsnLength, GFP_KERNEL);
2035
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302036 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002037 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2038 pCsrRoamInfo->nAssocReqLength);
2039
2040 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302041 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002042 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2043
Prakash Dhavali989127d2016-11-29 14:56:44 +05302044 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002045 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2046 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002047 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002048done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002049 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002050 if (final_req_ie)
2051 kfree(final_req_ie);
2052 kfree(rspRsnIe);
Naveen Rawat14298b92015-11-25 16:27:41 -08002053 kfree(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002054}
2055
2056/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302057 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002058 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302059 *
2060 * Return: roam sync status if roaming offloaded else false
2061 */
2062#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002063bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302064{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002065 if (roaminfo)
2066 return roaminfo->roamSynchInProgress;
2067 else
2068 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302069}
2070#endif
2071
2072
2073/**
2074 * hdd_change_sta_state_authenticated()-
2075 * This function changes STA state to authenticated
2076 * @adapter: pointer to the adapter structure.
2077 * @roaminfo: pointer to the RoamInfo structure.
2078 *
2079 * This is called from hdd_RoamSetKeyCompleteHandler
2080 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2081 *
2082 * Return: 0 on success and errno on failure
2083 */
2084static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2085 tCsrRoamInfo *roaminfo)
2086{
2087 int ret;
Dustin Brownf660fb42016-09-09 12:04:00 -07002088 uint32_t timeout;
Govind Singhedc5cda2015-10-23 17:11:35 +05302089 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002090 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302091
Dustin Brownf660fb42016-09-09 12:04:00 -07002092 timeout = hddstactx->hdd_ReassocScenario ?
2093 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002094 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002095
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002096 hdd_info("Changing TL state to AUTHENTICATED for StaId= %d",
2097 hddstactx->conn_info.staId[0]);
Govind Singhedc5cda2015-10-23 17:11:35 +05302098
2099 /* Connections that do not need Upper layer authentication,
2100 * transition TL to 'Authenticated' state after the keys are set
2101 */
2102 ret = hdd_change_peer_state(adapter,
2103 hddstactx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002104 OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302105 hdd_is_roam_sync_in_progress(roaminfo));
2106 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002107 if ((QDF_STA_MODE == adapter->device_mode) ||
2108 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302109 sme_ps_enable_auto_ps_timer(
2110 WLAN_HDD_GET_HAL_CTX(adapter),
2111 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002112 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302113 }
2114
2115 return ret;
2116}
2117
2118/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 * hdd_roam_set_key_complete_handler() - Update the security parameters
2120 * @pAdapter: pointer to adapter
2121 * @pRoamInfo: pointer to roam info
2122 * @roamId: roam id
2123 * @roamStatus: roam status
2124 * @roamResult: roam result
2125 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302126 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002127 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302128static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002129 tCsrRoamInfo *pRoamInfo,
2130 uint32_t roamId,
2131 eRoamCmdStatus roamStatus,
2132 eCsrRoamResult roamResult)
2133{
2134 eCsrEncryptionType connectedCipherAlgo;
2135 bool fConnected = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302136 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002137 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302138 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(pAdapter);
2139 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
2140
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141 ENTER();
2142
2143 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002144 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302145 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 }
2147 /*
2148 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2149 * then go to 'authenticated'. For all other authentication types
2150 * (those that do not require upper layer authentication) we can put TL
2151 * directly into 'authenticated' state.
2152 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002153 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 MAC_ADDRESS_STR, roamStatus, roamResult,
2155 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2156
2157 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2158 &connectedCipherAlgo);
2159 if (fConnected) {
Krunal Sonibe766b02016-03-10 13:00:44 -08002160 if (QDF_IBSS_MODE == pAdapter->device_mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002161 uint8_t staId;
2162
Anurag Chouhanc5548422016-02-24 18:33:27 +05302163 if (qdf_is_macaddr_broadcast(&pRoamInfo->peerMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002164 pHddStaCtx->roam_info.roamingState =
2165 HDD_ROAM_STATE_NONE;
2166 } else {
Deepak Dhamdhere5872c8c2016-06-02 15:51:47 -07002167 qdf_status = hdd_get_peer_sta_id(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002168 pHddStaCtx,
2169 &pRoamInfo->peerMac,
2170 &staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302171 if (QDF_STATUS_SUCCESS == qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002172 hdd_info("WLAN TL STA Ptk Installed for STAID=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 staId);
2174 pHddStaCtx->roam_info.roamingState =
2175 HDD_ROAM_STATE_NONE;
2176 }
2177 }
2178 } else {
2179 /*
2180 * TODO: Considering getting a state machine in
Govind Singhedc5cda2015-10-23 17:11:35 +05302181 * HDD later.This routine is invoked twice.
2182 * 1)set PTK 2)set GTK.The following if
2183 * statement will be TRUE when setting GTK.
2184 * At this time we don't handle the state in detail.
2185 * Related CR: 174048 - TL not in authenticated state
2186 */
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302187 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302188 pHddStaCtx->conn_info.gtk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302189 /*
2190 * PTK exchange happens in preauthentication
2191 * itself if key_mgmt is FT-PSK, ptk_installed
2192 * was false as there is no set PTK after
2193 * roaming. STA TL state moves to authenticated
2194 * only if ptk_installed is true. So, make
2195 * ptk_installed to true in case of 11R roaming.
2196 */
2197 if (csr_neighbor_roam_is11r_assoc(mac_ctx,
2198 pAdapter->sessionId))
2199 pHddStaCtx->conn_info.ptk_installed =
2200 true;
2201 } else {
Govind Singhedc5cda2015-10-23 17:11:35 +05302202 pHddStaCtx->conn_info.ptk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302203 }
Govind Singhedc5cda2015-10-23 17:11:35 +05302204
2205 /* In WPA case move STA to authenticated when
2206 * ptk is installed.Earlier in WEP case STA
2207 * was moved to AUTHENTICATED prior to setting
2208 * the unicast key and it was resulting in sending
2209 * few un-encrypted packet. Now in WEP case
2210 * STA state will be moved to AUTHENTICATED
2211 * after we set the unicast and broadcast key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002212 */
Govind Singhedc5cda2015-10-23 17:11:35 +05302213 if ((pHddStaCtx->conn_info.ucEncryptionType ==
2214 eCSR_ENCRYPT_TYPE_WEP40) ||
2215 (pHddStaCtx->conn_info.ucEncryptionType ==
2216 eCSR_ENCRYPT_TYPE_WEP104) ||
2217 (pHddStaCtx->conn_info.ucEncryptionType ==
2218 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2219 (pHddStaCtx->conn_info.ucEncryptionType ==
2220 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2221 if (pHddStaCtx->conn_info.gtk_installed &&
2222 pHddStaCtx->conn_info.ptk_installed)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302223 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302224 hdd_change_sta_state_authenticated(pAdapter,
2225 pRoamInfo);
2226 } else if (pHddStaCtx->conn_info.ptk_installed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302227 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05302228 hdd_change_sta_state_authenticated(pAdapter,
2229 pRoamInfo);
2230 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002231
Govind Singhedc5cda2015-10-23 17:11:35 +05302232 if (pHddStaCtx->conn_info.gtk_installed &&
2233 pHddStaCtx->conn_info.ptk_installed) {
2234 pHddStaCtx->conn_info.gtk_installed = false;
2235 pHddStaCtx->conn_info.ptk_installed = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002236 }
2237
2238 pHddStaCtx->roam_info.roamingState =
Govind Singhedc5cda2015-10-23 17:11:35 +05302239 HDD_ROAM_STATE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002240 }
2241 } else {
2242 /*
2243 * possible disassoc after issuing set key and waiting
2244 * set key complete.
2245 */
2246 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2247 }
2248
2249 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302250 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002251}
2252
2253/**
2254 * hdd_perform_roam_set_key_complete() - perform set key complete
2255 * @pAdapter: pointer to adapter
2256 *
2257 * Return: none
2258 */
2259void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2260{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302261 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2263 tCsrRoamInfo roamInfo;
2264 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302265 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302266 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302267 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302268 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002269
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302270 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 hdd_roam_set_key_complete_handler(pAdapter,
2272 &roamInfo,
2273 pHddStaCtx->roam_info.roamId,
2274 pHddStaCtx->roam_info.roamStatus,
2275 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302276 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002277 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002278
2279 pHddStaCtx->roam_info.deferKeyComplete = false;
2280}
2281
2282/**
2283 * hdd_association_completion_handler() - association completion handler
2284 * @pAdapter: pointer to adapter
2285 * @pRoamInfo: pointer to roam info
2286 * @roamId: roam id
2287 * @roamStatus: roam status
2288 * @roamResult: roam result
2289 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302290 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002291 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302292static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002293 tCsrRoamInfo *pRoamInfo,
2294 uint32_t roamId,
2295 eRoamCmdStatus roamStatus,
2296 eCsrRoamResult roamResult)
2297{
2298 struct net_device *dev = pAdapter->dev;
2299 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2300 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302301 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002302 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2303 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002304 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002305 bool hddDisconInProgress = false;
2306 unsigned long rc;
2307
2308 if (!pHddCtx) {
2309 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302310 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002311 }
2312
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302313 /* validate config */
2314 if (!pHddCtx->config) {
2315 hdd_err("config is NULL");
2316 return QDF_STATUS_E_NULL_VALUE;
2317 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002318 /* HDD has initiated disconnect, do not send connect result indication
2319 * to kernel as it will be handled by __cfg80211_disconnect.
2320 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302321 if (((eConnectionState_Disconnecting ==
2322 pHddStaCtx->conn_info.connState) ||
2323 (eConnectionState_NotConnected ==
2324 pHddStaCtx->conn_info.connState)) &&
2325 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2326 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002327 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002328 hddDisconInProgress = true;
2329 }
2330
2331 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2332 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002333 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302334 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002335 }
2336 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 hdd_conn_set_connection_state(pAdapter,
2338 eConnectionState_Associated);
2339 }
2340 /* Save the connection info from CSR... */
2341 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2342 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002343
2344 if (hdd_add_beacon_filter(pAdapter) != 0)
2345 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002346#ifdef FEATURE_WLAN_WAPI
2347 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2348 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2349 || pRoamInfo->u.pConnectedProfile->AuthType ==
2350 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2351 pAdapter->wapi_info.fIsWapiSta = 1;
2352 } else {
2353 pAdapter->wapi_info.fIsWapiSta = 0;
2354 }
2355#endif /* FEATURE_WLAN_WAPI */
2356
2357 /* Indicate 'connect' status to user space */
2358 hdd_send_association_event(dev, pRoamInfo);
2359
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002360 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002361 if (pHddCtx->miracast_value)
2362 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2363 }
2364
2365 /* Initialize the Linkup event completion variable */
2366 INIT_COMPLETION(pAdapter->linkup_event_var);
2367
2368 /*
2369 * Sometimes Switching ON the Carrier is taking time to activate
2370 * the device properly. Before allowing any packet to go up to
2371 * the application, device activation has to be ensured for
2372 * proper queue mapping by the kernel. we have registered net
2373 * device notifier for device change notification. With this we
2374 * will come to know that the device is getting
2375 * activated properly.
2376 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002377 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002378 /*
2379 * Enable Linkup Event Servicing which allows the net
2380 * device notifier to set the linkup event variable.
2381 */
2382 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002384 /* Switch on the Carrier to activate the device */
2385 wlan_hdd_netif_queue_control(pAdapter,
2386 WLAN_NETIF_CARRIER_ON,
2387 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002388
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002389 /*
2390 * Wait for the Link to up to ensure all the queues
2391 * are set properly by the kernel.
2392 */
2393 rc = wait_for_completion_timeout(
2394 &pAdapter->linkup_event_var,
2395 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2396 );
2397 if (!rc)
2398 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002399
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002400 /*
2401 * Disable Linkup Event Servicing - no more service
2402 * required from the net device notifier call.
2403 */
2404 pAdapter->isLinkUpSvcNeeded = false;
2405 } else {
2406 pHddStaCtx->ft_carrier_on = false;
2407 ft_carrier_on = true;
2408 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002409 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2410 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2411 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002412 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002413
2414 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2415
2416 if (hdd_ipa_is_enabled(pHddCtx))
2417 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002418 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 pRoamInfo->bssid.bytes);
2420
2421#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2422 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2423#endif
2424
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302425 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002426 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002427
Nirav Shah1da77682016-05-03 20:16:39 +05302428 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2429 pAdapter->sessionId,
2430 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2431
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 /*
2433 * For reassoc, the station is already registered, all we need
2434 * is to change the state of the STA in TL.
2435 * If authentication is required (WPA/WPA2/DWEP), change TL to
2436 * CONNECTED instead of AUTHENTICATED.
2437 */
2438 if (!pRoamInfo->fReassocReq) {
2439 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 u8 *pFTAssocRsp = NULL;
2441 unsigned int assocRsplen = 0;
2442 u8 *pFTAssocReq = NULL;
2443 unsigned int assocReqlen = 0;
2444 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2446 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2447
2448 /* add bss_id to cfg80211 data base */
2449 bss =
2450 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2451 pRoamInfo);
2452 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302453 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002454 wlan_hdd_netif_queue_control(pAdapter,
2455 WLAN_NETIF_CARRIER_OFF,
2456 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302457 if (!hddDisconInProgress) {
2458 /*
2459 * Here driver was not able to add bss
2460 * in cfg80211 database this can happen
2461 * if connected channel is not valid,
2462 * i.e reg domain was changed during
2463 * connection. Queue disconnect for the
2464 * session if disconnect is not in
2465 * progress.
2466 */
2467 hdd_err("Disconnecting...");
2468 sme_roam_disconnect(
2469 WLAN_HDD_GET_HAL_CTX(pAdapter),
2470 pAdapter->sessionId,
2471 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2472 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302473 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002474 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002475 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2476 eCSR_AUTH_TYPE_FT_RSN
2477 || pRoamInfo->u.pConnectedProfile->AuthType ==
2478 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2479
2480 /* Association Response */
2481 pFTAssocRsp =
2482 (u8 *) (pRoamInfo->pbFrames +
2483 pRoamInfo->nBeaconLength +
2484 pRoamInfo->nAssocReqLength);
2485 if (pFTAssocRsp != NULL) {
2486 /*
2487 * pFTAssocRsp needs to point to the IEs
2488 */
2489 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002490 hdd_info("AssocRsp is now at %02x%02x",
2491 (unsigned int)pFTAssocRsp[0],
2492 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 assocRsplen =
2494 pRoamInfo->nAssocRspLength -
2495 FT_ASSOC_RSP_IES_OFFSET;
2496 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002497 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002498 assocRsplen = 0;
2499 }
2500
2501 /* Association Request */
2502 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2503 pRoamInfo->nBeaconLength);
2504 if (pFTAssocReq != NULL) {
2505 if (!ft_carrier_on) {
2506 /*
2507 * pFTAssocReq needs to point to
2508 * the IEs
2509 */
2510 pFTAssocReq +=
2511 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002512 hdd_info("pFTAssocReq is now at %02x%02x",
2513 (unsigned int)
2514 pFTAssocReq[0],
2515 (unsigned int)
2516 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002517 assocReqlen =
2518 pRoamInfo->nAssocReqLength -
2519 FT_ASSOC_REQ_IES_OFFSET;
2520 } else {
2521 /*
2522 * This should contain only the
2523 * FTIEs
2524 */
2525 assocReqlen =
2526 pRoamInfo->nAssocReqLength;
2527 }
2528 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002529 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002530 assocReqlen = 0;
2531 }
2532
2533 if (ft_carrier_on) {
2534 if (!hddDisconInProgress) {
2535 /*
2536 * After roaming is completed,
2537 * active session count is
2538 * incremented as a part of
2539 * connect indication but
2540 * effectively the active
2541 * session count should still
2542 * be the same and hence upon
2543 * successful reassoc
2544 * decrement the active session
2545 * count here.
2546 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002547 if (!hdd_is_roam_sync_in_progress
2548 (pRoamInfo))
2549 cds_decr_session_set_pcl
2550 (pAdapter->device_mode,
2551 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002552 hdd_info("ft_carrier_on is %d, sending roamed indication",
2553 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002554 chan =
2555 ieee80211_get_channel
2556 (pAdapter->wdev.wiphy,
2557 (int)pRoamInfo->pBssDesc->
2558 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002559 hdd_info(
2560 "assocReqlen %d assocRsplen %d",
2561 assocReqlen,
2562 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002563
2564 hdd_notice(
2565 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302566 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302567 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302568 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002569 pFTAssocReq,
2570 assocReqlen);
2571
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002572 cfg80211_roamed(dev, chan,
2573 pRoamInfo->
2574 bssid.bytes,
2575 pFTAssocReq,
2576 assocReqlen,
2577 pFTAssocRsp,
2578 assocRsplen,
2579 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002580 wlan_hdd_send_roam_auth_event(
Prakash Dhavali989127d2016-11-29 14:56:44 +05302581 pAdapter,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002582 pRoamInfo->bssid.bytes,
2583 pFTAssocReq,
2584 assocReqlen,
2585 pFTAssocRsp,
2586 assocRsplen,
2587 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002588 }
2589 if (sme_get_ftptk_state
2590 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2591 pAdapter->sessionId)) {
2592 sme_set_ftptk_state
2593 (WLAN_HDD_GET_HAL_CTX
2594 (pAdapter),
2595 pAdapter->sessionId,
2596 false);
2597 pRoamInfo->fAuthRequired =
2598 false;
2599
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302600 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601 roam_info.bssid,
2602 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302603 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302604 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002605 roam_info.peerMac,
2606 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302607 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002608 pHddStaCtx->roam_info.roamId =
2609 roamId;
2610 pHddStaCtx->roam_info.
2611 roamStatus = roamStatus;
2612 pHddStaCtx->roam_info.
2613 deferKeyComplete = true;
2614 }
2615 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002616 hdd_info("ft_carrier_on is %d, sending connect indication",
2617 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302618 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002619 pRoamInfo->
2620 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302621 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002622 pFTAssocReq,
2623 assocReqlen,
2624 pFTAssocRsp,
2625 assocRsplen,
2626 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302627 GFP_KERNEL,
2628 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002629 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002630 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631 /*
2632 * wpa supplicant expecting WPA/RSN IE in
2633 * connect result.
2634 */
2635 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2636 (pAdapter),
2637 pAdapter->sessionId,
2638 &reqRsnLength,
2639 reqRsnIe);
2640
2641 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2642 (pAdapter),
2643 pAdapter->sessionId,
2644 &rspRsnLength,
2645 rspRsnIe);
2646 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002647 if (ft_carrier_on)
2648 hdd_send_re_assoc_event(dev,
2649 pAdapter,
2650 pRoamInfo,
2651 reqRsnIe,
2652 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002653 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002654 hdd_info("sending connect indication to nl80211:for bssid "
2655 MAC_ADDRESS_STR
2656 " result:%d and Status:%d",
2657 MAC_ADDR_ARRAY
2658 (pRoamInfo->bssid.bytes),
2659 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660
2661 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302662 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 pRoamInfo->
2664 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302665 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 reqRsnIe,
2667 reqRsnLength,
2668 rspRsnIe,
2669 rspRsnLength,
2670 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302671 GFP_KERNEL,
2672 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002673 }
2674 }
2675 }
2676 if (!hddDisconInProgress) {
2677 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002678 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002679 bss);
2680
2681 /*
2682 * Perform any WMM-related association
2683 * processing.
2684 */
2685 hdd_wmm_assoc(pAdapter, pRoamInfo,
2686 eCSR_BSS_TYPE_INFRASTRUCTURE);
2687
2688 /*
2689 * Start the Queue - Start tx queues before
2690 * hdd_roam_register_sta, since
2691 * hdd_roam_register_sta will flush any cached
2692 * data frames immediately.
2693 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002694 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002695 wlan_hdd_netif_queue_control(pAdapter,
2696 WLAN_WAKE_ALL_NETIF_QUEUE,
2697 WLAN_CONTROL_PATH);
2698
2699 /*
2700 * Register the Station with TL after associated
2701 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302702 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002703 pRoamInfo,
2704 pHddStaCtx->
2705 conn_info.
2706 staId[0],
2707 NULL,
2708 pRoamInfo->
2709 pBssDesc);
2710 }
2711 } else {
2712 /*
2713 * wpa supplicant expecting WPA/RSN IE in connect result
2714 * in case of reassociation also need to indicate it to
2715 * supplicant.
2716 */
2717 csr_roam_get_wpa_rsn_req_ie(
2718 WLAN_HDD_GET_HAL_CTX(pAdapter),
2719 pAdapter->sessionId,
2720 &reqRsnLength, reqRsnIe);
2721
2722 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2723 reqRsnIe, reqRsnLength);
2724 /* Reassoc successfully */
2725 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302726 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002727 hdd_change_peer_state(pAdapter,
2728 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002729 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002730#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2731 pRoamInfo->roamSynchInProgress
2732#else
2733 false
2734#endif
2735 );
2736 hdd_conn_set_authenticated(pAdapter, false);
2737 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002738 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2739 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302740 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002741 hdd_change_peer_state(pAdapter,
2742 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002743 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002744#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2745 pRoamInfo->roamSynchInProgress
2746#else
2747 false
2748#endif
2749 );
2750 hdd_conn_set_authenticated(pAdapter, true);
2751 }
2752
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302753 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754 /*
2755 * Perform any WMM-related association
2756 * processing
2757 */
2758 hdd_wmm_assoc(pAdapter, pRoamInfo,
2759 eCSR_BSS_TYPE_INFRASTRUCTURE);
2760 }
2761
2762 /* Start the tx queues */
2763#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2764 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002765 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002766#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002767 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002768 wlan_hdd_netif_queue_control(pAdapter,
2769 WLAN_WAKE_ALL_NETIF_QUEUE,
2770 WLAN_CONTROL_PATH);
2771 }
2772
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302773#ifdef FEATURE_WLAN_TDLS
2774 wlan_hdd_tdls_connection_callback(pAdapter);
2775#endif
2776
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302777 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002778 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302779 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002780 }
2781#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302782 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 sizeof(pAdapter->hdd_stats.hddPmfStats));
2784#endif
2785 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302786 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002787 hdd_wext_state_t *pWextState =
2788 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2789 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302790 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2791 " result:%d and Status:%d",
2792 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2793 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002794 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302795 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2796 " result:%d and Status:%d",
2797 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2798 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302799
2800 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2801 (pRoamInfo &&
2802 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2803 pRoamInfo->statusCode) ||
2804 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2805 pRoamInfo->statusCode) ||
2806 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2807 pRoamInfo->statusCode)))) {
2808 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2809 pRoamInfo ?
2810 pRoamInfo->bssid.bytes :
2811 pWextState->req_bssId.bytes);
2812 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2813 pRoamInfo ?
2814 pRoamInfo->bssid.bytes :
2815 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302816 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302817 }
2818
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002819 /*
2820 * CR465478: Only send up a connection failure result when CSR
2821 * has completed operation - with a ASSOCIATION_FAILURE status.
2822 */
2823 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2824 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302825 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002826 hdd_err("send connect failure to nl80211: for bssid "
2827 MAC_ADDRESS_STR
2828 " result:%d and Status:%d reasoncode %d",
2829 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2830 roamResult, roamStatus,
2831 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302832 pHddStaCtx->conn_info.assoc_status_code =
2833 pRoamInfo->statusCode;
2834 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -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);
2841
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,
4361 indicate the supplicant about measurement done */
4362 hdd_indicate_ese_bcn_report_no_results(
4363 pAdapter,
4364 pRoamInfo->pEseBcnReportRsp->
4365 measurementToken,
4366 pRoamInfo->pEseBcnReportRsp->flag,
4367 pRoamInfo->pEseBcnReportRsp->numBss);
4368 } else {
4369 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4370 memset(&wrqu, '\0', sizeof(wrqu));
4371 memset(buf, '\0', sizeof(buf));
4372 tot_bcn_ieLen = 0;
4373 sendBss = 0;
4374 pos = buf;
4375 freeBytes = IW_CUSTOM_MAX;
4376
4377 for (i = lastSent;
4378 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4379 len =
4380 bcnRepFieldSize + ieLenByte +
4381 pRoamInfo->pEseBcnReportRsp->
4382 bcnRepBssInfo[i].ieLen;
4383 if ((len + tot_bcn_ieLen) >
4384 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4385 break;
4386 }
4387 tot_bcn_ieLen += len;
4388 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004389 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4390 i, bcnRepFieldSize, 1,
4391 pRoamInfo->pEseBcnReportRsp->
4392 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 }
4394
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004395 hdd_info("Sending %d BSS Info", sendBss);
4396 hdd_info("CCXBCNREP=%d %d %d %d",
4397 pRoamInfo->pEseBcnReportRsp->measurementToken,
4398 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4399 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004400
4401 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4402 pRoamInfo->pEseBcnReportRsp->
4403 measurementToken,
4404 pRoamInfo->pEseBcnReportRsp->flag,
4405 sendBss);
4406 pos += nBytes;
4407 freeBytes -= nBytes;
4408
4409 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304410 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004411 sizeof(tot_bcn_ieLen));
4412 pos += sizeof(tot_bcn_ieLen);
4413 freeBytes -= sizeof(tot_bcn_ieLen);
4414
4415 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004416 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004417 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4418 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4419 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4420 pRoamInfo->pEseBcnReportRsp->
4421 bcnRepBssInfo[i +
4422 lastSent].bcnReportFields.
4423 ChanNum,
4424 pRoamInfo->pEseBcnReportRsp->
4425 bcnRepBssInfo[i +
4426 lastSent].bcnReportFields.
4427 Spare,
4428 pRoamInfo->pEseBcnReportRsp->
4429 bcnRepBssInfo[i +
4430 lastSent].bcnReportFields.
4431 MeasDuration,
4432 pRoamInfo->pEseBcnReportRsp->
4433 bcnRepBssInfo[i +
4434 lastSent].bcnReportFields.
4435 PhyType,
4436 pRoamInfo->pEseBcnReportRsp->
4437 bcnRepBssInfo[i +
4438 lastSent].bcnReportFields.
4439 RecvSigPower,
4440 pRoamInfo->pEseBcnReportRsp->
4441 bcnRepBssInfo[i +
4442 lastSent].bcnReportFields.
4443 ParentTsf,
4444 pRoamInfo->pEseBcnReportRsp->
4445 bcnRepBssInfo[i +
4446 lastSent].bcnReportFields.
4447 TargetTsf[0],
4448 pRoamInfo->pEseBcnReportRsp->
4449 bcnRepBssInfo[i +
4450 lastSent].bcnReportFields.
4451 TargetTsf[1],
4452 pRoamInfo->pEseBcnReportRsp->
4453 bcnRepBssInfo[i +
4454 lastSent].bcnReportFields.
4455 BcnInterval,
4456 pRoamInfo->pEseBcnReportRsp->
4457 bcnRepBssInfo[i +
4458 lastSent].bcnReportFields.
4459 CapabilityInfo,
4460 pRoamInfo->pEseBcnReportRsp->
4461 bcnRepBssInfo[i +
4462 lastSent].bcnReportFields.
4463 Bssid[0],
4464 pRoamInfo->pEseBcnReportRsp->
4465 bcnRepBssInfo[i +
4466 lastSent].bcnReportFields.
4467 Bssid[1],
4468 pRoamInfo->pEseBcnReportRsp->
4469 bcnRepBssInfo[i +
4470 lastSent].bcnReportFields.
4471 Bssid[2],
4472 pRoamInfo->pEseBcnReportRsp->
4473 bcnRepBssInfo[i +
4474 lastSent].bcnReportFields.
4475 Bssid[3],
4476 pRoamInfo->pEseBcnReportRsp->
4477 bcnRepBssInfo[i +
4478 lastSent].bcnReportFields.
4479 Bssid[4],
4480 pRoamInfo->pEseBcnReportRsp->
4481 bcnRepBssInfo[i +
4482 lastSent].bcnReportFields.
4483 Bssid[5]);
4484
4485 /* bcn report fields are copied */
4486 len =
4487 sizeof(pRoamInfo->pEseBcnReportRsp->
4488 bcnRepBssInfo[i +
4489 lastSent].
4490 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304491 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004492 (char *)&pRoamInfo->
4493 pEseBcnReportRsp->bcnRepBssInfo[i +
4494 lastSent].
4495 bcnReportFields, len);
4496 pos += len;
4497 freeBytes -= len;
4498
4499 /* Add 1 byte of ie len */
4500 len =
4501 pRoamInfo->pEseBcnReportRsp->
4502 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304503 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004504 pos += sizeof(len);
4505 freeBytes -= sizeof(len);
4506
4507 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304508 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004509 (char *)pRoamInfo->
4510 pEseBcnReportRsp->bcnRepBssInfo[i +
4511 lastSent].
4512 pBuf, len);
4513 pos += len;
4514 freeBytes -= len;
4515 }
4516
4517 wrqu.data.pointer = buf;
4518 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4519
4520 /* send the event */
4521 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4522 buf);
4523 lastSent += sendBss;
4524 }
4525 }
4526}
4527
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004528#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004529
4530/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304531 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4532 * @pHddStaCtx: Station Context
4533 *
4534 * API to check if the connection authentication type is 8021x_sha256.
4535 *
4536 * Return: bool
4537 */
4538#ifdef WLAN_FEATURE_11W
4539static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4540{
4541 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4542 pHddStaCtx->conn_info.authType;
4543}
4544#else
4545static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4546{
4547 return false;
4548}
4549#endif
4550
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304551/*
4552 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4553 * @adapter: Pointer to adapter context
4554 * @roam_info: Pointer to roam info
4555 *
4556 * Return: None
4557 */
4558static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4559 tCsrRoamInfo *roam_info)
4560{
4561 struct hdd_chan_change_params chan_change;
4562 struct cfg80211_bss *bss;
4563 struct net_device *dev = adapter->dev;
4564 struct wireless_dev *wdev = dev->ieee80211_ptr;
4565 struct wiphy *wiphy = wdev->wiphy;
4566 QDF_STATUS status;
4567
4568 hdd_info("channel switch for session:%d to channel:%d",
4569 adapter->sessionId, roam_info->chan_info.chan_id);
4570
4571 chan_change.chan = roam_info->chan_info.chan_id;
4572 chan_change.chan_params.ch_width =
4573 roam_info->chan_info.ch_width;
4574 chan_change.chan_params.sec_ch_offset =
4575 roam_info->chan_info.sec_ch_offset;
4576 chan_change.chan_params.center_freq_seg0 =
4577 roam_info->chan_info.band_center_freq1;
4578 chan_change.chan_params.center_freq_seg1 =
4579 roam_info->chan_info.band_center_freq2;
4580
4581 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4582 if (NULL == bss)
4583 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4584 else
4585 cfg80211_put_bss(wiphy, bss);
4586
4587 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4588 if (QDF_IS_STATUS_ERROR(status))
4589 hdd_err("channel change notification failed");
4590
4591 status = cds_set_hw_mode_on_channel_switch(adapter->sessionId);
4592 if (QDF_IS_STATUS_ERROR(status))
4593 hdd_info("set hw mode change not done");
4594}
4595
Komal Seelam98760ba2015-12-15 11:05:18 +05304596/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004597 * hdd_sme_roam_callback() - hdd sme roam callback
4598 * @pContext: pointer to adapter context
4599 * @pRoamInfo: pointer to roam info
4600 * @roamId: roam id
4601 * @roamStatus: roam status
4602 * @roamResult: roam result
4603 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304604 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004605 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304606QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004607hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4608 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4609{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304610 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004611 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4612 hdd_wext_state_t *pWextState = NULL;
4613 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304614 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004615 hdd_context_t *pHddCtx = NULL;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304616 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004617
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004618 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4619 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004620
4621 /* Sanity check */
4622 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004623 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304624 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004625 }
4626
4627 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4628 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4629
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304630 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304631 pAdapter->sessionId, roamStatus));
4632
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004633 switch (roamStatus) {
4634 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304635 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4636 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004637 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004638 break;
4639
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004640 /*
4641 * We did pre-auth,then we attempted a 11r or ese reassoc.
4642 * reassoc failed due to failure, timeout, reject from ap
4643 * in any case tell the OS, our carrier is off and mark
4644 * interface down.
4645 */
4646 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004647 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4648 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304649 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4651 roamStatus, roamResult);
4652 /*
4653 * Check if Mcast/Bcast Filters are set, if yes
4654 * clear the filters here.
4655 */
4656 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set ==
4657 true) {
4658 (WLAN_HDD_GET_CTX(pAdapter))->
4659 hdd_mcastbcast_filter_set = false;
4660 }
4661 pHddStaCtx->ft_carrier_on = false;
4662 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004663 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4664 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004665 break;
4666
4667 case eCSR_ROAM_FT_START:
4668 /*
4669 * When we roam for ESE and 11r, we dont want the OS to be
4670 * informed that the link is down. So mark the link ready for
4671 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4672 * be received. Where in we will not mark the link down
4673 * Also we want to stop tx at this point when we will be
4674 * doing disassoc at this time. This saves 30-60 msec
4675 * after reassoc.
4676 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004677 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004678 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4679 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004680 wlan_hdd_netif_queue_control(pAdapter,
4681 WLAN_NETIF_TX_DISABLE,
4682 WLAN_CONTROL_PATH);
4683 status = hdd_roam_deregister_sta(pAdapter,
4684 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304685 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304686 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004687 pHddStaCtx->ft_carrier_on = true;
4688 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004689 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4690 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004692 case eCSR_ROAM_NAPI_OFF:
4693 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4694 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004695 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004696 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004697 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004698 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004699 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004700 wlan_hdd_netif_queue_control(pAdapter,
4701 WLAN_NETIF_TX_DISABLE,
4702 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 wlan_hdd_netif_queue_control(pAdapter,
4705 WLAN_NETIF_CARRIER_OFF,
4706 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004707 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004708 break;
4709 case eCSR_ROAM_LOSTLINK:
4710 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004711 hdd_info("Roaming started due to connection lost");
4712 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004713 wlan_hdd_netif_queue_control(pAdapter,
4714 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4715 WLAN_CONTROL_PATH);
4716 break;
4717 }
4718 case eCSR_ROAM_DISASSOCIATED:
4719 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004720 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304721 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004722 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4723 roamStatus, roamResult);
4724 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4725 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4726 if (pHddCtx->hdd_mcastbcast_filter_set == true) {
4727 hdd_conf_mcastbcast_filter(pHddCtx, false);
4728
4729 if (true ==
4730 pHddCtx->sus_res_mcastbcast_filter_valid) {
4731 pHddCtx->configuredMcastBcastFilter =
4732 pHddCtx->sus_res_mcastbcast_filter;
4733 pHddCtx->
4734 sus_res_mcastbcast_filter_valid =
4735 false;
4736 }
4737
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004738 hdd_info("offload: disassociation happening, restoring configuredMcastBcastFilter");
4739 hdd_info("McastBcastFilter = %d",
4740 pHddCtx->configuredMcastBcastFilter);
4741 hdd_info("offload: already called mcastbcast filter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004742 (WLAN_HDD_GET_CTX(pAdapter))->
4743 hdd_mcastbcast_filter_set = false;
4744 }
4745 /* Call to clear any MC Addr List filter applied after
4746 * successful connection.
4747 */
4748 wlan_hdd_set_mc_addr_list(pAdapter, false);
4749 }
4750 break;
4751 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004752 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304753 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004754 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4755 roamStatus, roamResult);
4756 break;
4757 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004758 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004759 /*
4760 * To Do - address probable memory leak with WEP encryption upon
4761 * successful association.
4762 */
4763 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4764 /* Clear saved connection information in HDD */
4765 hdd_conn_remove_connect_info(
4766 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4767 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304768 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004769 hdd_association_completion_handler(pAdapter, pRoamInfo,
4770 roamId, roamStatus,
4771 roamResult);
4772#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4773 if (pRoamInfo)
4774 pRoamInfo->roamSynchInProgress = false;
4775#endif
4776 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004777 case eCSR_ROAM_CANCELLED:
4778 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004779 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304780 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004781 pRoamInfo,
4782 roamId,
4783 roamStatus,
4784 roamResult);
4785 break;
4786 case eCSR_ROAM_IBSS_IND:
4787 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4788 roamStatus, roamResult);
4789 break;
4790
4791 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304792 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004793 roam_roam_connect_status_update_handler(pAdapter,
4794 pRoamInfo,
4795 roamId,
4796 roamStatus,
4797 roamResult);
4798 break;
4799
4800 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304801 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802 hdd_roam_mic_error_indication_handler(pAdapter,
4803 pRoamInfo,
4804 roamId,
4805 roamStatus,
4806 roamResult);
4807 break;
4808
4809 case eCSR_ROAM_SET_KEY_COMPLETE:
4810 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304811 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4813 roamId, roamStatus,
4814 roamResult);
4815 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4816 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004817 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004818 pHddStaCtx->hdd_ReassocScenario,
4819 pAdapter->sessionId);
4820 }
4821 }
4822#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4823 if (pRoamInfo != NULL)
4824 pRoamInfo->roamSynchInProgress = false;
4825#endif
4826 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004827
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004828 case eCSR_ROAM_FT_RESPONSE:
4829 hdd_send_ft_event(pAdapter);
4830 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004831
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304833 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4834 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004835 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304836 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004837 wlan_hdd_cfg80211_pmksa_candidate_notify(
4838 pAdapter, pRoamInfo, 1, false);
4839 }
4840 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004841
4842#ifdef FEATURE_WLAN_LFR_METRICS
4843 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4844 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304845 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4847 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304848 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004849 }
4850 break;
4851 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4852 /*
4853 * This event will notify pre-auth completion in case of success
4854 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304855 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004856 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4857 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304858 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004859 }
4860 break;
4861 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4862 /*
4863 * This event will notify pre-auth completion incase of failure.
4864 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304865 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004866 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4867 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304868 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004869 }
4870 break;
4871 case eCSR_ROAM_HANDOVER_SUCCESS:
4872 /* This event is to notify handover success.
4873 It will be only invoked on success */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304874 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4876 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304877 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 }
4879 break;
4880#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 case eCSR_ROAM_REMAIN_CHAN_READY:
4882 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4883 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004884#ifdef FEATURE_WLAN_TDLS
4885 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304886 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004887 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4888 roamId,
4889 roamStatus,
4890 roamResult);
4891 break;
4892 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4893 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4894 pRoamInfo->reasonCode);
4895 break;
4896#endif
4897#ifdef WLAN_FEATURE_11W
4898 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4899 hdd_indicate_unprot_mgmt_frame(pAdapter,
4900 pRoamInfo->nFrameLength,
4901 pRoamInfo->pbFrames,
4902 pRoamInfo->frameType);
4903 break;
4904#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004905#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004906 case eCSR_ROAM_TSM_IE_IND:
4907 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4908 pRoamInfo->tsmIe.state,
4909 pRoamInfo->tsmIe.msmt_interval);
4910 break;
4911
4912 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4913 {
4914 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4915 pHddStaCtx->conn_info.authType
4916 || eCSR_AUTH_TYPE_CCKM_RSN ==
4917 pHddStaCtx->conn_info.authType) {
4918 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4919 }
4920 break;
4921 }
4922
4923 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4924 {
4925 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4926 break;
4927 }
4928
4929 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4930 {
4931 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4932 break;
4933 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004934#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304935 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304936 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304937 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304938
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304939 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4940 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
4941 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
4942 pAdapter, pRoamInfo->pBssDesc);
4943 if (NULL == bss_status)
4944 hdd_info("UPDATE_SCAN_RESULT returned NULL");
4945 else
4946 cfg80211_put_bss(
4947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4948 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4949#endif
4950 bss_status);
4951 }
4952 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07004953 case eCSR_ROAM_NDP_STATUS_UPDATE:
4954 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
4955 roamResult);
4956 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004957 case eCSR_ROAM_START:
4958 hdd_info("Process ROAM_START from firmware");
4959 wlan_hdd_netif_queue_control(pAdapter,
4960 WLAN_NETIF_TX_DISABLE,
4961 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004962 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004963 cds_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004964 hdd_set_roaming_in_progress(true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004965 cds_restart_opportunistic_timer(true);
4966 break;
4967 case eCSR_ROAM_ABORT:
4968 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004969 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004970 wlan_hdd_netif_queue_control(pAdapter,
4971 WLAN_WAKE_ALL_NETIF_QUEUE,
4972 WLAN_CONTROL_PATH);
4973 cds_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004974 hdd_set_roaming_in_progress(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07004975 break;
4976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977 default:
4978 break;
4979 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304980 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981}
4982
4983/**
4984 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4985 * @auth_suite: auth suite
4986 *
4987 * Return: eCsrAuthType enumeration
4988 */
4989eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4990{
4991 eCsrAuthType auth_type;
4992 /* is the auth type supported? */
4993 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4994 auth_type = eCSR_AUTH_TYPE_RSN;
4995 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4996 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004997 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 /* Check for 11r FT Authentication with PSK */
4999 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5000 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5001 /* Check for 11R FT Authentication with 802.1X */
5002 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5003 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005004#ifdef FEATURE_WLAN_ESE
5005 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5006 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5007 } else
5008#endif /* FEATURE_WLAN_ESE */
5009#ifdef WLAN_FEATURE_11W
5010 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5011 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5012 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5013 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5014 } else
5015#endif
5016 {
5017 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5018 }
5019 return auth_type;
5020}
5021
5022/**
5023 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5024 * @auth_suite: auth suite
5025 *
5026 * Return: eCsrAuthType enumeration
5027 */
5028eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5029{
5030 eCsrAuthType auth_type;
5031 /* is the auth type supported? */
5032 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5033 auth_type = eCSR_AUTH_TYPE_WPA;
5034 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5035 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5036 } else
5037#ifdef FEATURE_WLAN_ESE
5038 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5039 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5040 } else
5041#endif /* FEATURE_WLAN_ESE */
5042 {
5043 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5044 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005045 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005046 return auth_type;
5047}
5048
5049/**
5050 * hdd_translate_rsn_to_csr_encryption_type() -
5051 * Translate RSN to CSR encryption type
5052 * @cipher_suite: cipher suite
5053 *
5054 * Return: eCsrEncryptionType enumeration
5055 */
5056eCsrEncryptionType
5057hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5058{
5059 eCsrEncryptionType cipher_type;
5060
5061 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5062 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5063 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5064 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5065 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5066 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5067 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5068 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5069 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5070 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5071 else
5072 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5073
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005074 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005075 return cipher_type;
5076}
5077
5078/**
5079 * hdd_translate_wpa_to_csr_encryption_type() -
5080 * Translate WPA to CSR encryption type
5081 * @cipher_suite: cipher suite
5082 *
5083 * Return: eCsrEncryptionType enumeration
5084 */
5085eCsrEncryptionType
5086hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5087{
5088 eCsrEncryptionType cipher_type;
5089
5090 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5091 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5092 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5093 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5094 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5095 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5096 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5097 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5098 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5099 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5100 else
5101 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5102
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005103 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005104 return cipher_type;
5105}
5106
5107/**
5108 * hdd_process_genie() - process gen ie
5109 * @pAdapter: pointer to adapter
5110 * @bssid: pointer to mac address
5111 * @pEncryptType: pointer to encryption type
5112 * @mcEncryptType: pointer to multicast encryption type
5113 * @pAuthType: pointer to auth type
5114 *
5115 * Return: 0 on success, error number otherwise
5116 */
5117static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5118 u8 *bssid,
5119 eCsrEncryptionType *pEncryptType,
5120 eCsrEncryptionType *mcEncryptType,
5121 eCsrAuthType *pAuthType,
5122#ifdef WLAN_FEATURE_11W
5123 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5124#endif
5125 uint16_t gen_ie_len, uint8_t *gen_ie)
5126{
5127 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305128 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 tDot11fIERSN dot11RSNIE;
5130 tDot11fIEWPA dot11WPAIE;
5131 uint32_t i;
5132 uint8_t *pRsnIe;
5133 uint16_t RSNIeLen;
5134 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5135 bool updatePMKCache = false;
5136
5137 /*
5138 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5139 * setting present flag to 0.
5140 */
5141 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5142 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5143
5144 /* Type check */
5145 if (gen_ie[0] == DOT11F_EID_RSN) {
5146 /* Validity checks */
5147 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5148 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005149 hdd_err("Invalid DOT11F RSN IE length :%d",
5150 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005151 return -EINVAL;
5152 }
5153 /* Skip past the EID byte and length byte */
5154 pRsnIe = gen_ie + 2;
5155 RSNIeLen = gen_ie_len - 2;
5156 /* Unpack the RSN IE */
5157 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5158 pRsnIe, RSNIeLen, &dot11RSNIE);
5159 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005160 hdd_info("pairwise cipher suite count: %d",
5161 dot11RSNIE.pwise_cipher_suite_count);
5162 hdd_info("authentication suite count: %d",
5163 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005164 /*Here we have followed the apple base code,
5165 but probably I suspect we can do something different */
5166 /* 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 {
5903 /* Save the auth algo here and set auth type to SME Roam profile
5904 in the iw_set_ap_address */
5905 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5906 pHddStaCtx->conn_info.authType =
5907 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5908
5909 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5910 pHddStaCtx->conn_info.authType =
5911 eCSR_AUTH_TYPE_SHARED_KEY;
5912
5913 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5914 /*Not supported */
5915 pHddStaCtx->conn_info.authType =
5916 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5917 pWextState->roamProfile.AuthType.authType[0] =
5918 pHddStaCtx->conn_info.authType;
5919 }
5920 break;
5921
5922 case IW_AUTH_KEY_MGMT:
5923 {
5924#ifdef FEATURE_WLAN_ESE
5925#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5926 /*Check for CCKM AKM type */
5927 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005928 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005929 /* Set the CCKM bit in authKeyMgmt */
5930 /*
5931 * Right now, this breaks all ref to authKeyMgmt because
5932 * our code doesn't realize it is a "bitfield"
5933 */
5934 pWextState->authKeyMgmt |=
5935 IW_AUTH_KEY_MGMT_CCKM;
5936 /* Set the key management to 802.1X */
5937 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5938 pWextState->isESEConnection = true;
5939 /*
5940 * This is test code. I need to actually KNOW whether
5941 * this is an RSN Assoc or WPA.
5942 */
5943 pWextState->collectedAuthType =
5944 eCSR_AUTH_TYPE_CCKM_RSN;
5945 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5946 /* Save the key management */
5947 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5948 pWextState->collectedAuthType =
5949 eCSR_AUTH_TYPE_RSN;
5950 } else
5951 if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5952 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE;
5953 /* Save the key management anyway */
5954 pWextState->authKeyMgmt = wrqu->param.value;
5955 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
5956 /* Save the key management */
5957 pWextState->authKeyMgmt |=
5958 IW_AUTH_KEY_MGMT_802_1X;
5959 pWextState->collectedAuthType =
5960 eCSR_AUTH_TYPE_RSN;
5961 }
5962#else
5963 /* Save the key management */
5964 pWextState->authKeyMgmt = wrqu->param.value;
5965#endif /* FEATURE_WLAN_ESE */
5966 }
5967 break;
5968
5969 case IW_AUTH_TKIP_COUNTERMEASURES:
5970 {
5971 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005972 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005973 wrqu->param.value);
5974 pWextState->mTKIPCounterMeasures =
5975 TKIP_COUNTER_MEASURE_STARTED;
5976 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005977 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005978 wrqu->param.value);
5979 pWextState->mTKIPCounterMeasures =
5980 TKIP_COUNTER_MEASURE_STOPED;
5981 }
5982 }
5983 break;
5984 case IW_AUTH_DROP_UNENCRYPTED:
5985 case IW_AUTH_WPA_ENABLED:
5986 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5987 case IW_AUTH_ROAMING_CONTROL:
5988 case IW_AUTH_PRIVACY_INVOKED:
5989
5990 default:
5991
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005992 hdd_warn("called with unsupported auth type %d",
5993 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005994 break;
5995 }
5996
5997 EXIT();
5998 return 0;
5999}
6000
6001/**
6002 * iw_set_auth() - set auth callback function
6003 * @dev: Pointer to the net device.
6004 * @info: Pointer to the iw_request_info.
6005 * @wrqu: Pointer to the iwreq_data.
6006 * @extra: Pointer to the data.
6007 *
6008 * Return: 0 for success, error number on failure.
6009 */
6010int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6011 union iwreq_data *wrqu, char *extra)
6012{
6013 int ret;
6014
6015 cds_ssr_protect(__func__);
6016 ret = __iw_set_auth(dev, info, wrqu, extra);
6017 cds_ssr_unprotect(__func__);
6018
6019 return ret;
6020}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006021/**
6022 * __iw_get_auth() -
6023 * This function returns the auth type to the wpa_supplicant
6024 * @dev: pointer to the net device
6025 * @info: pointer to the iw request info
6026 * @wrqu: pointer to iwreq_data
6027 * @extra: pointer to the data
6028 *
6029 * Return: 0 on success, error number otherwise
6030 */
6031static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6032 union iwreq_data *wrqu, char *extra)
6033{
6034 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6035 hdd_context_t *hdd_ctx;
6036 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6037 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6038 int ret;
6039
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006040 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006041
6042 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6043 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306044 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006045 return ret;
6046
6047 switch (pRoamProfile->negotiatedAuthType) {
6048 case eCSR_AUTH_TYPE_WPA_NONE:
6049 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6050 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6051 break;
6052 case eCSR_AUTH_TYPE_WPA:
6053 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6054 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6055 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006056
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006057 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006058 case eCSR_AUTH_TYPE_RSN:
6059 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6060 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6061 break;
6062 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6063 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6064 break;
6065 case eCSR_AUTH_TYPE_SHARED_KEY:
6066 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6067 break;
6068 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006069 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006070 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6071 break;
6072 case eCSR_AUTH_TYPE_AUTOSWITCH:
6073 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6074 break;
6075 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006076 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006077 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6078 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006079
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006080 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006081 case eCSR_AUTH_TYPE_RSN_PSK:
6082#ifdef WLAN_FEATURE_11W
6083 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6084 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6085#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006086 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006087 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6088 return -EIO;
6089 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006090 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006091 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6092 return -EIO;
6093 }
6094 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6095 switch (pRoamProfile->negotiatedUCEncryptionType) {
6096 case eCSR_ENCRYPT_TYPE_NONE:
6097 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6098 break;
6099 case eCSR_ENCRYPT_TYPE_WEP40:
6100 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6101 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6102 break;
6103 case eCSR_ENCRYPT_TYPE_TKIP:
6104 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6105 break;
6106 case eCSR_ENCRYPT_TYPE_WEP104:
6107 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6108 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6109 break;
6110 case eCSR_ENCRYPT_TYPE_AES:
6111 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6112 break;
6113 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006114 hdd_notice("called with unknown auth type %d",
6115 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006116 return -EIO;
6117 }
6118 }
6119
6120 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6121 switch (pRoamProfile->negotiatedMCEncryptionType) {
6122 case eCSR_ENCRYPT_TYPE_NONE:
6123 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6124 break;
6125 case eCSR_ENCRYPT_TYPE_WEP40:
6126 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6127 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6128 break;
6129 case eCSR_ENCRYPT_TYPE_TKIP:
6130 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6131 break;
6132 case eCSR_ENCRYPT_TYPE_WEP104:
6133 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6134 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6135 break;
6136 case eCSR_ENCRYPT_TYPE_AES:
6137 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6138 break;
6139 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006140 hdd_info("called with unknown auth type %d",
6141 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006142 return -EIO;
6143 }
6144 }
6145
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006146 hdd_info("called with auth type %d",
6147 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006148 EXIT();
6149 return 0;
6150}
6151
6152/**
6153 * iw_get_auth() - get auth callback function
6154 * @dev: Pointer to the net device.
6155 * @info: Pointer to the iw_request_info.
6156 * @wrqu: Pointer to the iwreq_data.
6157 * @extra: Pointer to the data.
6158 *
6159 * Return: 0 for success, error number on failure.
6160 */
6161int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6162 union iwreq_data *wrqu, char *extra)
6163{
6164 int ret;
6165
6166 cds_ssr_protect(__func__);
6167 ret = __iw_get_auth(dev, info, wrqu, extra);
6168 cds_ssr_unprotect(__func__);
6169
6170 return ret;
6171}
6172
6173/**
6174 * __iw_set_ap_address() - set ap address
6175 * @dev: pointer to the net device
6176 * @info: pointer to the iw request info
6177 * @wrqu: pointer to iwreq_data
6178 * @extra: pointer to the data
6179 *
6180 * This function updates the HDD global station context connection info
6181 * BSSID with the MAC address received from the wpa_supplicant.
6182 *
6183 * Return: 0 on success, error number otherwise
6184 */
6185static int __iw_set_ap_address(struct net_device *dev,
6186 struct iw_request_info *info,
6187 union iwreq_data *wrqu, char *extra)
6188{
6189
6190 hdd_adapter_t *adapter;
6191 hdd_context_t *hdd_ctx;
6192 hdd_station_ctx_t *pHddStaCtx =
6193 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6194 uint8_t *pMacAddress = NULL;
6195 int ret;
6196
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006197 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006198
6199 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6200
6201 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6202 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306203 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006204 return ret;
6205
6206 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006207 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306208 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306209 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006210 EXIT();
6211
6212 return 0;
6213}
6214
6215/**
6216 * iw_set_ap_address() - set ap addresses callback function
6217 * @dev: Pointer to the net device.
6218 * @info: Pointer to the iw_request_info.
6219 * @wrqu: Pointer to the iwreq_data.
6220 * @extra: Pointer to the data.
6221 *
6222 * Return: 0 for success, error number on failure.
6223 */
6224int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6225 union iwreq_data *wrqu, char *extra)
6226{
6227 int ret;
6228
6229 cds_ssr_protect(__func__);
6230 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6231 cds_ssr_unprotect(__func__);
6232
6233 return ret;
6234}
6235
6236/**
6237 * __iw_get_ap_address() - get ap address
6238 * @dev: pointer to the net device
6239 * @info: pointer to the iw request info
6240 * @wrqu: pointer to iwreq_data
6241 * @extra: pointer to the data
6242 *
6243 * This function returns currently associated BSSID.
6244 *
6245 * Return: 0 on success, error number otherwise
6246 */
6247static int __iw_get_ap_address(struct net_device *dev,
6248 struct iw_request_info *info,
6249 union iwreq_data *wrqu, char *extra)
6250{
6251 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6252 hdd_context_t *hdd_ctx;
6253 hdd_station_ctx_t *pHddStaCtx =
6254 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6255 int ret;
6256
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006257 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006258
6259 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6260 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306261 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006262 return ret;
6263
6264 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6265 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306266 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006267 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306268 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006269 } else {
6270 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6271 }
6272 EXIT();
6273 return 0;
6274}
6275
6276/**
6277 * iw_get_ap_address() - get ap addresses callback function
6278 * @dev: Pointer to the net device.
6279 * @info: Pointer to the iw_request_info.
6280 * @wrqu: Pointer to the iwreq_data.
6281 * @extra: Pointer to the data.
6282 *
6283 * Return: 0 for success, error number on failure.
6284 */
6285int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6286 union iwreq_data *wrqu, char *extra)
6287{
6288 int ret;
6289
6290 cds_ssr_protect(__func__);
6291 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6292 cds_ssr_unprotect(__func__);
6293
6294 return ret;
6295}