blob: b192e59b6f8227e4c62b1f05533a43a5d3a5f3f8 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_assoc.c
30 *
31 * WLAN Host Device Driver implementation
32 *
33 */
34
35#include "wlan_hdd_includes.h"
36#include <ani_global.h>
37#include "dot11f.h"
38#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053039#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include <linux/ieee80211.h>
41#include <linux/wireless.h>
42#include <linux/etherdevice.h>
43#include <net/cfg80211.h>
44#include "wlan_hdd_cfg80211.h"
45#include "csr_inside_api.h"
46#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_api.h"
49#include "wlan_hdd_hostapd.h"
50#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070051#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070052#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <cds_sched.h>
54#include "cds_concurrency.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053055#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070057#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070058#include <cdp_txrx_cmn.h>
59#include <cdp_txrx_flow_ctrl_legacy.h>
60#include <cdp_txrx_peer_ops.h>
61#include <cdp_txrx_misc.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053062#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080063#include <wlan_hdd_object_manager.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080064
65/* These are needed to recognize WPA and RSN suite types */
66#define HDD_WPA_OUI_SIZE 4
67#define HDD_RSN_OUI_SIZE 4
68uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
69uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
70uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
71uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
72uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
73uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
74
75#ifdef FEATURE_WLAN_ESE
76/* CCKM */
77uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
78/* CCKM */
79uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
80#endif /* FEATURE_WLAN_ESE */
81
82/* group cipher */
83uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
84
85/* WEP-40 or RSN */
86uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
87
88/* TKIP or RSN-PSK */
89uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
90
91/* Reserved */
92uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
93
94/* AES-CCMP */
95uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
96
97/* WEP-104 */
98uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
99
100#ifdef WLAN_FEATURE_11W
101/* RSN-PSK-SHA256 */
102uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
103
104/* RSN-8021X-SHA256 */
105uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
106#endif
107
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108/* Offset where the EID-Len-IE, start. */
109#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
110#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800111
112#define BEACON_FRAME_IES_OFFSET 12
113#define HDD_PEER_AUTHORIZE_WAIT 10
114
115/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700116 * beacon_filter_table - table of IEs used for beacon filtering
117 */
118static const int beacon_filter_table[] = {
119 SIR_MAC_DS_PARAM_SET_EID,
120 SIR_MAC_ERP_INFO_EID,
121 SIR_MAC_EDCA_PARAM_SET_EID,
122 SIR_MAC_QOS_CAPABILITY_EID,
123 SIR_MAC_HT_INFO_EID,
124 SIR_MAC_VHT_OPMODE_EID,
125 SIR_MAC_VHT_OPERATION_EID,
126};
127
128/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800129 * hdd_conn_set_authenticated() - set authentication state
130 * @pAdapter: pointer to the adapter
131 * @authState: authentication state
132 *
133 * This function updates the global HDD station context
134 * authentication state.
135 *
136 * Return: none
137 */
138static void
139hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
140{
141 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
142 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
143
144 /* save the new connection state */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700145 hdd_notice("Authenticated state Changed from oldState:%d to State:%d",
146 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800147 pHddStaCtx->conn_info.uIsAuthenticated = authState;
148
149 /* Check is pending ROC request or not when auth state changed */
150 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
151}
152
153/**
154 * hdd_conn_set_connection_state() - set connection state
155 * @pAdapter: pointer to the adapter
156 * @connState: connection state
157 *
158 * This function updates the global HDD station context connection state.
159 *
160 * Return: none
161 */
162void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
163 eConnectionState connState)
164{
165 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
166 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
167
168 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530169 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
170 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
171 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800172 pHddStaCtx->conn_info.connState = connState;
173
174 /* Check is pending ROC request or not when connection state changed */
175 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
176}
177
178/**
179 * hdd_conn_get_connection_state() - get connection state
180 * @pAdapter: pointer to the adapter
181 * @pConnState: pointer to connection state
182 *
183 * This function updates the global HDD station context connection state.
184 *
185 * Return: true if (Infra Associated or IBSS Connected)
186 * and sets output parameter pConnState;
187 * false otherwise
188 */
189static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
190 eConnectionState *pConnState)
191{
192 bool fConnected = false;
193 eConnectionState connState;
194
195 /* get the connection state. */
196 connState = pHddStaCtx->conn_info.connState;
197
198 if (eConnectionState_Associated == connState ||
199 eConnectionState_IbssConnected == connState ||
200 eConnectionState_IbssDisconnected == connState) {
201 fConnected = true;
202 }
203
204 if (pConnState)
205 *pConnState = connState;
206
207 return fConnected;
208}
209
210/**
211 * hdd_is_connecting() - Function to check connection progress
212 * @hdd_sta_ctx: pointer to global HDD Station context
213 *
214 * Return: true if connecting, false otherwise
215 */
216bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
217{
218 return hdd_sta_ctx->conn_info.connState ==
219 eConnectionState_Connecting;
220}
221
222/**
223 * hdd_conn_is_connected() - Function to check connection status
224 * @pHddStaCtx: pointer to global HDD Station context
225 *
226 * Return: false if any errors encountered, true otherwise
227 */
228bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
229{
230 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
231}
232
233/**
234 * hdd_conn_get_connected_band() - get current connection radio band
235 * @pHddStaCtx: pointer to global HDD Station context
236 *
237 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
238 * eCSR_BAND_ALL if not connected
239 */
240eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
241{
242 uint8_t staChannel = 0;
243
244 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
245 staChannel = pHddStaCtx->conn_info.operationChannel;
246
247 if (staChannel > 0 && staChannel < 14)
248 return eCSR_BAND_24;
249 else if (staChannel >= 36 && staChannel <= 184)
250 return eCSR_BAND_5G;
251 else /* If station is not connected return as eCSR_BAND_ALL */
252 return eCSR_BAND_ALL;
253}
254
255/**
256 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
257 * @pHddStaCtx: pointer to global HDD Station context
258 * @pConnectedCipherAlgo: pointer to connected cipher algo
259 *
260 * Return: false if any errors encountered, true otherwise
261 */
262static inline bool
263hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
264 eCsrEncryptionType *pConnectedCipherAlgo)
265{
266 bool fConnected = false;
267
268 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
269
270 if (pConnectedCipherAlgo)
271 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
272
273 return fConnected;
274}
275
276/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700277 * hdd_remove_beacon_filter() - remove beacon filter
278 * @adapter: Pointer to the hdd adapter
279 *
280 * Return: 0 on success and errno on failure
281 */
282static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
283{
284 QDF_STATUS status;
285 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
286
287 status = sme_remove_beacon_filter(hdd_ctx->hHal,
288 adapter->sessionId);
289 if (!QDF_IS_STATUS_SUCCESS(status)) {
290 hdd_err("sme_remove_beacon_filter() failed");
291 return -EFAULT;
292 }
293
294 return 0;
295}
296
297/**
298 * hdd_add_beacon_filter() - add beacon filter
299 * @adapter: Pointer to the hdd adapter
300 *
301 * Return: 0 on success and errno on failure
302 */
303static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
304{
305 int i;
306 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
307 QDF_STATUS status;
308 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
309
310 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530311 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700312 (unsigned long int *)ie_map);
313
314 status = sme_add_beacon_filter(hdd_ctx->hHal,
315 adapter->sessionId, ie_map);
316 if (!QDF_IS_STATUS_SUCCESS(status)) {
317 hdd_err("sme_add_beacon_filter() failed");
318 return -EFAULT;
319 }
320 return 0;
321}
322
323/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530324 * hdd_copy_vht_caps()- copy vht caps info from roam info to
325 * hdd station context.
326 * @hdd_sta_ctx: pointer to hdd station context
327 * @roam_info: pointer to roam info
328 *
329 * Return: None
330 */
331static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
332 tCsrRoamInfo *roam_info)
333{
334 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
335 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
336 uint32_t i, temp_ht_cap;
337
338 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
339
340 if (roam_ht_cap->advCodingCap)
341 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
342 if (roam_ht_cap->supportedChannelWidthSet)
343 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
344 temp_ht_cap = roam_ht_cap->mimoPowerSave &
345 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
346 if (temp_ht_cap)
347 hdd_ht_cap->cap_info |=
348 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
349 if (roam_ht_cap->greenField)
350 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
351 if (roam_ht_cap->shortGI20MHz)
352 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
353 if (roam_ht_cap->shortGI40MHz)
354 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
355 if (roam_ht_cap->txSTBC)
356 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
357 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
358 IEEE80211_HT_CAP_RX_STBC_SHIFT);
359 if (temp_ht_cap)
360 hdd_ht_cap->cap_info |=
361 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
362 if (roam_ht_cap->delayedBA)
363 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
364 if (roam_ht_cap->maximalAMSDUsize)
365 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
366 if (roam_ht_cap->dsssCckMode40MHz)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
368 if (roam_ht_cap->psmp)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
370 if (roam_ht_cap->stbcControlFrame)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
372 if (roam_ht_cap->lsigTXOPProtection)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
374
375 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
376 if (roam_ht_cap->maxRxAMPDUFactor)
377 hdd_ht_cap->ampdu_params_info |=
378 IEEE80211_HT_AMPDU_PARM_FACTOR;
379 temp_ht_cap = roam_ht_cap->mpduDensity &
380 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
381 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
382 if (temp_ht_cap)
383 hdd_ht_cap->ampdu_params_info |=
384 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
385
386 /* 802.11n HT extended capabilities masks */
387 if (roam_ht_cap->pco)
388 hdd_ht_cap->extended_ht_cap_info |=
389 IEEE80211_HT_EXT_CAP_PCO;
390 temp_ht_cap = roam_ht_cap->transitionTime &
391 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
392 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
393 if (temp_ht_cap)
394 hdd_ht_cap->extended_ht_cap_info |=
395 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
396 temp_ht_cap = roam_ht_cap->mcsFeedback &
397 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
398 if (temp_ht_cap)
399 hdd_ht_cap->extended_ht_cap_info |=
400 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
401
402 /* tx_bf_cap_info capabilities */
403 if (roam_ht_cap->txBF)
404 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
405 if (roam_ht_cap->rxStaggeredSounding)
406 hdd_ht_cap->tx_BF_cap_info |=
407 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
408 if (roam_ht_cap->txStaggeredSounding)
409 hdd_ht_cap->tx_BF_cap_info |=
410 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
411 if (roam_ht_cap->rxZLF)
412 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
413 if (roam_ht_cap->txZLF)
414 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
415 if (roam_ht_cap->implicitTxBF)
416 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
417 temp_ht_cap = roam_ht_cap->calibration &
418 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
419 if (temp_ht_cap)
420 hdd_ht_cap->tx_BF_cap_info |=
421 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
422 if (roam_ht_cap->explicitCSITxBF)
423 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
424 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
425 hdd_ht_cap->tx_BF_cap_info |=
426 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
427 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
428 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
429 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
430 if (temp_ht_cap)
431 hdd_ht_cap->tx_BF_cap_info |=
432 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
433 temp_ht_cap =
434 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
435 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
436 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
437 if (temp_ht_cap)
438 hdd_ht_cap->tx_BF_cap_info |=
439 temp_ht_cap <<
440 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
441 temp_ht_cap =
442 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
443 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
444 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
445 if (temp_ht_cap)
446 hdd_ht_cap->tx_BF_cap_info |=
447 temp_ht_cap <<
448 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
449 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
450 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
451 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
452 if (temp_ht_cap)
453 hdd_ht_cap->tx_BF_cap_info |=
454 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
455 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
456 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
457 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
458 if (temp_ht_cap)
459 hdd_ht_cap->tx_BF_cap_info |=
460 temp_ht_cap <<
461 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
462 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
463 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
464 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
465 if (temp_ht_cap)
466 hdd_ht_cap->tx_BF_cap_info |=
467 temp_ht_cap <<
468 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
469
470 /* antenna selection */
471 if (roam_ht_cap->antennaSelection)
472 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
473 if (roam_ht_cap->explicitCSIFeedbackTx)
474 hdd_ht_cap->antenna_selection_info |=
475 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
476 if (roam_ht_cap->antennaIndicesFeedbackTx)
477 hdd_ht_cap->antenna_selection_info |=
478 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
479 if (roam_ht_cap->explicitCSIFeedback)
480 hdd_ht_cap->antenna_selection_info |=
481 ANTENNA_SEL_INFO_EXP_CSI_FB;
482 if (roam_ht_cap->antennaIndicesFeedback)
483 hdd_ht_cap->antenna_selection_info |=
484 ANTENNA_SEL_INFO_ANT_ID_FB;
485 if (roam_ht_cap->rxAS)
486 hdd_ht_cap->antenna_selection_info |=
487 ANTENNA_SEL_INFO_RX_AS;
488 if (roam_ht_cap->txSoundingPPDUs)
489 hdd_ht_cap->antenna_selection_info |=
490 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
491
492 /* mcs data rate */
493 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
494 hdd_ht_cap->mcs.rx_mask[i] =
495 roam_ht_cap->supportedMCSSet[i];
496 hdd_ht_cap->mcs.rx_highest =
497 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
498 ((short) (roam_ht_cap->supportedMCSSet[10]));
499 hdd_ht_cap->mcs.tx_params =
500 roam_ht_cap->supportedMCSSet[12];
501}
502
503#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
504#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
505#define VHT_CAP_RXSTBC_MASK_SHIFT 8
506#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
507#define VHT_CAP_BEAMFORMEE_STS_MASK \
508 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
509#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
510#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
511 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
512#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
513#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
514 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
515#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
516
517/**
518 * hdd_copy_ht_caps()- copy ht caps info from roam info to
519 * hdd station context.
520 * @hdd_sta_ctx: pointer to hdd station context
521 * @roam_info: pointer to roam info
522 *
523 * Return: None
524 */
525static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
526 tCsrRoamInfo *roam_info)
527{
528 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
529 struct ieee80211_vht_cap *hdd_vht_cap =
530 &hdd_sta_ctx->conn_info.vht_caps;
531 uint32_t temp_vht_cap;
532
533 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
534
535 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
536 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
537 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
538 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
539 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
540 if (temp_vht_cap)
541 if (roam_vht_cap->supportedChannelWidthSet &
542 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
543 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
544 hdd_vht_cap->vht_cap_info |=
545 temp_vht_cap <<
546 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
547 if (roam_vht_cap->supportedChannelWidthSet &
548 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
549 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
550 hdd_vht_cap->vht_cap_info |=
551 temp_vht_cap <<
552 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
553 if (roam_vht_cap->ldpcCodingCap)
554 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
555 if (roam_vht_cap->shortGI80MHz)
556 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
557 if (roam_vht_cap->shortGI160and80plus80MHz)
558 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
559 if (roam_vht_cap->txSTBC)
560 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
561 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
562 VHT_CAP_RXSTBC_MASK_SHIFT);
563 if (temp_vht_cap)
564 hdd_vht_cap->vht_cap_info |=
565 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
566 if (roam_vht_cap->suBeamFormerCap)
567 hdd_vht_cap->vht_cap_info |=
568 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
569 if (roam_vht_cap->suBeamformeeCap)
570 hdd_vht_cap->vht_cap_info |=
571 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
572 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
573 (VHT_CAP_BEAMFORMEE_STS_MASK);
574 if (temp_vht_cap)
575 hdd_vht_cap->vht_cap_info |=
576 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
577 temp_vht_cap = roam_vht_cap->numSoundingDim &
578 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
579 if (temp_vht_cap)
580 hdd_vht_cap->vht_cap_info |=
581 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
582 if (roam_vht_cap->muBeamformerCap)
583 hdd_vht_cap->vht_cap_info |=
584 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
585 if (roam_vht_cap->muBeamformeeCap)
586 hdd_vht_cap->vht_cap_info |=
587 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
588 if (roam_vht_cap->vhtTXOPPS)
589 hdd_vht_cap->vht_cap_info |=
590 IEEE80211_VHT_CAP_VHT_TXOP_PS;
591 if (roam_vht_cap->htcVHTCap)
592 hdd_vht_cap->vht_cap_info |=
593 IEEE80211_VHT_CAP_HTC_VHT;
594 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
595 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
596 if (temp_vht_cap)
597 hdd_vht_cap->vht_cap_info |=
598 temp_vht_cap <<
599 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
600 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
601 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
602 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
603 if (temp_vht_cap)
604 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
605 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
606 if (roam_vht_cap->rxAntPattern)
607 hdd_vht_cap->vht_cap_info |=
608 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
609 if (roam_vht_cap->txAntPattern)
610 hdd_vht_cap->vht_cap_info |=
611 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
612 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
613 hdd_vht_cap->supp_mcs.rx_highest =
614 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
615 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
616 hdd_vht_cap->supp_mcs.tx_highest =
617 ((uint16_t)roam_vht_cap->txSupDataRate);
618}
619
620/* ht param */
621#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
622#define HT_PARAM_SERVICE_INT_GRAN 0xe0
623#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
624
625/* operatinon mode */
626#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
627
628/* stbc_param */
629#define HT_STBC_PARAM_MCS 0x007f
630
631/**
632 * hdd_copy_ht_operation()- copy HT operation element from roam info to
633 * hdd station context.
634 * @hdd_sta_ctx: pointer to hdd station context
635 * @roam_info: pointer to roam info
636 *
637 * Return: None
638 */
639static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
640 tCsrRoamInfo *roam_info)
641{
642 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
643 struct ieee80211_ht_operation *hdd_ht_ops =
644 &hdd_sta_ctx->conn_info.ht_operation;
645 uint32_t i, temp_ht_ops;
646
647 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
648
649 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
650
651 /* HT_PARAMS */
652 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
653 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
654 if (temp_ht_ops)
655 hdd_ht_ops->ht_param |= temp_ht_ops;
656 else
657 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
658 if (roam_ht_ops->recommendedTxWidthSet)
659 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
660 if (roam_ht_ops->rifsMode)
661 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
662 if (roam_ht_ops->controlledAccessOnly)
663 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
664 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
665 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
666 if (temp_ht_ops)
667 hdd_ht_ops->ht_param |= temp_ht_ops <<
668 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
669
670 /* operation mode */
671 temp_ht_ops = roam_ht_ops->opMode &
672 IEEE80211_HT_OP_MODE_PROTECTION;
673 switch (temp_ht_ops) {
674 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
675 hdd_ht_ops->operation_mode |=
676 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
677 break;
678 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
679 hdd_ht_ops->operation_mode |=
680 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
681 break;
682 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
683 hdd_ht_ops->operation_mode |=
684 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
685 break;
686 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
687 default:
688 hdd_ht_ops->operation_mode |=
689 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
690 }
691 if (roam_ht_ops->nonGFDevicesPresent)
692 hdd_ht_ops->operation_mode |=
693 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
694 if (roam_ht_ops->transmitBurstLimit)
695 hdd_ht_ops->operation_mode |=
696 HT_OP_MODE_TX_BURST_LIMIT;
697 if (roam_ht_ops->obssNonHTStaPresent)
698 hdd_ht_ops->operation_mode |=
699 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
700
701 /* stbc_param */
702 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
703 HT_STBC_PARAM_MCS;
704 if (temp_ht_ops)
705 hdd_ht_ops->stbc_param |= temp_ht_ops;
706 if (roam_ht_ops->dualCTSProtection)
707 hdd_ht_ops->stbc_param |=
708 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
709 if (roam_ht_ops->secondaryBeacon)
710 hdd_ht_ops->stbc_param |=
711 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
712 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
713 hdd_ht_ops->stbc_param |=
714 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
715 if (roam_ht_ops->pcoActive)
716 hdd_ht_ops->stbc_param |=
717 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
718 if (roam_ht_ops->pcoPhase)
719 hdd_ht_ops->stbc_param |=
720 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
721
722 /* basic MCs set */
723 for (i = 0; i < 16; ++i)
724 hdd_ht_ops->basic_set[i] =
725 roam_ht_ops->basicMCSSet[i];
726}
727
728/**
729 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
730 * hdd station context.
731 * @hdd_sta_ctx: pointer to hdd station context
732 * @roam_info: pointer to roam info
733 *
734 * Return: None
735 */
736static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
737 tCsrRoamInfo *roam_info)
738{
739 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
740 struct ieee80211_vht_operation *hdd_vht_ops =
741 &hdd_sta_ctx->conn_info.vht_operation;
742
743 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
744
745 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
746 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
747 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
748 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
749}
750
751
752/**
753 * hdd_save_bss_info() - save connection info in hdd sta ctx
754 * @adapter: Pointer to adapter
755 * @roam_info: pointer to roam info
756 *
757 * Return: None
758 */
759static void hdd_save_bss_info(hdd_adapter_t *adapter,
760 tCsrRoamInfo *roam_info)
761{
762 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
763
764 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
765 hdd_sta_ctx->conn_info.operationChannel);
766 if (roam_info->vht_caps.present) {
767 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
768 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
769 } else {
770 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
771 }
772 if (roam_info->ht_caps.present) {
773 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
774 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
775 } else {
776 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
777 }
778 if (roam_info->reassoc)
779 hdd_sta_ctx->conn_info.roam_count++;
780 if (roam_info->hs20vendor_ie.present) {
781 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
782 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
783 &roam_info->hs20vendor_ie,
784 sizeof(roam_info->hs20vendor_ie));
785 } else {
786 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
787 }
788 if (roam_info->ht_operation.present) {
789 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
790 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
791 } else {
792 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
793 }
794 if (roam_info->vht_operation.present) {
795 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
796 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
797 } else {
798 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
799 }
800}
801
802/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800803 * hdd_conn_save_connect_info() - save current connection information
804 * @pAdapter: pointer to adapter
805 * @pRoamInfo: pointer to roam info
806 * @eBssType: bss type
807 *
808 * Return: none
809 */
810static void
811hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
812 eCsrRoamBssType eBssType)
813{
814 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
815 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
816
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530817 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800818
819 if (pRoamInfo) {
820 /* Save the BSSID for the connection */
821 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530822 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530823 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800824 &pRoamInfo->bssid);
825
826 /*
827 * Save the Station ID for this station from
828 * the 'Roam Info'. For IBSS mode, staId is
829 * assigned in NEW_PEER_IND. For reassoc,
830 * the staID doesn't change and it may be invalid
831 * in this structure so no change here.
832 */
833 if (!pRoamInfo->fReassocReq) {
834 pHddStaCtx->conn_info.staId[0] =
835 pRoamInfo->staId;
836 }
837 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530838 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 &pRoamInfo->bssid);
840 } else {
841 /*
842 * can't happen. We need a valid IBSS or Infra setting
843 * in the BSSDescription or we can't function.
844 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530845 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800846 }
847
848 /* notify WMM */
849 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
850
851 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530852 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800853 } else {
854 /* Get Multicast Encryption Type */
855 encryptType =
856 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
857 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
858 /* Get Unicast Encryption Type */
859 encryptType =
860 pRoamInfo->u.pConnectedProfile->EncryptionType;
861 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
862
863 pHddStaCtx->conn_info.authType =
864 pRoamInfo->u.pConnectedProfile->AuthType;
865
866 pHddStaCtx->conn_info.operationChannel =
867 pRoamInfo->u.pConnectedProfile->operationChannel;
868
869 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530870 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800871 &pRoamInfo->u.pConnectedProfile->SSID,
872 sizeof(tSirMacSSid));
873
874 /* Save dot11mode in which STA associated to AP */
875 pHddStaCtx->conn_info.dot11Mode =
876 pRoamInfo->u.pConnectedProfile->dot11Mode;
877
878 pHddStaCtx->conn_info.proxyARPService =
879 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530880
881 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
882
883 pHddStaCtx->conn_info.rate_flags =
884 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800885 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530886 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800887 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800888}
889
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890/**
891 * hdd_send_ft_assoc_response() - send fast transition assoc response
892 * @dev: pointer to net device
893 * @pAdapter: pointer to adapter
894 * @pCsrRoamInfo: pointer to roam info
895 *
896 * Send the 11R key information to the supplicant. Only then can the supplicant
897 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
898 * for the same purpose.)
899 *
900 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
901 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
902 * This is the Assoc Response.
903 *
904 * Return: none
905 */
906static void
907hdd_send_ft_assoc_response(struct net_device *dev,
908 hdd_adapter_t *pAdapter,
909 tCsrRoamInfo *pCsrRoamInfo)
910{
911 union iwreq_data wrqu;
912 char *buff;
913 unsigned int len = 0;
914 u8 *pFTAssocRsp = NULL;
915
916 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700917 hdd_err("pCsrRoamInfo->nAssocRspLength=%d",
918 (int)pCsrRoamInfo->nAssocRspLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800919 return;
920 }
921
922 pFTAssocRsp =
923 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
924 pCsrRoamInfo->nAssocReqLength);
925 if (pFTAssocRsp == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700926 hdd_err("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800927 return;
928 }
929 /* pFTAssocRsp needs to point to the IEs */
930 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700931 hdd_notice("AssocRsp is now at %02x%02x",
932 (unsigned int)pFTAssocRsp[0],
933 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800934
935 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700936 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800937 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700938 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800939 return;
940 }
941 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
942 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
943 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800944 memcpy(buff, pFTAssocRsp, len);
945 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
946
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700947 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800948}
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 */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001020 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001021 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001022 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001023 return;
1024 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025
1026 /* Sme needs to send the RIC IEs first */
1027 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1028 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1029 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1030 &ric_ies_length);
1031 if (ric_ies_length == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001032 hdd_warn("RIC IEs is of length 0 not sending RIC Information for now");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001033 } else {
1034 wrqu.data.length = str_len + ric_ies_length;
1035 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1036 }
1037
1038 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301039 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1041 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1042 (u8 *) &buff[str_len],
1043 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1044
1045 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001046 qdf_mem_free(buff);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001047 hdd_err("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001048 return;
1049 }
1050
1051 wrqu.data.length = str_len + auth_resp_len;
1052 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1053
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001054 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001055#endif
1056}
1057
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001058#ifdef FEATURE_WLAN_ESE
1059/**
1060 * hdd_send_new_ap_channel_info() - send new ap channel info
1061 * @dev: pointer to net device
1062 * @pAdapter: pointer to adapter
1063 * @pCsrRoamInfo: pointer to roam info
1064 *
1065 * Send the ESE required "new AP Channel info" to the supplicant.
1066 * (This keeps the supplicant "up to date" on the current channel.)
1067 *
1068 * The current (new AP) channel information is passed in.
1069 *
1070 * Return: none
1071 */
1072static void
1073hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1074 tCsrRoamInfo *pCsrRoamInfo)
1075{
1076 union iwreq_data wrqu;
1077 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1078
1079 if (descriptor == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001080 hdd_err("pCsrRoamInfo->pBssDesc(%p)", descriptor);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081 return;
1082 }
1083 /*
1084 * Send the Channel event, the supplicant needs this to generate
1085 * the Adjacent AP report.
1086 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001087 hdd_warn("Sending up an SIOCGIWFREQ, channelId(%d)",
1088 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001089 memset(&wrqu, '\0', sizeof(wrqu));
1090 wrqu.freq.m = descriptor->channelId;
1091 wrqu.freq.e = 0;
1092 wrqu.freq.i = 0;
1093 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1094}
1095
1096#endif /* FEATURE_WLAN_ESE */
1097
1098/**
1099 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1100 * @pAdapter: pointer to adapter
1101 * @pCsrRoamInfo: pointer to roam info
1102 *
1103 * Return: none
1104 */
1105static void
1106hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1107 tCsrRoamInfo *pCsrRoamInfo)
1108{
1109 union iwreq_data wrqu;
1110 u8 *pBeaconIes;
1111 u8 currentLen = 0;
1112 char *buff;
1113 int totalIeLen = 0, currentOffset = 0, strLen;
1114
1115 memset(&wrqu, '\0', sizeof(wrqu));
1116
1117 if (0 == pCsrRoamInfo->nBeaconLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001118 hdd_warn("pCsrRoamInfo->nBeaconFrameLength = 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001119 return;
1120 }
1121 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1122 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001123 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001124 return;
1125 }
1126 /* pBeaconIes needs to point to the IEs */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001127 hdd_notice("Beacon IEs is now at %02x%02x",
1128 (unsigned int)pBeaconIes[0],
1129 (unsigned int)pBeaconIes[1]);
1130 hdd_notice("Beacon IEs length = %d",
1131 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001132
1133 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001134 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001135 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001136 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001137 return;
1138 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001139
1140 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1141 currentLen = strLen + 1;
1142
1143 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1144 do {
1145 /*
1146 * If the beacon size exceeds max CUSTOM event size, break it
1147 * into chunks of CUSTOM event max size and send it to
1148 * supplicant. Changes are done in supplicant to handle this.
1149 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301150 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301152 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301153 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 currentLen);
1155 currentOffset += currentLen;
1156 totalIeLen -= currentLen;
1157 wrqu.data.length = strLen + 1 + currentLen;
1158 if (totalIeLen)
1159 buff[strLen] = 1; /* more chunks pending */
1160 else
1161 buff[strLen] = 0; /* last chunk */
1162
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001163 hdd_notice("Beacon IEs length to supplicant = %d",
1164 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1166 } while (totalIeLen > 0);
1167
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001168 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001169}
1170
1171/**
1172 * hdd_send_association_event() - send association event
1173 * @dev: pointer to net device
1174 * @pCsrRoamInfo: pointer to roam info
1175 *
1176 * Return: none
1177 */
1178static void hdd_send_association_event(struct net_device *dev,
1179 tCsrRoamInfo *pCsrRoamInfo)
1180{
Rajeev Kumar78427682017-01-13 16:13:11 -08001181 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001182 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1183 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1184 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1185 union iwreq_data wrqu;
1186 int we_event;
1187 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301188 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001189
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001190 /* Added to find the auth type on the fly at run time */
1191 /* rather than with cfg to see if FT is enabled */
1192 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1193 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001194
1195 memset(&wrqu, '\0', sizeof(wrqu));
1196 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1197 we_event = SIOCGIWAP;
1198#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1199 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301200 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001201 /* change logging before release */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001202 hdd_info("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301203 /* Update tdls module about the disconnection event */
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301204 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301205 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001206#endif
1207 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Abhishek Singh1c676222016-05-09 14:20:28 +05301208 tSirSmeChanInfo chan_info;
1209
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001210 if (!pCsrRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001211 hdd_err("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001212 return;
1213 }
1214
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001215 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
1216 cds_incr_active_session(pAdapter->device_mode,
1217 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001218 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1219 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1220
1221#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001222 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001223 if (global_p2p_connection_status ==
1224 P2P_CLIENT_CONNECTING_STATE_1) {
1225 global_p2p_connection_status =
1226 P2P_CLIENT_CONNECTED_STATE_1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001227 hdd_err("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001228 } else if (global_p2p_connection_status ==
1229 P2P_CLIENT_CONNECTING_STATE_2) {
1230 global_p2p_connection_status =
1231 P2P_CLIENT_COMPLETED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001232 hdd_err("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001233 }
1234 }
1235#endif
1236 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1237 MAC_ADDRESS_STR "\n",
1238 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1239 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1240 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1241
1242 /*
1243 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1244 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001245 * fFTEnable is true.
1246 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001247 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001248 if ((pRoamProfile->AuthType.authType[0] ==
1249 eCSR_AUTH_TYPE_FT_RSN_PSK)
1250 || (pRoamProfile->AuthType.authType[0] ==
1251 eCSR_AUTH_TYPE_FT_RSN)
1252#ifdef FEATURE_WLAN_ESE
1253 || (pRoamProfile->AuthType.authType[0] ==
1254 eCSR_AUTH_TYPE_CCKM_RSN)
1255 || (pRoamProfile->AuthType.authType[0] ==
1256 eCSR_AUTH_TYPE_CCKM_WPA)
1257#endif
1258 ) {
1259 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1260 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301261 qdf_copy_macaddr(&peerMacAddr,
1262 &pHddStaCtx->conn_info.bssId);
1263 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1264 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1265 chan_info.info = pCsrRoamInfo->chan_info.info;
1266 chan_info.band_center_freq1 =
1267 pCsrRoamInfo->chan_info.band_center_freq1;
1268 chan_info.band_center_freq2 =
1269 pCsrRoamInfo->chan_info.band_center_freq2;
1270 chan_info.reg_info_1 =
1271 pCsrRoamInfo->chan_info.reg_info_1;
1272 chan_info.reg_info_2 =
1273 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301274
Rajeev Kumar78427682017-01-13 16:13:11 -08001275 ret = hdd_add_peer_object(pAdapter->hdd_vdev,
1276 pAdapter->device_mode,
1277 peerMacAddr.bytes);
1278 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301279 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1280 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1281
Abhishek Singh1c676222016-05-09 14:20:28 +05301282 /* send peer status indication to oem app */
1283 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
1284 ePeerConnected,
1285 pCsrRoamInfo->
1286 timingMeasCap,
1287 pAdapter->sessionId,
1288 &chan_info,
1289 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001290 /* Update tdls module about connection event */
1291 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001292
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001294#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001295 /* start timer in sta/p2p_cli */
1296 spin_lock_bh(&pHddCtx->bus_bw_lock);
1297 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1298 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001299 cdp_get_intra_bss_fwd_pkts_count(
1300 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301301 &pAdapter->prev_fwd_tx_packets,
1302 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001303 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1304 hdd_start_bus_bw_compute_timer(pAdapter);
1305#endif
1306#endif
1307 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1308 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001309 cds_update_connection_info(pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
1311 ETH_ALEN);
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301312 hdd_err("wlan: new IBSS connection to " MAC_ADDRESS_STR,
1313 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301314
Rajeev Kumar78427682017-01-13 16:13:11 -08001315 ret = hdd_add_peer_object(pAdapter->hdd_vdev,
1316 QDF_IBSS_MODE,
1317 pCsrRoamInfo->bssid.bytes);
1318 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301319 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1320 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001321 } else { /* Not Associated */
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05301322 hdd_err("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301324 cds_decr_session_set_pcl(pAdapter->device_mode,
1325 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001326
1327#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1328 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1329#endif
1330
Abhishek Singh1c676222016-05-09 14:20:28 +05301331 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1332 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301333 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001334 &pHddStaCtx->conn_info.bssId);
1335
1336 /* send peer status indication to oem app */
1337 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301338 ePeerDisconnected, 0,
1339 pAdapter->sessionId,
1340 NULL,
1341 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001342 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301343
Rajeev Kumardfa37072017-01-13 16:27:22 -08001344 ret = hdd_remove_peer_object(pAdapter->hdd_vdev,
1345 peerMacAddr.bytes);
1346 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301347 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1348 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1349
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001350 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001351 /* Update tdls module about the disconnection event */
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301352 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001353
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001354#ifdef MSM_PLATFORM
1355 /* stop timer in sta/p2p_cli */
1356 spin_lock_bh(&pHddCtx->bus_bw_lock);
1357 pAdapter->prev_tx_packets = 0;
1358 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301359 pAdapter->prev_fwd_tx_packets = 0;
1360 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001361 spin_unlock_bh(&pHddCtx->bus_bw_lock);
1362 hdd_stop_bus_bw_compute_timer(pAdapter);
1363#endif
1364 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001365 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001366 /* Send SCC/MCC Switching event to IPA */
1367 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1368
1369 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001370 /* During the WLAN uninitialization,supplicant is stopped before the
1371 * driver so not sending the status of the connection to supplicant
1372 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001373 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001374 wireless_send_event(dev, we_event, &wrqu, msg);
1375#ifdef FEATURE_WLAN_ESE
1376 if (eConnectionState_Associated ==
1377 pHddStaCtx->conn_info.connState) {
1378 if ((pRoamProfile->AuthType.authType[0] ==
1379 eCSR_AUTH_TYPE_CCKM_RSN) ||
1380 (pRoamProfile->AuthType.authType[0] ==
1381 eCSR_AUTH_TYPE_CCKM_WPA))
1382 hdd_send_new_ap_channel_info(dev, pAdapter,
1383 pCsrRoamInfo);
1384 }
1385#endif
1386 }
1387}
1388
1389/**
1390 * hdd_conn_remove_connect_info() - remove connection info
1391 * @pHddStaCtx: pointer to global HDD station context
1392 * @pCsrRoamInfo: pointer to roam info
1393 *
1394 * Return: none
1395 */
1396static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1397{
1398 /* Remove staId, bssId and peerMacAddress */
1399 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301400 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1401 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301402 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403
1404 /* Clear all security settings */
1405 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1406 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1407 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1408
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301409 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1410 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412 pHddStaCtx->conn_info.proxyARPService = 0;
1413
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301414 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415}
1416
1417/**
1418 * hdd_roam_deregister_sta() - deregister station
1419 * @pAdapter: pointer to adapter
1420 * @staId: station identifier
1421 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301422 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 */
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07001424QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001425{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301426 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001427 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1428
1429 if (eConnectionState_IbssDisconnected ==
1430 pHddStaCtx->conn_info.connState) {
1431 /*
1432 * Do not set the carrier off when the last peer leaves.
1433 * We will set the carrier off while stopping the IBSS.
1434 */
1435 }
1436
Leo Changfdb45c32016-10-28 11:09:23 -07001437 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
1438 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301439 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001440 hdd_err("cdp_peer_clear() failed for staID %d. Status(%d) [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301441 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001442 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301443 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001444}
1445
1446/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301447 * hdd_print_bss_info() - print bss info
1448 * @hdd_sta_ctx: pointer to hdd station context
1449 *
1450 * Return: None
1451 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001452static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301453{
1454 uint32_t *cap_info;
1455
1456 hdd_info("WIFI DATA LOGGER");
1457 hdd_info("channel: %d",
1458 hdd_sta_ctx->conn_info.freq);
1459 hdd_info("dot11mode: %d",
1460 hdd_sta_ctx->conn_info.dot11Mode);
1461 hdd_info("AKM: %d",
1462 hdd_sta_ctx->conn_info.authType);
1463 hdd_info("ssid: %.*s",
1464 hdd_sta_ctx->conn_info.SSID.SSID.length,
1465 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1466 hdd_info("roam count: %d",
1467 hdd_sta_ctx->conn_info.roam_count);
1468 hdd_info("ant_info: %d",
1469 hdd_sta_ctx->conn_info.txrate.nss);
1470 hdd_info("datarate legacy %d",
1471 hdd_sta_ctx->conn_info.txrate.legacy);
1472 hdd_info("datarate mcs: %d",
1473 hdd_sta_ctx->conn_info.txrate.mcs);
1474 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1475 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1476 hdd_info("ht caps: %x", *cap_info);
1477 }
1478 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1479 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1480 hdd_info("vht caps: %x", *cap_info);
1481 }
1482 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1483 hdd_info("hs20 info: %x",
1484 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1485 hdd_info("signal: %d",
1486 hdd_sta_ctx->conn_info.signal);
1487 hdd_info("noise: %d",
1488 hdd_sta_ctx->conn_info.noise);
1489}
1490
1491/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492 * hdd_dis_connect_handler() - disconnect event handler
1493 * @pAdapter: pointer to adapter
1494 * @pRoamInfo: pointer to roam info
1495 * @roamId: roam identifier
1496 * @roamStatus: roam status
1497 * @roamResult: roam result
1498 *
1499 * This function handles disconnect event:
1500 * 1. Disable transmit queues;
1501 * 2. Clean up internal connection states and data structures;
1502 * 3. Send disconnect indication to supplicant.
1503 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301504 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001505 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301506static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001507 tCsrRoamInfo *pRoamInfo,
1508 uint32_t roamId,
1509 eRoamCmdStatus roamStatus,
1510 eCsrRoamResult roamResult)
1511{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301512 QDF_STATUS status = QDF_STATUS_SUCCESS;
1513 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001514 struct net_device *dev = pAdapter->dev;
1515 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1516 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1517 uint8_t sta_id;
1518 bool sendDisconInd = true;
1519
1520 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001521 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301522 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001523 }
1524 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001525 hdd_notice("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1527 WLAN_CONTROL_PATH);
1528
1529 if (hdd_ipa_is_enabled(pHddCtx))
1530 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001531 HDD_IPA_STA_DISCONNECT,
1532 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001533
1534#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1535 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1536#endif
1537
Nirav Shah1da77682016-05-03 20:16:39 +05301538 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1539 pAdapter->sessionId,
1540 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001541
1542 /* HDD has initiated disconnect, do not send disconnect indication
1543 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301544 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001545 * to cfg80211_disconnected.
1546 */
1547 if ((eConnectionState_Disconnecting ==
1548 pHddStaCtx->conn_info.connState) ||
1549 (eConnectionState_NotConnected ==
1550 pHddStaCtx->conn_info.connState)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001551 hdd_notice("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001552 sendDisconInd = false;
1553 }
1554
1555 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1556 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 hdd_conn_set_connection_state(pAdapter,
1558 eConnectionState_Disconnecting);
1559 }
1560
1561 hdd_clear_roam_profile_ie(pAdapter);
1562 hdd_wmm_init(pAdapter);
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301563 hdd_info("Invoking packetdump deregistration API");
1564 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001565
1566 /* indicate 'disconnect' status to wpa_supplicant... */
1567 hdd_send_association_event(dev, pRoamInfo);
1568 /* indicate disconnected event to nl80211 */
1569 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1570 /*
1571 * Only send indication to kernel if not initiated
1572 * by kernel
1573 */
1574 if (sendDisconInd) {
1575 /*
1576 * To avoid wpa_supplicant sending "HANGED" CMD
1577 * to ICS UI.
1578 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001579 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1580 if (pRoamInfo->reasonCode ==
1581 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1582 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301583 wlan_hdd_cfg80211_indicate_disconnect(
1584 dev, false,
1585 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001586 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301587 wlan_hdd_cfg80211_indicate_disconnect(
1588 dev, false,
1589 WLAN_REASON_UNSPECIFIED
1590 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001591 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301593 hdd_info("sent disconnected event to nl80211, reason code %d",
1594 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1595 pRoamInfo->reasonCode :
1596 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001597 }
1598 /*
1599 * During the WLAN uninitialization,supplicant is stopped
1600 * before the driver so not sending the status of the
1601 * connection to supplicant.
1602 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001603 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001604#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001605 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001606 if (global_p2p_connection_status ==
1607 P2P_CLIENT_CONNECTED_STATE_1) {
1608 global_p2p_connection_status =
1609 P2P_CLIENT_DISCONNECTED_STATE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001610 hdd_err("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001611 } else if (global_p2p_connection_status ==
1612 P2P_CLIENT_COMPLETED_STATE) {
1613 global_p2p_connection_status =
1614 P2P_NOT_ACTIVE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001615 hdd_err("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 }
1617 }
1618#endif
1619
1620 }
1621 }
1622
1623 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001624 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001625 if (hdd_remove_beacon_filter(pAdapter) != 0)
1626 hdd_err("hdd_remove_beacon_filter() failed");
1627
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301629 uint8_t i;
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001630 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301632 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301633 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1634 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301635 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636 }
1637 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301638 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001639 for (i = 0; i < MAX_PEERS; i++) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301640 if (0 == pHddStaCtx->conn_info.staId[i])
1641 continue;
1642 sta_id = pHddStaCtx->conn_info.staId[i];
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001643 hdd_info("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301644 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301645 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001646 hdd_err("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301647 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301648 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301649 }
1650 /* set the staid and peer mac as 0, all other
1651 * reset are done in hdd_connRemoveConnectInfo.
1652 */
1653 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301654 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301655 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301656 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1657 pHddCtx->sta_to_adapter[sta_id] = NULL;
1658 }
1659 } else {
1660 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhc9941602016-08-09 16:06:22 +05301661
1662 /* clear scan cache for Link Lost */
1663 if (pRoamInfo && !pRoamInfo->reasonCode &&
1664 (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult)) {
1665 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1666 pHddStaCtx->conn_info.bssId.bytes);
1667 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1668 pHddStaCtx->conn_info.bssId.bytes);
1669 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301670 /* We should clear all sta register with TL,
1671 * for now, only one.
1672 */
1673 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301674 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001675 hdd_err("hdd_roam_deregister_sta() failed to for staID %d. Status= %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301676 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301677 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301678 }
1679 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001680 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001681 /* Clear saved connection information in HDD */
1682 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001683 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
1684#ifdef WLAN_FEATURE_GTK_OFFLOAD
Krunal Sonibe766b02016-03-10 13:00:44 -08001685 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1686 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1688 sizeof(tSirGtkOffloadParams));
1689 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
1690 }
1691#endif
1692
1693#ifdef FEATURE_WLAN_TDLS
1694 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1695 wlan_hdd_tdls_disconnection_callback(pAdapter);
1696#endif
1697
Krunal Sonibe766b02016-03-10 13:00:44 -08001698 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1699 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001700 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1701 (pAdapter),
1702 pAdapter->sessionId);
1703 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301704 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001705 /* Unblock anyone waiting for disconnect to complete */
1706 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301707 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 return status;
1709}
1710
1711/**
1712 * hdd_set_peer_authorized_event() - set peer_authorized_event
1713 * @vdev_id: vdevid
1714 *
1715 * Return: None
1716 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001717static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001718{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301719 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001720 hdd_adapter_t *adapter = NULL;
1721
1722 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1723 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001724 hdd_err("Invalid vdev_id");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001725 }
1726 complete(&adapter->sta_authorized_event);
1727}
1728
1729/**
1730 * hdd_change_peer_state() - change peer state
1731 * @pAdapter: HDD adapter
1732 * @sta_state: peer state
1733 * @roam_synch_in_progress: roam synch in progress
1734 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301735 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001736 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301737QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001738 uint8_t sta_id,
1739 enum ol_txrx_peer_state sta_state,
1740 bool roam_synch_in_progress)
1741{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301742 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001743 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001744 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1745 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1746 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001747
1748 if (!pdev) {
1749 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301750 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001751 }
1752
1753 if (sta_id >= WLAN_MAX_STA_COUNT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001754 hdd_err("Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301755 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001756 }
1757
Leo Changfdb45c32016-10-28 11:09:23 -07001758 peer = cdp_peer_find_by_local_id(soc, pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001759 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301760 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001761
Leo Changfdb45c32016-10-28 11:09:23 -07001762 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001763 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001764 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001765 return QDF_STATUS_E_FAULT;
1766 }
1767
Leo Changfdb45c32016-10-28 11:09:23 -07001768 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301769 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001770 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301771 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772 }
1773#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1774 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301775 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001776#endif
1777
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001778 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001779#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1780 /* make sure event is reset */
1781 INIT_COMPLETION(pAdapter->sta_authorized_event);
1782#endif
1783
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001784 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001785 hdd_set_peer_authorized_event,
1786 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301787 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001788 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301789 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001790 }
1791
Krunal Sonibe766b02016-03-10 13:00:44 -08001792 if (pAdapter->device_mode == QDF_STA_MODE ||
1793 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001795 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 unsigned long rc;
1797
1798 /* wait for event from firmware to set the event */
1799 rc = wait_for_completion_timeout(
1800 &pAdapter->sta_authorized_event,
1801 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1802 if (!rc) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001803 hdd_notice("timeout waiting for sta_authorized_event");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001804 }
Leo Changfdb45c32016-10-28 11:09:23 -07001805 vdev = cdp_peer_get_vdev(soc, peer);
1806 cdp_fc_vdev_unpause(soc, vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001807 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808#endif
1809 }
1810 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301811 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812}
1813
1814/**
1815 * hdd_roam_register_sta() - register station
1816 * @pAdapter: pointer to adapter
1817 * @pRoamInfo: pointer to roam info
1818 * @staId: station identifier
1819 * @pPeerMacAddress: peer MAC address
1820 * @pBssDesc: pointer to BSS description
1821 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301822 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001824QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001825 tCsrRoamInfo *pRoamInfo,
1826 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301827 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001828 tSirBssDescription *pBssDesc)
1829{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301830 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001831 struct ol_txrx_desc_type staDesc = { 0 };
1832 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001833 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001834 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1835 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001836
1837 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301838 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001839
1840 /* Get the Station ID from the one saved during the association */
1841 staDesc.sta_id = staId;
1842
1843 /* set the QoS field appropriately */
1844 if (hdd_wmm_is_active(pAdapter))
1845 staDesc.is_qos_enabled = 1;
1846 else
1847 staDesc.is_qos_enabled = 0;
1848
1849#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001850 hdd_notice("WAPI STA Registered: %d",
1851 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 if (pAdapter->wapi_info.fIsWapiSta)
1853 staDesc.is_wapi_supported = 1;
1854 else
1855 staDesc.is_wapi_supported = 0;
1856#endif /* FEATURE_WLAN_WAPI */
1857
Dhanashri Atre50141c52016-04-07 13:15:29 -07001858 /* Register the vdev transmit and receive functions */
1859 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1860 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001861
1862 pAdapter->txrx_vdev = cdp_get_vdev_from_vdev_id(soc, pdev,
1863 pAdapter->sessionId);
1864 if (!pAdapter->txrx_vdev) {
1865 hdd_err("%s find vdev fail", __func__);
1866 return QDF_STATUS_E_FAILURE;
1867 }
1868
1869 txrx_ops.tx.tx = NULL;
1870 cdp_vdev_register(soc, pAdapter->txrx_vdev, pAdapter, &txrx_ops);
1871 if (!txrx_ops.tx.tx) {
1872 hdd_err("%s vdev register fail", __func__);
1873 return QDF_STATUS_E_FAILURE;
1874 }
1875
Dhanashri Atre50141c52016-04-07 13:15:29 -07001876 pAdapter->tx_fn = txrx_ops.tx.tx;
Leo Changfdb45c32016-10-28 11:09:23 -07001877 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301878 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07001879 hdd_warn("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001880 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301881 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001882 }
1883
1884 if (!pRoamInfo->fAuthRequired) {
1885 /*
1886 * Connections that do not need Upper layer auth, transition
1887 * TLSHIM directly to 'Authenticated' state
1888 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301889 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001890 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001891 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001892#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1893 pRoamInfo->roamSynchInProgress
1894#else
1895 false
1896#endif
1897 );
1898
1899 hdd_conn_set_authenticated(pAdapter, true);
1900 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001901 hdd_info("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001902 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301903 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001905 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001906#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1907 pRoamInfo->roamSynchInProgress
1908#else
1909 false
1910#endif
1911 );
1912 hdd_conn_set_authenticated(pAdapter, false);
1913 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301914 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001915}
1916
1917/**
1918 * hdd_send_re_assoc_event() - send reassoc event
1919 * @dev: pointer to net device
1920 * @pAdapter: pointer to adapter
1921 * @pCsrRoamInfo: pointer to roam info
1922 * @reqRsnIe: pointer to RSN Information element
1923 * @reqRsnLength: length of RSN IE
1924 *
1925 * Return: none
1926 */
1927static void hdd_send_re_assoc_event(struct net_device *dev,
1928 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1929 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1930{
1931 unsigned int len = 0;
1932 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001933 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
1934 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001935 uint32_t rspRsnLength = 0;
1936 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001937 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1938 uint8_t *buf_ptr, ssid_ie_len;
1939 struct cfg80211_bss *bss = NULL;
1940 uint8_t *final_req_ie = NULL;
1941 tCsrRoamConnectedProfile roam_profile;
1942 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1943
Jeff Johnsonfdb73432016-10-11 08:07:27 -07001944 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
1945
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001946 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001947 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001948 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001949 }
1950
Naveen Rawat14298b92015-11-25 16:27:41 -08001951 if (!assoc_req_ies) {
1952 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001953 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001954 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001955 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001956 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001957 goto done;
1958 }
1959
1960 if (pCsrRoamInfo->nAssocRspLength == 0) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001961 hdd_err("Invalid assoc response length");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001962 goto done;
1963 }
1964
1965 pFTAssocRsp =
1966 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1967 pCsrRoamInfo->nAssocReqLength);
1968 if (pFTAssocRsp == NULL)
1969 goto done;
1970
1971 /* pFTAssocRsp needs to point to the IEs */
1972 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001973 hdd_info("AssocRsp is now at %02x%02x",
1974 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001975
1976 /*
1977 * Active session count is decremented upon disconnection, but during
1978 * roaming, there is no disconnect indication and hence active session
1979 * count is not decremented.
1980 * After roaming is completed, active session count is incremented
1981 * as a part of connect indication but effectively after roaming the
1982 * active session count should still be the same and hence upon
1983 * successful reassoc decrement the active session count here.
1984 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001985 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301986 cds_decr_session_set_pcl(pAdapter->device_mode,
1987 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001988
1989 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
1990 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1991 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301992 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1993 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001994
1995 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05301996 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
1998 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05301999
2000 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2001 chan, pCsrRoamInfo->bssid.bytes,
2002 &roam_profile.SSID.ssId[0],
2003 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002004
2005 if (bss == NULL)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002006 hdd_err("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002007 buf_ptr = buf_ssid_ie;
2008 *buf_ptr = SIR_MAC_SSID_EID;
2009 buf_ptr++;
2010 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2011 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302012 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002013 roam_profile.SSID.length);
2014 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08002015 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302016 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002017 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002018 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002019 if (final_req_ie == NULL)
2020 goto done;
2021 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302022 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002023 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302024 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2025 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2026 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002027 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08002028 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302029 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002030 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002031 cfg80211_roamed_bss(dev, bss,
2032 final_req_ie, (ssid_ie_len + reqRsnLength),
2033 rspRsnIe, rspRsnLength, GFP_KERNEL);
2034
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302035 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002036 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2037 pCsrRoamInfo->nAssocReqLength);
2038
2039 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302040 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002041 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2042
Prakash Dhavali989127d2016-11-29 14:56:44 +05302043 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002044 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2045 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002046 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002047done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002048 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002049 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002050 qdf_mem_free(final_req_ie);
2051 qdf_mem_free(rspRsnIe);
2052 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002053}
2054
2055/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302056 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002057 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302058 *
2059 * Return: roam sync status if roaming offloaded else false
2060 */
2061#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002062bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302063{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002064 if (roaminfo)
2065 return roaminfo->roamSynchInProgress;
2066 else
2067 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302068}
2069#endif
2070
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002071/**
2072 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2073 * @hddstactx: pointer to HDD sta context
2074 * @roaminfo: pointer to roaminfo structure
2075 *
2076 * This function returns staid for IBSS peer. If peer is broadcast
2077 * MAC address return self staid(0) else find the peer sta id of
2078 * the peer.
2079 *
2080 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2081 */
2082static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2083 tCsrRoamInfo *roaminfo)
2084{
2085 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2086 QDF_STATUS status;
2087
2088 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2089 staid = 0;
2090 } else {
2091 status = hdd_get_peer_sta_id(hddstactx,
2092 &roaminfo->peerMac, &staid);
2093 if (status != QDF_STATUS_SUCCESS) {
2094 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2095 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2096 }
2097 }
2098
2099 return staid;
2100}
Govind Singhedc5cda2015-10-23 17:11:35 +05302101
2102/**
2103 * hdd_change_sta_state_authenticated()-
2104 * This function changes STA state to authenticated
2105 * @adapter: pointer to the adapter structure.
2106 * @roaminfo: pointer to the RoamInfo structure.
2107 *
2108 * This is called from hdd_RoamSetKeyCompleteHandler
2109 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2110 *
2111 * Return: 0 on success and errno on failure
2112 */
2113static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2114 tCsrRoamInfo *roaminfo)
2115{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002116 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002117 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002118 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302119 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002120 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302121
Dustin Brownf660fb42016-09-09 12:04:00 -07002122 timeout = hddstactx->hdd_ReassocScenario ?
2123 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002124 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002125
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002126 if (QDF_IBSS_MODE == adapter->device_mode)
2127 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2128 else
2129 staid = hddstactx->conn_info.staId[0];
2130
2131 hdd_info("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302132
2133 /* Connections that do not need Upper layer authentication,
2134 * transition TL to 'Authenticated' state after the keys are set
2135 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002136 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302137 hdd_is_roam_sync_in_progress(roaminfo));
2138 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08002139 if ((QDF_STA_MODE == adapter->device_mode) ||
2140 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302141 sme_ps_enable_auto_ps_timer(
2142 WLAN_HDD_GET_HAL_CTX(adapter),
2143 adapter->sessionId,
Dustin Brownf660fb42016-09-09 12:04:00 -07002144 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302145 }
2146
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002147 return qdf_status_to_os_return(status);
2148}
2149
2150/**
2151 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2152 * if key installation is required
2153 * @encr_type: encryption type
2154 *
2155 * Return: true if key installation is required and false otherwise.
2156 */
2157static inline bool hdd_is_key_install_required_for_ibss(
2158 eCsrEncryptionType encr_type)
2159{
2160 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2161 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2162 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
2163 eCSR_ENCRYPT_TYPE_AES == encr_type)
2164 return true;
2165 else
2166 return false;
2167}
2168
2169/**
2170 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2171 * complete
2172 * @adapter: pointer to HDD adapter
2173 * @roaminfo: pointer to roam info
2174 * @roam_result: roam result
2175 *
2176 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2177 * This function checks for the successful set key completion and update
2178 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2179 *
2180 * Return: None
2181 */
2182static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2183 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2184{
2185 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(adapter);
2186 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
2187 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2188 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2189
2190 /*
2191 * If the security mode is one of the following, IBSS peer will be
2192 * waiting in CONN state and we will move the peer state to AUTH
2193 * here. For non-secure connection, no need to wait for set-key complete
2194 * peer will be moved to AUTH in hdd_roam_register_sta.
2195 */
2196 if (QDF_IBSS_MODE == adapter->device_mode) {
2197 if (hdd_is_key_install_required_for_ibss(encr_type))
2198 hdd_change_sta_state_authenticated(adapter, roaminfo);
2199
2200 return;
2201 }
2202
2203 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2204 hdd_sta_ctx->conn_info.gtk_installed = true;
2205 /*
2206 * PTK exchange happens in preauthentication itself if key_mgmt
2207 * is FT-PSK, ptk_installed was false as there is no set PTK
2208 * after roaming. STA TL state moves to authenticated only if
2209 * ptk_installed is true. So, make ptk_installed to true in
2210 * case of 11R roaming.
2211 */
2212 if (csr_neighbor_roam_is11r_assoc(mac_ctx, adapter->sessionId))
2213 hdd_sta_ctx->conn_info.ptk_installed = true;
2214 } else {
2215 hdd_sta_ctx->conn_info.ptk_installed = true;
2216 }
2217
2218 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2219 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2220 * unicast key and it was resulting in sending few un-encrypted packet.
2221 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2222 * set the unicast and broadcast key.
2223 */
2224 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2225 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2226 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2227 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2228 if (hdd_sta_ctx->conn_info.gtk_installed &&
2229 hdd_sta_ctx->conn_info.ptk_installed)
2230 hdd_change_sta_state_authenticated(adapter, roaminfo);
2231 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2232 hdd_change_sta_state_authenticated(adapter, roaminfo);
2233 }
2234
2235 if (hdd_sta_ctx->conn_info.gtk_installed &&
2236 hdd_sta_ctx->conn_info.ptk_installed) {
2237 hdd_sta_ctx->conn_info.gtk_installed = false;
2238 hdd_sta_ctx->conn_info.ptk_installed = false;
2239 }
2240
2241 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2242
2243 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302244}
2245
2246/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002247 * hdd_roam_set_key_complete_handler() - Update the security parameters
2248 * @pAdapter: pointer to adapter
2249 * @pRoamInfo: pointer to roam info
2250 * @roamId: roam id
2251 * @roamStatus: roam status
2252 * @roamResult: roam result
2253 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302254 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002255 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302256static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002257 tCsrRoamInfo *pRoamInfo,
2258 uint32_t roamId,
2259 eRoamCmdStatus roamStatus,
2260 eCsrRoamResult roamResult)
2261{
2262 eCsrEncryptionType connectedCipherAlgo;
2263 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002264 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302265
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002266 ENTER();
2267
2268 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002269 hdd_info("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302270 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002271 }
2272 /*
2273 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2274 * then go to 'authenticated'. For all other authentication types
2275 * (those that do not require upper layer authentication) we can put TL
2276 * directly into 'authenticated' state.
2277 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002278 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002279 MAC_ADDRESS_STR, roamStatus, roamResult,
2280 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2281
2282 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2283 &connectedCipherAlgo);
2284 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002285 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2286 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002287 } else {
2288 /*
2289 * possible disassoc after issuing set key and waiting
2290 * set key complete.
2291 */
2292 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2293 }
2294
2295 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302296 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002297}
2298
2299/**
2300 * hdd_perform_roam_set_key_complete() - perform set key complete
2301 * @pAdapter: pointer to adapter
2302 *
2303 * Return: none
2304 */
2305void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2306{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302307 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002308 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2309 tCsrRoamInfo roamInfo;
2310 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302311 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302312 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302313 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302314 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002315
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302316 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002317 hdd_roam_set_key_complete_handler(pAdapter,
2318 &roamInfo,
2319 pHddStaCtx->roam_info.roamId,
2320 pHddStaCtx->roam_info.roamStatus,
2321 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302322 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002323 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002324
2325 pHddStaCtx->roam_info.deferKeyComplete = false;
2326}
2327
2328/**
2329 * hdd_association_completion_handler() - association completion handler
2330 * @pAdapter: pointer to adapter
2331 * @pRoamInfo: pointer to roam info
2332 * @roamId: roam id
2333 * @roamStatus: roam status
2334 * @roamResult: roam result
2335 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302336 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002337 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302338static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002339 tCsrRoamInfo *pRoamInfo,
2340 uint32_t roamId,
2341 eRoamCmdStatus roamStatus,
2342 eCsrRoamResult roamResult)
2343{
2344 struct net_device *dev = pAdapter->dev;
2345 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2346 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302347 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002348 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2349 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002350 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002351 bool hddDisconInProgress = false;
2352 unsigned long rc;
2353
2354 if (!pHddCtx) {
2355 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302356 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002357 }
2358
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302359 /* validate config */
2360 if (!pHddCtx->config) {
2361 hdd_err("config is NULL");
2362 return QDF_STATUS_E_NULL_VALUE;
2363 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002364 /* HDD has initiated disconnect, do not send connect result indication
2365 * to kernel as it will be handled by __cfg80211_disconnect.
2366 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302367 if (((eConnectionState_Disconnecting ==
2368 pHddStaCtx->conn_info.connState) ||
2369 (eConnectionState_NotConnected ==
2370 pHddStaCtx->conn_info.connState)) &&
2371 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2372 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002373 hdd_info("Disconnect from HDD in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002374 hddDisconInProgress = true;
2375 }
2376
2377 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2378 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002379 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302380 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002381 }
2382 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002383 hdd_conn_set_connection_state(pAdapter,
2384 eConnectionState_Associated);
2385 }
2386 /* Save the connection info from CSR... */
2387 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2388 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002389
2390 if (hdd_add_beacon_filter(pAdapter) != 0)
2391 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002392#ifdef FEATURE_WLAN_WAPI
2393 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2394 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2395 || pRoamInfo->u.pConnectedProfile->AuthType ==
2396 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2397 pAdapter->wapi_info.fIsWapiSta = 1;
2398 } else {
2399 pAdapter->wapi_info.fIsWapiSta = 0;
2400 }
2401#endif /* FEATURE_WLAN_WAPI */
2402
2403 /* Indicate 'connect' status to user space */
2404 hdd_send_association_event(dev, pRoamInfo);
2405
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002406 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002407 if (pHddCtx->miracast_value)
2408 cds_set_mas(pAdapter, pHddCtx->miracast_value);
2409 }
2410
2411 /* Initialize the Linkup event completion variable */
2412 INIT_COMPLETION(pAdapter->linkup_event_var);
2413
2414 /*
2415 * Sometimes Switching ON the Carrier is taking time to activate
2416 * the device properly. Before allowing any packet to go up to
2417 * the application, device activation has to be ensured for
2418 * proper queue mapping by the kernel. we have registered net
2419 * device notifier for device change notification. With this we
2420 * will come to know that the device is getting
2421 * activated properly.
2422 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002423 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002424 /*
2425 * Enable Linkup Event Servicing which allows the net
2426 * device notifier to set the linkup event variable.
2427 */
2428 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002429
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002430 /* Switch on the Carrier to activate the device */
2431 wlan_hdd_netif_queue_control(pAdapter,
2432 WLAN_NETIF_CARRIER_ON,
2433 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002434
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002435 /*
2436 * Wait for the Link to up to ensure all the queues
2437 * are set properly by the kernel.
2438 */
2439 rc = wait_for_completion_timeout(
2440 &pAdapter->linkup_event_var,
2441 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2442 );
2443 if (!rc)
2444 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002445
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002446 /*
2447 * Disable Linkup Event Servicing - no more service
2448 * required from the net device notifier call.
2449 */
2450 pAdapter->isLinkUpSvcNeeded = false;
2451 } else {
2452 pHddStaCtx->ft_carrier_on = false;
2453 ft_carrier_on = true;
2454 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002455 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2456 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2457 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002458 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002459
2460 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2461
2462 if (hdd_ipa_is_enabled(pHddCtx))
2463 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002464 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 pRoamInfo->bssid.bytes);
2466
2467#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2468 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2469#endif
2470
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05302471 hdd_info("check for SAP restart");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07002472 cds_check_concurrent_intf_and_restart_sap(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002473
Nirav Shah1da77682016-05-03 20:16:39 +05302474 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2475 pAdapter->sessionId,
2476 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2477
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478 /*
2479 * For reassoc, the station is already registered, all we need
2480 * is to change the state of the STA in TL.
2481 * If authentication is required (WPA/WPA2/DWEP), change TL to
2482 * CONNECTED instead of AUTHENTICATED.
2483 */
2484 if (!pRoamInfo->fReassocReq) {
2485 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002486 u8 *pFTAssocRsp = NULL;
2487 unsigned int assocRsplen = 0;
2488 u8 *pFTAssocReq = NULL;
2489 unsigned int assocReqlen = 0;
2490 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2492 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2493
2494 /* add bss_id to cfg80211 data base */
2495 bss =
2496 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2497 pRoamInfo);
2498 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302499 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002500 wlan_hdd_netif_queue_control(pAdapter,
2501 WLAN_NETIF_CARRIER_OFF,
2502 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302503 if (!hddDisconInProgress) {
2504 /*
2505 * Here driver was not able to add bss
2506 * in cfg80211 database this can happen
2507 * if connected channel is not valid,
2508 * i.e reg domain was changed during
2509 * connection. Queue disconnect for the
2510 * session if disconnect is not in
2511 * progress.
2512 */
2513 hdd_err("Disconnecting...");
2514 sme_roam_disconnect(
2515 WLAN_HDD_GET_HAL_CTX(pAdapter),
2516 pAdapter->sessionId,
2517 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2518 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302519 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002521 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2522 eCSR_AUTH_TYPE_FT_RSN
2523 || pRoamInfo->u.pConnectedProfile->AuthType ==
2524 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2525
2526 /* Association Response */
2527 pFTAssocRsp =
2528 (u8 *) (pRoamInfo->pbFrames +
2529 pRoamInfo->nBeaconLength +
2530 pRoamInfo->nAssocReqLength);
2531 if (pFTAssocRsp != NULL) {
2532 /*
2533 * pFTAssocRsp needs to point to the IEs
2534 */
2535 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002536 hdd_info("AssocRsp is now at %02x%02x",
2537 (unsigned int)pFTAssocRsp[0],
2538 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 assocRsplen =
2540 pRoamInfo->nAssocRspLength -
2541 FT_ASSOC_RSP_IES_OFFSET;
2542 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002543 hdd_err("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002544 assocRsplen = 0;
2545 }
2546
2547 /* Association Request */
2548 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2549 pRoamInfo->nBeaconLength);
2550 if (pFTAssocReq != NULL) {
2551 if (!ft_carrier_on) {
2552 /*
2553 * pFTAssocReq needs to point to
2554 * the IEs
2555 */
2556 pFTAssocReq +=
2557 FT_ASSOC_REQ_IES_OFFSET;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002558 hdd_info("pFTAssocReq is now at %02x%02x",
2559 (unsigned int)
2560 pFTAssocReq[0],
2561 (unsigned int)
2562 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002563 assocReqlen =
2564 pRoamInfo->nAssocReqLength -
2565 FT_ASSOC_REQ_IES_OFFSET;
2566 } else {
2567 /*
2568 * This should contain only the
2569 * FTIEs
2570 */
2571 assocReqlen =
2572 pRoamInfo->nAssocReqLength;
2573 }
2574 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002575 hdd_err("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 assocReqlen = 0;
2577 }
2578
2579 if (ft_carrier_on) {
2580 if (!hddDisconInProgress) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302581 struct cfg80211_bss *roam_bss;
2582
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002583 /*
2584 * After roaming is completed,
2585 * active session count is
2586 * incremented as a part of
2587 * connect indication but
2588 * effectively the active
2589 * session count should still
2590 * be the same and hence upon
2591 * successful reassoc
2592 * decrement the active session
2593 * count here.
2594 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002595 if (!hdd_is_roam_sync_in_progress
2596 (pRoamInfo))
2597 cds_decr_session_set_pcl
2598 (pAdapter->device_mode,
2599 pAdapter->sessionId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002600 hdd_info("ft_carrier_on is %d, sending roamed indication",
2601 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002602 chan =
2603 ieee80211_get_channel
2604 (pAdapter->wdev.wiphy,
2605 (int)pRoamInfo->pBssDesc->
2606 channelId);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002607 hdd_info(
2608 "assocReqlen %d assocRsplen %d",
2609 assocReqlen,
2610 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002611
2612 hdd_notice(
2613 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302614 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302615 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302616 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002617 pFTAssocReq,
2618 assocReqlen);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302619 roam_bss =
2620 hdd_cfg80211_get_bss(
2621 pAdapter->wdev.wiphy,
2622 chan,
2623 pRoamInfo->bssid.bytes,
2624 pRoamInfo->u.
2625 pConnectedProfile->SSID.ssId,
2626 pRoamInfo->u.
2627 pConnectedProfile->SSID.length);
2628 cfg80211_roamed_bss(dev,
2629 roam_bss,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002630 pFTAssocReq,
2631 assocReqlen,
2632 pFTAssocRsp,
2633 assocRsplen,
2634 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002635 wlan_hdd_send_roam_auth_event(
Prakash Dhavali989127d2016-11-29 14:56:44 +05302636 pAdapter,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002637 pRoamInfo->bssid.bytes,
2638 pFTAssocReq,
2639 assocReqlen,
2640 pFTAssocRsp,
2641 assocRsplen,
2642 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 }
2644 if (sme_get_ftptk_state
2645 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2646 pAdapter->sessionId)) {
2647 sme_set_ftptk_state
2648 (WLAN_HDD_GET_HAL_CTX
2649 (pAdapter),
2650 pAdapter->sessionId,
2651 false);
2652 pRoamInfo->fAuthRequired =
2653 false;
2654
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302655 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002656 roam_info.bssid,
2657 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302658 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302659 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002660 roam_info.peerMac,
2661 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302662 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002663 pHddStaCtx->roam_info.roamId =
2664 roamId;
2665 pHddStaCtx->roam_info.
2666 roamStatus = roamStatus;
2667 pHddStaCtx->roam_info.
2668 deferKeyComplete = true;
2669 }
2670 } else if (!hddDisconInProgress) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002671 hdd_info("ft_carrier_on is %d, sending connect indication",
2672 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302673 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002674 pRoamInfo->
2675 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302676 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 pFTAssocReq,
2678 assocReqlen,
2679 pFTAssocRsp,
2680 assocRsplen,
2681 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302682 GFP_KERNEL,
2683 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002684 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002685 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002686 /*
2687 * wpa supplicant expecting WPA/RSN IE in
2688 * connect result.
2689 */
2690 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2691 (pAdapter),
2692 pAdapter->sessionId,
2693 &reqRsnLength,
2694 reqRsnIe);
2695
2696 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2697 (pAdapter),
2698 pAdapter->sessionId,
2699 &rspRsnLength,
2700 rspRsnIe);
2701 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002702 if (ft_carrier_on)
2703 hdd_send_re_assoc_event(dev,
2704 pAdapter,
2705 pRoamInfo,
2706 reqRsnIe,
2707 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002708 else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002709 hdd_info("sending connect indication to nl80211:for bssid "
2710 MAC_ADDRESS_STR
2711 " result:%d and Status:%d",
2712 MAC_ADDR_ARRAY
2713 (pRoamInfo->bssid.bytes),
2714 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002715
2716 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302717 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002718 pRoamInfo->
2719 bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302720 pRoamInfo,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002721 reqRsnIe,
2722 reqRsnLength,
2723 rspRsnIe,
2724 rspRsnLength,
2725 WLAN_STATUS_SUCCESS,
Abhishek Singha84d3952016-09-13 13:45:05 +05302726 GFP_KERNEL,
2727 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002728 }
2729 }
2730 }
2731 if (!hddDisconInProgress) {
2732 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002733 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002734 bss);
2735
2736 /*
2737 * Perform any WMM-related association
2738 * processing.
2739 */
2740 hdd_wmm_assoc(pAdapter, pRoamInfo,
2741 eCSR_BSS_TYPE_INFRASTRUCTURE);
2742
2743 /*
2744 * Start the Queue - Start tx queues before
2745 * hdd_roam_register_sta, since
2746 * hdd_roam_register_sta will flush any cached
2747 * data frames immediately.
2748 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002749 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002750 wlan_hdd_netif_queue_control(pAdapter,
2751 WLAN_WAKE_ALL_NETIF_QUEUE,
2752 WLAN_CONTROL_PATH);
2753
2754 /*
2755 * Register the Station with TL after associated
2756 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302757 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002758 pRoamInfo,
2759 pHddStaCtx->
2760 conn_info.
2761 staId[0],
2762 NULL,
2763 pRoamInfo->
2764 pBssDesc);
2765 }
2766 } else {
2767 /*
2768 * wpa supplicant expecting WPA/RSN IE in connect result
2769 * in case of reassociation also need to indicate it to
2770 * supplicant.
2771 */
2772 csr_roam_get_wpa_rsn_req_ie(
2773 WLAN_HDD_GET_HAL_CTX(pAdapter),
2774 pAdapter->sessionId,
2775 &reqRsnLength, reqRsnIe);
2776
2777 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2778 reqRsnIe, reqRsnLength);
2779 /* Reassoc successfully */
2780 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302781 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002782 hdd_change_peer_state(pAdapter,
2783 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002784 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002785#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2786 pRoamInfo->roamSynchInProgress
2787#else
2788 false
2789#endif
2790 );
2791 hdd_conn_set_authenticated(pAdapter, false);
2792 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002793 hdd_info("staId: %d Changing TL state to AUTHENTICATED",
2794 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302795 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002796 hdd_change_peer_state(pAdapter,
2797 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002798 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002799#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2800 pRoamInfo->roamSynchInProgress
2801#else
2802 false
2803#endif
2804 );
2805 hdd_conn_set_authenticated(pAdapter, true);
2806 }
2807
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302808 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 /*
2810 * Perform any WMM-related association
2811 * processing
2812 */
2813 hdd_wmm_assoc(pAdapter, pRoamInfo,
2814 eCSR_BSS_TYPE_INFRASTRUCTURE);
2815 }
2816
2817 /* Start the tx queues */
2818#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2819 if (pRoamInfo->roamSynchInProgress)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002820 hdd_info("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002821#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002822 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002823 wlan_hdd_netif_queue_control(pAdapter,
2824 WLAN_WAKE_ALL_NETIF_QUEUE,
2825 WLAN_CONTROL_PATH);
2826 }
2827
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05302828#ifdef FEATURE_WLAN_TDLS
2829 wlan_hdd_tdls_connection_callback(pAdapter);
2830#endif
2831
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302832 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002833 hdd_err("STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302834 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002835 }
2836#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302837 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002838 sizeof(pAdapter->hdd_stats.hddPmfStats));
2839#endif
2840 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05302841 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002842 hdd_wext_state_t *pWextState =
2843 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2844 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302845 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2846 " result:%d and Status:%d",
2847 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2848 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002849 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05302850 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
2851 " result:%d and Status:%d",
2852 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2853 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05302854
2855 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2856 (pRoamInfo &&
2857 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2858 pRoamInfo->statusCode) ||
2859 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2860 pRoamInfo->statusCode) ||
2861 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2862 pRoamInfo->statusCode)))) {
2863 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2864 pRoamInfo ?
2865 pRoamInfo->bssid.bytes :
2866 pWextState->req_bssId.bytes);
2867 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2868 pRoamInfo ?
2869 pRoamInfo->bssid.bytes :
2870 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05302871 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05302872 }
2873
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002874 /*
2875 * CR465478: Only send up a connection failure result when CSR
2876 * has completed operation - with a ASSOCIATION_FAILURE status.
2877 */
2878 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2879 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302880 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002881 hdd_err("send connect failure to nl80211: for bssid "
2882 MAC_ADDRESS_STR
2883 " result:%d and Status:%d reasoncode %d",
2884 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2885 roamResult, roamStatus,
2886 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05302887 pHddStaCtx->conn_info.assoc_status_code =
2888 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08002889 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002890 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002891 MAC_ADDRESS_STR
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002892 " result:%d and Status:%d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002893 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2894 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08002895 }
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05302896 hdd_err("Invoking packetdump deregistration API");
2897 wlan_deregister_txrx_packetdump();
2898
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002899 /* inform association failure event to nl80211 */
2900 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2901 roamResult) {
2902 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302903 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302905 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002906 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302907 GFP_KERNEL,
2908 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002909 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302910 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002911 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302912 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002913 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05302914 GFP_KERNEL,
2915 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002916 } else {
Wu Gao77d28352016-11-23 17:50:56 +08002917 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05302918 hdd_connect_result(dev,
2919 pRoamInfo->bssid.bytes,
2920 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08002921 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05302922 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002923 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302924 GFP_KERNEL,
2925 connect_timeout);
Wu Gao77d28352016-11-23 17:50:56 +08002926 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05302927 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05302929 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302931 GFP_KERNEL,
2932 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002933 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302934 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002935 } else if ((eCSR_ROAM_CANCELLED == roamStatus
2936 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05302937 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002938 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05302939 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002940 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05302941 GFP_KERNEL,
2942 connect_timeout);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002943 }
2944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002945 /*
2946 * Set connection state to eConnectionState_NotConnected only
2947 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002948 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002949 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07002950 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
2951 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002952 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002953 hdd_conn_set_connection_state(pAdapter,
2954 eConnectionState_NotConnected);
2955 }
2956 hdd_wmm_init(pAdapter);
2957
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002958 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002959 wlan_hdd_netif_queue_control(pAdapter,
2960 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2961 WLAN_CONTROL_PATH);
2962 }
2963
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302964 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002965 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302966 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002967
Govind Singh24db1ed2015-12-18 15:54:59 +05302968 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2969 cds_force_sap_on_scc(roamResult,
2970 pRoamInfo->pBssDesc->channelId);
2971 } else {
2972 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302973 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302974 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302976 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002977}
2978
2979/**
2980 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
2981 * @pAdapter: pointer to adapter
2982 * @pRoamInfo: pointer to roam info
2983 * @roamId: roam id
2984 * @roamStatus: roam status
2985 * @roamResult: roam result
2986 *
2987 * Here we update the status of the Ibss when we receive information that we
2988 * have started/joined an ibss session.
2989 *
2990 * Return: none
2991 */
2992static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
2993 tCsrRoamInfo *pRoamInfo,
2994 uint32_t roamId,
2995 eRoamCmdStatus roamStatus,
2996 eCsrRoamResult roamResult)
2997{
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002998 hdd_info("%s: id %d, status %d, result %d",
2999 pAdapter->dev->name, roamId,
3000 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003001
3002 switch (roamResult) {
3003 /* both IBSS Started and IBSS Join should come in here. */
3004 case eCSR_ROAM_RESULT_IBSS_STARTED:
3005 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3006 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3007 {
3008 hdd_context_t *pHddCtx =
3009 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303010 hdd_station_ctx_t *hdd_sta_ctx =
3011 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303012 struct qdf_mac_addr broadcastMacAddr =
3013 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003014
3015 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303016 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003017 return;
3018 }
3019
3020 /* When IBSS Started comes from CSR, we need to move
3021 * connection state to IBSS Disconnected (meaning no peers
3022 * are in the IBSS).
3023 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003024 hdd_conn_set_connection_state(pAdapter,
3025 eConnectionState_IbssDisconnected);
3026 /* notify wmm */
3027 hdd_wmm_connect(pAdapter, pRoamInfo,
3028 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303029
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003030 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303031
3032 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003033 pAdapter;
3034 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303035 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003036 &broadcastMacAddr,
3037 pRoamInfo->pBssDesc);
3038
3039 if (pRoamInfo->pBssDesc) {
3040 struct cfg80211_bss *bss;
3041#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3042 struct ieee80211_channel *chan;
3043 int chan_no;
3044 unsigned int freq;
3045#endif
3046 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003047 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3048 pAdapter->dev->name,
3049 MAC_ADDR_ARRAY(
3050 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003051
3052 /* we must first give cfg80211 the BSS information */
3053 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3054 pRoamInfo);
3055 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003056 hdd_err("%s: unable to create IBSS entry",
3057 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003058 return;
3059 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003060 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003061 wlan_hdd_netif_queue_control(pAdapter,
3062 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3063 WLAN_CONTROL_PATH);
3064
3065#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3066 chan_no = pRoamInfo->pBssDesc->channelId;
3067
3068 if (chan_no <= 14)
3069 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003070 NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003071 else
3072 freq = ieee80211_channel_to_frequency(chan_no,
Dustin Browna30892e2016-10-12 17:28:36 -07003073 NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003074
3075 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3076
3077 if (chan)
3078 cfg80211_ibss_joined(pAdapter->dev,
3079 bss->bssid, chan,
3080 GFP_KERNEL);
3081 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003082 hdd_err("%s: chanId: %d, can't find channel",
3083 pAdapter->dev->name,
3084 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085#else
3086 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3087 GFP_KERNEL);
3088#endif
3089 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003091 bss);
3092 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003093 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003094 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07003095 pAdapter->sessionId);
3096 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3097 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08003098 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003099 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003100 break;
3101 }
3102
3103 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3104 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003105 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003106 break;
3107 }
3108
3109 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003110 hdd_err("%s: unexpected result %d",
3111 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003112 break;
3113 }
3114
3115 return;
3116}
3117
3118/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003119 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3120 * @sta_ctx: pointer to hdd station context
3121 * @sta_id: station ID
3122 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003123 *
3124 * This information is passed to iwconfig later. The peer that joined
3125 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003126
3127 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003128 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003129bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3130 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003131{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003132 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003133
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003134 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
3135 if (0 == sta_ctx->conn_info.staId[idx]) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003136 hdd_info("adding peer: %pM, sta_id: %d, at idx: %d",
3137 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003138 sta_ctx->conn_info.staId[idx] = sta_id;
3139 qdf_copy_macaddr(
3140 &sta_ctx->conn_info.peerMacAddress[idx],
3141 peer_mac_addr);
3142 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003143 }
3144 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003145 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003146}
3147
3148/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003149 * hdd_delete_peer() - removes peer from hdd station context peer table
3150 * @sta_ctx: pointer to hdd station context
3151 * @sta_id: station ID
3152 *
3153 * Return: None
3154 */
3155void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3156{
3157 int i;
3158
3159 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3160 if (sta_id == sta_ctx->conn_info.staId[i]) {
3161 sta_ctx->conn_info.staId[i] = 0;
3162 return;
3163 }
3164 }
3165
3166 hdd_err(FL("sta_id %d is not present in peer table"), sta_id);
3167}
3168
3169/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3171 * @pAdapter: pointer to adapter
3172 * @staId: station id
3173 *
3174 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003175 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003176 * false otherwise.
3177 */
3178static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3179{
3180 bool fSuccess = false;
3181 int idx = 0;
3182 uint8_t valid_idx = 0;
3183 uint8_t del_idx = 0;
3184 uint8_t empty_slots = 0;
3185 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3186
Naveen Rawatc45d1622016-07-05 12:20:09 -07003187 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003188 if (staId == pHddStaCtx->conn_info.staId[idx]) {
3189 pHddStaCtx->conn_info.staId[idx] = 0;
3190
Anurag Chouhanc5548422016-02-24 18:33:27 +05303191 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003192 peerMacAddress[idx]);
3193
3194 fSuccess = true;
3195
3196 /*
3197 * Note the deleted Index, if its 0 we need special
3198 * handling.
3199 */
3200 del_idx = idx;
3201
3202 empty_slots++;
3203 } else {
3204 if (pHddStaCtx->conn_info.staId[idx] != 0) {
3205 valid_idx = idx;
3206 } else {
3207 /* Found an empty slot */
3208 empty_slots++;
3209 }
3210 }
3211 }
3212
Naveen Rawatc45d1622016-07-05 12:20:09 -07003213 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 /* Last peer departed, set the IBSS state appropriately */
3215 pHddStaCtx->conn_info.connState =
3216 eConnectionState_IbssDisconnected;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003217 hdd_err("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 }
3219 /* Find next active staId, to have a valid sta trigger for TL. */
3220 if (fSuccess == true) {
3221 if (del_idx == 0) {
3222 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
3223 pHddStaCtx->conn_info.staId[0] =
3224 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303225 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003226 peerMacAddress[0],
3227 &pHddStaCtx->conn_info.
3228 peerMacAddress[valid_idx]);
3229
3230 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303231 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003232 peerMacAddress[valid_idx]);
3233 }
3234 }
3235 }
3236 return fSuccess;
3237}
3238
3239/**
3240 * roam_ibss_connect_handler() - IBSS connection handler
3241 * @pAdapter: pointer to adapter
3242 * @pRoamInfo: pointer to roam info
3243 *
3244 * We update the status of the IBSS to connected in this function.
3245 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303246 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003247 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303248static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003249 tCsrRoamInfo *pRoamInfo)
3250{
3251 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 /*
3253 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3254 * a partner stations).
3255 */
3256 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3257
3258 /* Save the connection info from CSR... */
3259 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3260
3261 /* Send the bssid address to the wext. */
3262 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3263 /* add bss_id to cfg80211 data base */
3264 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3265 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003266 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003267 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303268 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003269 }
3270 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003271 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003272 bss);
3273
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303274 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003275}
3276
3277/**
3278 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3279 * @pAdapter: pointer to adapter
3280 * @pRoamInfo: pointer to roam info
3281 * @roamId: roam id
3282 * @roamStatus: roam status
3283 * @roamResult: roam result
3284 *
3285 * This function indicates the Mic failure to the supplicant
3286 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303287 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003288 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303289static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003290hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3291 tCsrRoamInfo *pRoamInfo,
3292 uint32_t roamId,
3293 eRoamCmdStatus roamStatus,
3294 eCsrRoamResult roamResult)
3295{
3296 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3297
3298 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3299 TKIP_COUNTER_MEASURE_STOPED ==
3300 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3301 struct iw_michaelmicfailure msg;
3302 union iwreq_data wreq;
3303 memset(&msg, '\0', sizeof(msg));
3304 msg.src_addr.sa_family = ARPHRD_ETHER;
3305 memcpy(msg.src_addr.sa_data,
3306 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3307 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003308 hdd_info("MIC MAC " MAC_ADDRESS_STR,
3309 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003310
3311 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3312 msg.flags = IW_MICFAILURE_GROUP;
3313 else
3314 msg.flags = IW_MICFAILURE_PAIRWISE;
3315 memset(&wreq, 0, sizeof(wreq));
3316 wreq.data.length = sizeof(msg);
3317 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3318 (char *)&msg);
3319 /* inform mic failure to nl80211 */
3320 cfg80211_michael_mic_failure(pAdapter->dev,
3321 pRoamInfo->u.pMICFailureInfo->
3322 taMacAddr,
3323 ((pRoamInfo->u.pMICFailureInfo->
3324 multicast ==
3325 eSIR_TRUE) ?
3326 NL80211_KEYTYPE_GROUP :
3327 NL80211_KEYTYPE_PAIRWISE),
3328 pRoamInfo->u.pMICFailureInfo->
3329 keyId,
3330 pRoamInfo->u.pMICFailureInfo->TSC,
3331 GFP_KERNEL);
3332
3333 }
3334
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303335 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336}
3337
3338/**
3339 * roam_roam_connect_status_update_handler() - IBSS connect status update
3340 * @pAdapter: pointer to adapter
3341 * @pRoamInfo: pointer to roam info
3342 * @roamId: roam id
3343 * @roamStatus: roam status
3344 * @roamResult: roam result
3345 *
3346 * The Ibss connection status is updated regularly here in this function.
3347 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303348 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003349 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303350static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003351roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3352 tCsrRoamInfo *pRoamInfo,
3353 uint32_t roamId,
3354 eRoamCmdStatus roamStatus,
3355 eCsrRoamResult roamResult)
3356{
Rajeev Kumardfa37072017-01-13 16:27:22 -08003357 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003358 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003359 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303360
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 switch (roamResult) {
3362 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3363 {
3364 hdd_station_ctx_t *pHddStaCtx =
3365 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003366 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003367 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003368
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303369 hdd_err("IBSS New Peer indication from SME "
3370 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3371 MAC_ADDRESS_STR " and stationID= %d",
3372 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3373 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3374 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003375
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003376 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003377 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3378 pRoamInfo->staId,
3379 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003380 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003381 break;
3382 }
3383
3384 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3385
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003386 if (hdd_is_key_install_required_for_ibss(encr_type))
3387 pRoamInfo->fAuthRequired = true;
3388
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003389 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303390 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003391 pRoamInfo,
3392 pRoamInfo->staId,
3393 &pRoamInfo->peerMac,
3394 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303395 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003396 hdd_err("Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303397 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 }
3399 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003400 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3401 if (stainfo == NULL) {
3402 hdd_err("memory allocation for station_info failed");
3403 return QDF_STATUS_E_NOMEM;
3404 }
3405 stainfo->filled = 0;
3406 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407
3408 cfg80211_new_sta(pAdapter->dev,
3409 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003410 stainfo, GFP_KERNEL);
3411 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003412
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003413 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 pHddStaCtx->ibss_enc_key.keyDirection =
3415 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303416 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 &pRoamInfo->peerMac);
3418
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003419 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003420 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003421
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303422 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003423 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3424 (pAdapter),
3425 pAdapter->sessionId,
3426 &pHddStaCtx->ibss_enc_key,
3427 &roamId);
3428
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303429 if (QDF_STATUS_SUCCESS != qdf_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003430 hdd_err("sme_roam_set_key failed, status=%d",
3431 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303432 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003433 }
3434 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003435 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003436 wlan_hdd_netif_queue_control(pAdapter,
3437 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3438 WLAN_CONTROL_PATH);
3439 break;
3440 }
3441
3442 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3443 {
3444
3445 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3446
3447 break;
3448 }
3449 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3450 {
3451 hdd_station_ctx_t *pHddStaCtx =
3452 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3453
3454 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003455 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003456
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303457 hdd_err("IBSS Peer Departed from SME "
3458 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3459 MAC_ADDRESS_STR " and stationID= %d",
3460 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3461 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3462 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003463
3464 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3465
3466 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3467 pHddStaCtx->ibss_sta_generation++;
3468
Rajeev Kumardfa37072017-01-13 16:27:22 -08003469 ret = hdd_remove_peer_object(pAdapter->hdd_vdev,
3470 pRoamInfo->peerMac.bytes);
3471 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303472 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
3473 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3474
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003475 cfg80211_del_sta(pAdapter->dev,
3476 (const u8 *)&pRoamInfo->peerMac.bytes,
3477 GFP_KERNEL);
3478 break;
3479 }
3480 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3481 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003482 hdd_info("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003484 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485 wlan_hdd_netif_queue_control(pAdapter,
3486 WLAN_NETIF_TX_DISABLE_N_CARRIER,
3487 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003488 hdd_conn_set_connection_state(pAdapter,
3489 eConnectionState_NotConnected);
3490
3491 /* Send the bssid address to the wext. */
3492 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3493 break;
3494 }
3495 default:
3496 break;
3497
3498 }
3499
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303500 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003501}
3502
3503#ifdef FEATURE_WLAN_TDLS
3504/**
3505 * hdd_roam_register_tdlssta() - register new TDLS station
3506 * @pAdapter: pointer to adapter
3507 * @peerMac: pointer to peer MAC address
3508 * @staId: station identifier
3509 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303510 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003511 *
3512 * Construct the staDesc and register with TL the new STA.
3513 * This is called as part of ADD_STA in the TDLS setup.
3514 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303515 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003516 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303517QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003518 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303519 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003520{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303521 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003523 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003524 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3525 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003526
3527 /*
3528 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3529 * be peer MAC, here we are working on direct Link
3530 */
3531 staDesc.sta_id = staId;
3532
3533 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303534 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003535
Dhanashri Atre50141c52016-04-07 13:15:29 -07003536 /* Register the vdev transmit and receive functions */
3537 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3538 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003539 cdp_vdev_register(soc,
3540 cdp_get_vdev_from_vdev_id(soc, pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003541 pAdapter, &txrx_ops);
3542 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003543
3544 /* Register the Station with TL... */
Leo Changfdb45c32016-10-28 11:09:23 -07003545 qdf_status = cdp_peer_register(soc, pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303546 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003547 hdd_err("cdp_peer_register() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303548 qdf_status, qdf_status);
3549 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003550 }
3551
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303552 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553}
3554
3555/**
3556 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3557 * @pAdapter: pointer to adapter
3558 * @staId: station identifier
3559 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303560 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003561 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303562static QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563 uint8_t staId)
3564{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303565 QDF_STATUS qdf_status;
Leo Changfdb45c32016-10-28 11:09:23 -07003566 qdf_status = cdp_peer_clear(cds_get_context(QDF_MODULE_ID_SOC),
3567 cds_get_context(QDF_MODULE_ID_TXRX), staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303568 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Leo Changfdb45c32016-10-28 11:09:23 -07003569 hdd_warn("cdp_peer_clear() failed for staID %d. Status=%d [0x%08X]",
3570 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003571 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303572 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003573}
3574
3575/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003576 * hdd_tdls_connection_tracker_update() - update connection tracker state
3577 * @adapter: pointer to adapter
3578 * @roam_info: pointer to roam info
3579 * @hdd_tdls_ctx: tdls context
3580 *
3581 * Return: QDF_STATUS enumeration
3582 */
3583static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3584 tCsrRoamInfo *roam_info,
3585 tdlsCtx_t *hdd_tdls_ctx)
3586{
3587 hddTdlsPeer_t *curr_peer;
3588 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3589
3590 curr_peer = wlan_hdd_tdls_find_peer(adapter,
3591 roam_info->peerMac.bytes, true);
3592
3593 if (!curr_peer) {
3594 hdd_err("curr_peer is null");
3595 return QDF_STATUS_E_FAILURE;
3596 }
3597
3598 mutex_lock(&hdd_ctx->tdls_lock);
3599
3600 if (eTDLS_LINK_CONNECTED ==
3601 curr_peer->link_status) {
3602 hdd_err("Received CONNECTION_TRACKER_NOTIFICATION "
3603 MAC_ADDRESS_STR
3604 " staId: %d, reason: %d",
3605 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3606 roam_info->staId,
3607 roam_info->reasonCode);
3608
3609 if (roam_info->reasonCode ==
3610 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3611 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003612 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3613 roam_info->reasonCode ==
3614 eWMI_TDLS_SCAN_STARTED_EVENT)
3615 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003616 else if (roam_info->reasonCode ==
3617 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3618 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003619 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3620 roam_info->reasonCode ==
3621 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3622 hdd_ctx->enable_tdls_connection_tracker = true;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003623
3624 } else {
3625 hdd_err("TDLS not connected, ignore notification, reason: %d",
3626 roam_info->reasonCode);
3627 }
3628
3629 mutex_unlock(&hdd_ctx->tdls_lock);
3630
3631 return QDF_STATUS_SUCCESS;
3632}
3633
3634
3635
3636
3637/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003638 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3639 * @pAdapter: pointer to adapter
3640 * @pRoamInfo: pointer to roam info
3641 * @roamId: roam id
3642 * @roamStatus: roam status
3643 * @roamResult: roam result
3644 *
3645 * HDD interface between SME and TL to ensure TDLS client registration with
3646 * TL in case of new TDLS client is added and deregistration at the time
3647 * TDLS client is deleted.
3648 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303649 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003650 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303651static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003652hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3653 tCsrRoamInfo *pRoamInfo,
3654 uint32_t roamId,
3655 eRoamCmdStatus roamStatus,
3656 eCsrRoamResult roamResult)
3657{
3658 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3659 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3660 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303661 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003662 uint8_t staIdx;
3663 hddTdlsPeer_t *curr_peer;
3664 uint32_t reason;
3665
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003666 hdd_info("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003667 roamResult ==
3668 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3669 ==
3670 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3671 roamResult ==
3672 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3673 : roamResult ==
3674 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3675 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3676 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3677 roamResult ==
3678 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3679 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3680 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3681 : roamResult ==
3682 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3683 : roamResult ==
3684 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3685 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3686 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3687
3688 if (!pHddTdlsCtx) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003689 hdd_info("TDLS ctx is null, ignore roamResult (%d)",
3690 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003691 return status;
3692 }
3693
3694 switch (roamResult) {
3695 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3696 {
3697 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003698 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003699 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303700 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3701
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003702 } else {
3703 /*
3704 * Check if there is available index for this new TDLS
3705 * STA.
3706 */
3707 for (staIdx = 0;
3708 staIdx < pHddCtx->max_num_tdls_sta;
3709 staIdx++) {
3710 if (0 ==
3711 pHddCtx->tdlsConnInfo[staIdx].
3712 staId) {
3713 pHddCtx->tdlsConnInfo[staIdx].
3714 sessionId =
3715 pRoamInfo->sessionId;
3716 pHddCtx->tdlsConnInfo[staIdx].
3717 staId = pRoamInfo->staId;
3718
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003719 hdd_warn("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003720 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003721 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003722 staIdx,
3723 pHddCtx->
3724 tdlsConnInfo[staIdx].
3725 staId,
3726 MAC_ADDR_ARRAY
3727 (pRoamInfo->peerMac.bytes));
3728
Anurag Chouhanc5548422016-02-24 18:33:27 +05303729 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003730 tdlsConnInfo
3731 [staIdx].
3732 peerMac,
3733 &pRoamInfo->
3734 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303735 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003736 break;
3737 }
3738 }
3739 if (staIdx < pHddCtx->max_num_tdls_sta) {
3740 if (-1 ==
3741 wlan_hdd_tdls_set_sta_id(pAdapter,
3742 pRoamInfo->
3743 peerMac.bytes,
3744 pRoamInfo->
3745 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003746 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303747 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003748 }
3749
3750 (WLAN_HDD_GET_CTX(pAdapter))->
3751 sta_to_adapter[pRoamInfo->staId] =
3752 pAdapter;
3753 /*
3754 * store the ucast signature,
3755 * if required for further reference.
3756 */
3757
3758 wlan_hdd_tdls_set_signature(pAdapter,
3759 pRoamInfo->
3760 peerMac.bytes,
3761 pRoamInfo->
3762 ucastSig);
3763 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303764 status = QDF_STATUS_E_FAILURE;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003765 hdd_err("no available slot in conn_info. staId %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003766 pRoamInfo->staId);
3767 }
3768 pAdapter->tdlsAddStaStatus = status;
3769 }
3770 complete(&pAdapter->tdls_add_station_comp);
3771 break;
3772 }
3773 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3774 {
3775 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003776 hdd_err("Add Sta failed. status code(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003777 pRoamInfo->statusCode);
3778 }
3779 /* store the ucast signature which will be used later when
3780 * registering to TL
3781 */
3782 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3783 complete(&pAdapter->tdls_add_station_comp);
3784 break;
3785 }
3786 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3787 {
3788 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003789 hdd_err("Link Establish Request failed. status(=%d)",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003790 pRoamInfo->statusCode);
3791 }
3792 complete(&pAdapter->tdls_link_establish_req_comp);
3793 break;
3794 }
3795 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3796 {
3797 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3798 staIdx++) {
3799 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3800 pRoamInfo->sessionId)
3801 && pRoamInfo->staId ==
3802 pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003803 hdd_warn("HDD: del STA IDX = %x",
3804 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003805
3806 curr_peer =
3807 wlan_hdd_tdls_find_peer(pAdapter,
3808 pRoamInfo->
3809 peerMac.bytes,
3810 true);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303811 if (NULL != curr_peer) {
3812 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3813 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3814 curr_peer->link_status);
3815 if (TDLS_IS_CONNECTED(curr_peer)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003816 hdd_roam_deregister_tdlssta
3817 (pAdapter,
3818 pRoamInfo->staId);
3819 wlan_hdd_tdls_decrement_peer_count
3820 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303821 } else if (eTDLS_LINK_CONNECTING ==
3822 curr_peer->link_status) {
3823 hdd_roam_deregister_tdlssta
3824 (pAdapter,
3825 pRoamInfo->staId);
3826 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003827 }
3828 wlan_hdd_tdls_reset_peer(pAdapter,
3829 pRoamInfo->
3830 peerMac.bytes);
3831
3832 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3833 pHddCtx->tdlsConnInfo[staIdx].
3834 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303835 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003836 tdlsConnInfo[staIdx].
3837 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303838 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303839 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840 break;
3841 }
3842 }
3843 complete(&pAdapter->tdls_del_station_comp);
3844 }
3845 break;
3846 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3847 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003848 hdd_err("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003849 pRoamInfo->reasonCode);
3850
3851 curr_peer =
3852 wlan_hdd_tdls_find_peer(pAdapter,
3853 pRoamInfo->peerMac.bytes, true);
3854 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
3855 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303856 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3857 curr_peer->peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303858 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003859 break;
3860 }
3861 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3862 {
3863 /* 0 staIdx is assigned to AP we dont want to touch that */
3864 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3865 staIdx++) {
3866 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3867 pRoamInfo->sessionId)
3868 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003869 hdd_warn("hdd_tdlsStatusUpdate: staIdx %d "
3870 MAC_ADDRESS_STR,
3871 pHddCtx->tdlsConnInfo[staIdx].
3872 staId,
3873 MAC_ADDR_ARRAY(pHddCtx->
3874 tdlsConnInfo
3875 [staIdx].
3876 peerMac.
3877 bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003878 wlan_hdd_tdls_reset_peer(pAdapter,
3879 pHddCtx->
3880 tdlsConnInfo
3881 [staIdx].
3882 peerMac.bytes);
3883 hdd_roam_deregister_tdlssta(pAdapter,
3884 pHddCtx->
3885 tdlsConnInfo
3886 [staIdx].
3887 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303888 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003889 sizeof
3890 (smeTdlsPeerStateParams));
3891 smeTdlsPeerStateParams.vdevId =
3892 pHddCtx->tdlsConnInfo[staIdx].
3893 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303894 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003895 peerMacAddr,
3896 &pHddCtx->
3897 tdlsConnInfo[staIdx].
3898 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303899 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003900 smeTdlsPeerStateParams.peerState =
3901 eSME_TDLS_PEER_STATE_TEARDOWN;
3902
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003903 hdd_info("calling sme_update_tdls_peer_state for staIdx %d "
3904 MAC_ADDRESS_STR,
3905 pHddCtx->tdlsConnInfo[staIdx].
3906 staId,
3907 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 tdlsConnInfo
3909 [staIdx].
3910 peerMac.
3911 bytes));
3912 status =
3913 sme_update_tdls_peer_state(
3914 pHddCtx->hHal,
3915 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303916 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003917 hdd_err("sme_update_tdls_peer_state failed for "
3918 MAC_ADDRESS_STR,
3919 MAC_ADDR_ARRAY
3920 (pHddCtx->
3921 tdlsConnInfo[staIdx].
3922 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003923 }
3924 wlan_hdd_tdls_decrement_peer_count
3925 (pAdapter);
3926
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303927 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928 tdlsConnInfo[staIdx].
3929 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303930 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003931 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3932 pHddCtx->tdlsConnInfo[staIdx].
3933 sessionId = 255;
3934
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303935 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003936 }
3937 }
3938 break;
3939 }
3940 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3941 {
3942 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07003943 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
3944 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303945 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003946 break;
3947 }
3948
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07003949 if (pHddCtx->tdls_nss_switch_in_progress) {
3950 hdd_err("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
3951 status = QDF_STATUS_SUCCESS;
3952 break;
3953 }
3954
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003955 curr_peer =
3956 wlan_hdd_tdls_get_peer(pAdapter,
Kabilan Kannan36090ce2016-05-03 19:28:44 -07003957 pRoamInfo->peerMac.bytes,
3958 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05303960 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303961 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 } else {
3963 if (eTDLS_LINK_CONNECTED ==
3964 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003965 hdd_err("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003966 } else {
3967 /*
3968 * If external control is enabled then initiate
3969 * TDLS only if forced peer is set otherwise
3970 * ignore should Discover trigger from fw.
3971 */
3972 if (pHddCtx->config->
3973 fTDLSExternalControl
3974 && (false ==
3975 curr_peer->isForcedPeer)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003976 hdd_info("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303977 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003978 break;
3979 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003980 hdd_info("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003981 pHddCtx->config->
3982 fTDLSExternalControl,
3983 curr_peer->isForcedPeer,
3984 pRoamInfo->reasonCode);
3985 }
Nitesh Shah983e8f52016-11-25 12:36:29 +05303986 pHddTdlsCtx->curr_candidate = curr_peer;
3987 wlan_hdd_tdls_implicit_send_discovery_request(
3988 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003989 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303990 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003991 }
3992 break;
3993 }
3994
3995 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
3996 {
3997 curr_peer =
3998 wlan_hdd_tdls_find_peer(pAdapter,
3999 pRoamInfo->peerMac.bytes, true);
4000 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304001 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304002 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004003 } else {
4004 if (eTDLS_LINK_CONNECTED ==
4005 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004006 hdd_err("Received SHOULD_TEARDOWN for peer "
4007 MAC_ADDRESS_STR
4008 " staId: %d, reason: %d",
4009 MAC_ADDR_ARRAY(pRoamInfo->
4010 peerMac.bytes),
4011 pRoamInfo->staId,
4012 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013
4014 if (pRoamInfo->reasonCode ==
4015 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4016 pRoamInfo->reasonCode ==
4017 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4018 pRoamInfo->reasonCode ==
4019 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4020 pRoamInfo->reasonCode ==
4021 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4022 reason =
4023 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4024 } else
4025 reason =
4026 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4027
4028 wlan_hdd_tdls_indicate_teardown
4029 (pHddTdlsCtx->pAdapter, curr_peer,
4030 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304031 hdd_send_wlan_tdls_teardown_event(
4032 eTDLS_TEARDOWN_BSS_DISCONNECT,
4033 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004035 hdd_err("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
4036 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004037 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304038 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004039 }
4040 break;
4041 }
4042
4043 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4044 {
4045 curr_peer =
4046 wlan_hdd_tdls_find_peer(pAdapter,
4047 pRoamInfo->peerMac.bytes, true);
4048 if (!curr_peer) {
Nitesh Shahfacafba2016-11-23 12:16:22 +05304049 hdd_info("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304050 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004051 } else {
4052 if (eTDLS_LINK_CONNECTED ==
4053 curr_peer->link_status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004054 hdd_err("Received SHOULD_PEER_DISCONNECTED for peer "
4055 MAC_ADDRESS_STR
4056 " staId: %d, reason: %d",
4057 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4058 pRoamInfo->staId,
4059 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060
4061 if (pRoamInfo->reasonCode ==
4062 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4063 pRoamInfo->reasonCode ==
4064 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4065 pRoamInfo->reasonCode ==
4066 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4067 pRoamInfo->reasonCode ==
4068 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4069 reason =
4070 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4071 } else
4072 reason =
4073 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4074
4075 wlan_hdd_tdls_indicate_teardown
4076 (pHddTdlsCtx->pAdapter, curr_peer,
4077 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304078 hdd_send_wlan_tdls_teardown_event(
4079 eTDLS_TEARDOWN_BSS_DISCONNECT,
4080 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004082 hdd_err("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
4083 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004084 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304085 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 }
4087 break;
4088 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004089
4090 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
4091 status = hdd_tdls_connection_tracker_update(pAdapter,
4092 pRoamInfo,
4093 pHddTdlsCtx);
4094 break;
4095
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004096 default:
4097 {
4098 break;
4099 }
4100 }
4101
4102 return status;
4103}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004104#else
4105
4106static inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
4107 uint8_t staId)
4108{
4109 return QDF_STATUS_SUCCESS;
4110}
4111
4112static inline QDF_STATUS
4113hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4114 tCsrRoamInfo *pRoamInfo,
4115 uint32_t roamId,
4116 eRoamCmdStatus roamStatus,
4117 eCsrRoamResult roamResult)
4118{
4119 return QDF_STATUS_SUCCESS;
4120}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121#endif
4122
4123#ifdef WLAN_FEATURE_11W
4124/**
4125 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4126 * @pAdapter: pointer to the adapter
4127 * @nFrameLength: Length of the unprotected frame being passed
4128 * @pbFrames: Pointer to the frame buffer
4129 * @frameType: 802.11 frame type
4130 *
4131 * This function forwards the unprotected management frame to the supplicant.
4132 *
4133 * Return: nothing
4134 */
4135static void
4136hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4137 uint8_t *pbFrames, uint8_t frameType)
4138{
4139 uint8_t type = 0;
4140 uint8_t subType = 0;
4141
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004142 hdd_info("Frame Type = %d Frame Length = %d",
4143 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144
4145 /* Sanity Checks */
4146 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004147 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004148 return;
4149 }
4150
4151 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004152 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004153 return;
4154 }
4155
4156 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004157 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 return;
4159 }
4160
4161 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004162 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 return;
4164 }
4165
4166 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004167 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004168 return;
4169 }
4170
4171 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4172 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4173
4174 /* Get pAdapter from Destination mac address of the frame */
4175 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4176#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4177 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4178 nFrameLength);
4179#else
4180 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4181 nFrameLength);
4182#endif
4183 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4184 } else if (type == SIR_MAC_MGMT_FRAME &&
4185 subType == SIR_MAC_MGMT_DEAUTH) {
4186#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4187 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4188 nFrameLength);
4189#else
4190 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4191 nFrameLength);
4192#endif
4193 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4194 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004195 hdd_err("Frame type %d and subtype %d are not valid",
4196 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 return;
4198 }
4199}
4200#endif
4201
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004202#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203/**
4204 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4205 * @pAdapter: pointer to adapter
4206 * @tid: traffic identifier
4207 * @state: state
4208 * @measInterval: measurement interval
4209 *
4210 * This function sends traffic stream metrics IE information to
4211 * the supplicant via wireless event.
4212 *
4213 * Return: none
4214 */
4215static void
4216hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4217 uint8_t state, uint16_t measInterval)
4218{
4219 union iwreq_data wrqu;
4220 char buf[IW_CUSTOM_MAX + 1];
4221 int nBytes = 0;
4222
4223 if (NULL == pAdapter)
4224 return;
4225
4226 /* create the event */
4227 memset(&wrqu, '\0', sizeof(wrqu));
4228 memset(buf, '\0', sizeof(buf));
4229
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004230 hdd_info("TSM Ind tid(%d) state(%d) MeasInt(%d)",
4231 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232
4233 nBytes =
4234 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4235 measInterval);
4236
4237 wrqu.data.pointer = buf;
4238 wrqu.data.length = nBytes;
4239 /* send the event */
4240 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4241}
4242
4243/**
4244 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4245 * @pAdapter: pointer to adapter
4246 * @pRoamInfo: pointer to roam info
4247 *
4248 * This function sends cckm preauth indication to the supplicant
4249 * via wireless custom event.
4250 *
4251 * Return: none
4252 */
4253static void
4254hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4255{
4256 union iwreq_data wrqu;
4257 char buf[IW_CUSTOM_MAX + 1];
4258 char *pos = buf;
4259 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4260
4261 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4262 return;
4263
4264 /* create the event */
4265 memset(&wrqu, '\0', sizeof(wrqu));
4266 memset(buf, '\0', sizeof(buf));
4267
4268 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004269 hdd_info("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
4270 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4271 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004272
4273 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4274 pos += nBytes;
4275 freeBytes -= nBytes;
4276
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304277 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304278 pos += QDF_MAC_ADDR_SIZE;
4279 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004280
4281 nBytes = snprintf(pos, freeBytes, " %u:%u",
4282 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4283 freeBytes -= nBytes;
4284
4285 wrqu.data.pointer = buf;
4286 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4287
4288 /* send the event */
4289 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4290}
4291
4292/**
4293 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4294 * @pAdapter: pointer to adapter
4295 * @pRoamInfo: pointer to roam info
4296 *
4297 * Return: none
4298 */
4299static void
4300hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4301 tCsrRoamInfo *pRoamInfo)
4302{
4303 union iwreq_data wrqu;
4304 char buf[IW_CUSTOM_MAX + 1];
4305 int nBytes = 0;
4306
4307 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4308 return;
4309
4310 /* create the event */
4311 memset(&wrqu, '\0', sizeof(wrqu));
4312 memset(buf, '\0', sizeof(buf));
4313
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004314 hdd_info("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004315
4316 nBytes =
4317 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4318 pRoamInfo->tsmRoamDelay);
4319
4320 wrqu.data.pointer = buf;
4321 wrqu.data.length = nBytes;
4322
4323 /* send the event */
4324 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4325}
4326
4327/**
4328 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4329 * @pAdapter: pointer to adapter
4330 * @measurementToken: measurement token
4331 * @flag: flag
4332 * @numBss: number of bss
4333 *
4334 * If the measurement is none and no scan results found,
4335 * indicate the supplicant about measurement done.
4336 *
4337 * Return: none
4338 */
4339void
4340hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4341 const uint16_t measurementToken,
4342 const bool flag, const uint8_t numBss)
4343{
4344 union iwreq_data wrqu;
4345 char buf[IW_CUSTOM_MAX];
4346 char *pos = buf;
4347 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4348
4349 memset(&wrqu, '\0', sizeof(wrqu));
4350 memset(buf, '\0', sizeof(buf));
4351
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004352 hdd_info("CCXBCNREP=%d %d %d", measurementToken,
4353 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004354
4355 nBytes =
4356 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4357 flag, numBss);
4358
4359 wrqu.data.pointer = buf;
4360 wrqu.data.length = nBytes;
4361 /* send the event */
4362 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4363}
4364
4365/**
4366 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4367 * @pAdapter: pointer to adapter
4368 * @pRoamInfo: pointer to roam info
4369 *
4370 * If the measurement is none and no scan results found,
4371 * indicate the supplicant about measurement done.
4372 *
4373 * Return: none
4374 */
4375static void
4376hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4377 const tCsrRoamInfo *pRoamInfo)
4378{
4379 union iwreq_data wrqu;
4380 char buf[IW_CUSTOM_MAX];
4381 char *pos = buf;
4382 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4383 uint8_t i = 0, len = 0;
4384 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4385 uint8_t lastSent = 0, sendBss = 0;
4386 int bcnRepFieldSize =
4387 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4388 bcnReportFields);
4389 uint8_t ieLenByte = 1;
4390 /*
4391 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4392 */
4393#define ESEBCNREPHEADER_LEN (18)
4394
4395 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4396 return;
4397
4398 /*
4399 * Custom event can pass maximum of 256 bytes of data,
4400 * based on the IE len we need to identify how many BSS info can
4401 * be filled in to custom event data.
4402 */
4403 /*
4404 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4405 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4406 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4407 */
4408
4409 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4410 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004411 hdd_info("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004412 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004413 * indicate the supplicant about measurement done
4414 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004415 hdd_indicate_ese_bcn_report_no_results(
4416 pAdapter,
4417 pRoamInfo->pEseBcnReportRsp->
4418 measurementToken,
4419 pRoamInfo->pEseBcnReportRsp->flag,
4420 pRoamInfo->pEseBcnReportRsp->numBss);
4421 } else {
4422 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4423 memset(&wrqu, '\0', sizeof(wrqu));
4424 memset(buf, '\0', sizeof(buf));
4425 tot_bcn_ieLen = 0;
4426 sendBss = 0;
4427 pos = buf;
4428 freeBytes = IW_CUSTOM_MAX;
4429
4430 for (i = lastSent;
4431 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4432 len =
4433 bcnRepFieldSize + ieLenByte +
4434 pRoamInfo->pEseBcnReportRsp->
4435 bcnRepBssInfo[i].ieLen;
4436 if ((len + tot_bcn_ieLen) >
4437 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4438 break;
4439 }
4440 tot_bcn_ieLen += len;
4441 sendBss++;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004442 hdd_info("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
4443 i, bcnRepFieldSize, 1,
4444 pRoamInfo->pEseBcnReportRsp->
4445 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004446 }
4447
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004448 hdd_info("Sending %d BSS Info", sendBss);
4449 hdd_info("CCXBCNREP=%d %d %d %d",
4450 pRoamInfo->pEseBcnReportRsp->measurementToken,
4451 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4452 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004453
4454 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4455 pRoamInfo->pEseBcnReportRsp->
4456 measurementToken,
4457 pRoamInfo->pEseBcnReportRsp->flag,
4458 sendBss);
4459 pos += nBytes;
4460 freeBytes -= nBytes;
4461
4462 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304463 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004464 sizeof(tot_bcn_ieLen));
4465 pos += sizeof(tot_bcn_ieLen);
4466 freeBytes -= sizeof(tot_bcn_ieLen);
4467
4468 for (i = 0; i < sendBss; i++) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004469 hdd_info("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004470 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4471 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4472 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4473 pRoamInfo->pEseBcnReportRsp->
4474 bcnRepBssInfo[i +
4475 lastSent].bcnReportFields.
4476 ChanNum,
4477 pRoamInfo->pEseBcnReportRsp->
4478 bcnRepBssInfo[i +
4479 lastSent].bcnReportFields.
4480 Spare,
4481 pRoamInfo->pEseBcnReportRsp->
4482 bcnRepBssInfo[i +
4483 lastSent].bcnReportFields.
4484 MeasDuration,
4485 pRoamInfo->pEseBcnReportRsp->
4486 bcnRepBssInfo[i +
4487 lastSent].bcnReportFields.
4488 PhyType,
4489 pRoamInfo->pEseBcnReportRsp->
4490 bcnRepBssInfo[i +
4491 lastSent].bcnReportFields.
4492 RecvSigPower,
4493 pRoamInfo->pEseBcnReportRsp->
4494 bcnRepBssInfo[i +
4495 lastSent].bcnReportFields.
4496 ParentTsf,
4497 pRoamInfo->pEseBcnReportRsp->
4498 bcnRepBssInfo[i +
4499 lastSent].bcnReportFields.
4500 TargetTsf[0],
4501 pRoamInfo->pEseBcnReportRsp->
4502 bcnRepBssInfo[i +
4503 lastSent].bcnReportFields.
4504 TargetTsf[1],
4505 pRoamInfo->pEseBcnReportRsp->
4506 bcnRepBssInfo[i +
4507 lastSent].bcnReportFields.
4508 BcnInterval,
4509 pRoamInfo->pEseBcnReportRsp->
4510 bcnRepBssInfo[i +
4511 lastSent].bcnReportFields.
4512 CapabilityInfo,
4513 pRoamInfo->pEseBcnReportRsp->
4514 bcnRepBssInfo[i +
4515 lastSent].bcnReportFields.
4516 Bssid[0],
4517 pRoamInfo->pEseBcnReportRsp->
4518 bcnRepBssInfo[i +
4519 lastSent].bcnReportFields.
4520 Bssid[1],
4521 pRoamInfo->pEseBcnReportRsp->
4522 bcnRepBssInfo[i +
4523 lastSent].bcnReportFields.
4524 Bssid[2],
4525 pRoamInfo->pEseBcnReportRsp->
4526 bcnRepBssInfo[i +
4527 lastSent].bcnReportFields.
4528 Bssid[3],
4529 pRoamInfo->pEseBcnReportRsp->
4530 bcnRepBssInfo[i +
4531 lastSent].bcnReportFields.
4532 Bssid[4],
4533 pRoamInfo->pEseBcnReportRsp->
4534 bcnRepBssInfo[i +
4535 lastSent].bcnReportFields.
4536 Bssid[5]);
4537
4538 /* bcn report fields are copied */
4539 len =
4540 sizeof(pRoamInfo->pEseBcnReportRsp->
4541 bcnRepBssInfo[i +
4542 lastSent].
4543 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304544 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004545 (char *)&pRoamInfo->
4546 pEseBcnReportRsp->bcnRepBssInfo[i +
4547 lastSent].
4548 bcnReportFields, len);
4549 pos += len;
4550 freeBytes -= len;
4551
4552 /* Add 1 byte of ie len */
4553 len =
4554 pRoamInfo->pEseBcnReportRsp->
4555 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304556 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004557 pos += sizeof(len);
4558 freeBytes -= sizeof(len);
4559
4560 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304561 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004562 (char *)pRoamInfo->
4563 pEseBcnReportRsp->bcnRepBssInfo[i +
4564 lastSent].
4565 pBuf, len);
4566 pos += len;
4567 freeBytes -= len;
4568 }
4569
4570 wrqu.data.pointer = buf;
4571 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4572
4573 /* send the event */
4574 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4575 buf);
4576 lastSent += sendBss;
4577 }
4578 }
4579}
4580
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004581#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004582
4583/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304584 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4585 * @pHddStaCtx: Station Context
4586 *
4587 * API to check if the connection authentication type is 8021x_sha256.
4588 *
4589 * Return: bool
4590 */
4591#ifdef WLAN_FEATURE_11W
4592static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4593{
4594 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4595 pHddStaCtx->conn_info.authType;
4596}
4597#else
4598static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4599{
4600 return false;
4601}
4602#endif
4603
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304604/*
4605 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4606 * @adapter: Pointer to adapter context
4607 * @roam_info: Pointer to roam info
4608 *
4609 * Return: None
4610 */
4611static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4612 tCsrRoamInfo *roam_info)
4613{
4614 struct hdd_chan_change_params chan_change;
4615 struct cfg80211_bss *bss;
4616 struct net_device *dev = adapter->dev;
4617 struct wireless_dev *wdev = dev->ieee80211_ptr;
4618 struct wiphy *wiphy = wdev->wiphy;
4619 QDF_STATUS status;
4620
4621 hdd_info("channel switch for session:%d to channel:%d",
4622 adapter->sessionId, roam_info->chan_info.chan_id);
4623
4624 chan_change.chan = roam_info->chan_info.chan_id;
4625 chan_change.chan_params.ch_width =
4626 roam_info->chan_info.ch_width;
4627 chan_change.chan_params.sec_ch_offset =
4628 roam_info->chan_info.sec_ch_offset;
4629 chan_change.chan_params.center_freq_seg0 =
4630 roam_info->chan_info.band_center_freq1;
4631 chan_change.chan_params.center_freq_seg1 =
4632 roam_info->chan_info.band_center_freq2;
4633
4634 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4635 if (NULL == bss)
4636 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4637 else
4638 cfg80211_put_bss(wiphy, bss);
4639
4640 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change);
4641 if (QDF_IS_STATUS_ERROR(status))
4642 hdd_err("channel change notification failed");
4643
4644 status = cds_set_hw_mode_on_channel_switch(adapter->sessionId);
4645 if (QDF_IS_STATUS_ERROR(status))
4646 hdd_info("set hw mode change not done");
4647}
4648
Komal Seelam98760ba2015-12-15 11:05:18 +05304649/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004650 * hdd_sme_roam_callback() - hdd sme roam callback
4651 * @pContext: pointer to adapter context
4652 * @pRoamInfo: pointer to roam info
4653 * @roamId: roam id
4654 * @roamStatus: roam status
4655 * @roamResult: roam result
4656 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304657 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004658 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304659QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004660hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4661 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4662{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304663 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004664 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4665 hdd_wext_state_t *pWextState = NULL;
4666 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304667 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004668 hdd_context_t *pHddCtx = NULL;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304669 struct cfg80211_bss *bss_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004670
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004671 hdd_info("CSR Callback: status= %d result= %d roamID=%d",
4672 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004673
4674 /* Sanity check */
4675 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004676 hdd_alert("invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304677 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004678 }
4679
4680 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4681 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4682
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05304683 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304684 pAdapter->sessionId, roamStatus));
4685
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 switch (roamStatus) {
4687 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304688 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4689 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004690 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004691 break;
4692
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693 /*
4694 * We did pre-auth,then we attempted a 11r or ese reassoc.
4695 * reassoc failed due to failure, timeout, reject from ap
4696 * in any case tell the OS, our carrier is off and mark
4697 * interface down.
4698 */
4699 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004700 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4701 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304702 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004703 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4704 roamStatus, roamResult);
4705 /*
4706 * Check if Mcast/Bcast Filters are set, if yes
4707 * clear the filters here.
4708 */
4709 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set ==
4710 true) {
4711 (WLAN_HDD_GET_CTX(pAdapter))->
4712 hdd_mcastbcast_filter_set = false;
4713 }
4714 pHddStaCtx->ft_carrier_on = false;
4715 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004716 hdd_info("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
4717 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004718 break;
4719
4720 case eCSR_ROAM_FT_START:
4721 /*
4722 * When we roam for ESE and 11r, we dont want the OS to be
4723 * informed that the link is down. So mark the link ready for
4724 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4725 * be received. Where in we will not mark the link down
4726 * Also we want to stop tx at this point when we will be
4727 * doing disassoc at this time. This saves 30-60 msec
4728 * after reassoc.
4729 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004730 hdd_info("Disabling queues");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004731 hdd_info("Roam Synch Ind: NAPI Serialize ON");
4732 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004733 wlan_hdd_netif_queue_control(pAdapter,
4734 WLAN_NETIF_TX_DISABLE,
4735 WLAN_CONTROL_PATH);
4736 status = hdd_roam_deregister_sta(pAdapter,
4737 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304738 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304739 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004740 pHddStaCtx->ft_carrier_on = true;
4741 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004742 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4743 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004744 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004745 case eCSR_ROAM_NAPI_OFF:
4746 hdd_info("After Roam Synch Comp: NAPI Serialize OFF");
4747 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004748 hdd_set_roaming_in_progress(false);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004749 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004750 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004751 /* notify apps that we can't pass traffic anymore */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004752 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004753 wlan_hdd_netif_queue_control(pAdapter,
4754 WLAN_NETIF_TX_DISABLE,
4755 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004756 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004757 wlan_hdd_netif_queue_control(pAdapter,
4758 WLAN_NETIF_CARRIER_OFF,
4759 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004760 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004761 break;
4762 case eCSR_ROAM_LOSTLINK:
4763 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004764 hdd_info("Roaming started due to connection lost");
4765 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766 wlan_hdd_netif_queue_control(pAdapter,
4767 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4768 WLAN_CONTROL_PATH);
4769 break;
4770 }
4771 case eCSR_ROAM_DISASSOCIATED:
4772 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004773 hdd_info("****eCSR_ROAM_DISASSOCIATED****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304774 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004775 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4776 roamStatus, roamResult);
4777 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4778 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4779 if (pHddCtx->hdd_mcastbcast_filter_set == true) {
4780 hdd_conf_mcastbcast_filter(pHddCtx, false);
4781
4782 if (true ==
4783 pHddCtx->sus_res_mcastbcast_filter_valid) {
4784 pHddCtx->configuredMcastBcastFilter =
4785 pHddCtx->sus_res_mcastbcast_filter;
4786 pHddCtx->
4787 sus_res_mcastbcast_filter_valid =
4788 false;
4789 }
4790
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004791 hdd_info("offload: disassociation happening, restoring configuredMcastBcastFilter");
4792 hdd_info("McastBcastFilter = %d",
4793 pHddCtx->configuredMcastBcastFilter);
4794 hdd_info("offload: already called mcastbcast filter");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004795 (WLAN_HDD_GET_CTX(pAdapter))->
4796 hdd_mcastbcast_filter_set = false;
4797 }
4798 /* Call to clear any MC Addr List filter applied after
4799 * successful connection.
4800 */
4801 wlan_hdd_set_mc_addr_list(pAdapter, false);
4802 }
4803 break;
4804 case eCSR_ROAM_IBSS_LEAVE:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004805 hdd_info("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304806 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004807 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4808 roamStatus, roamResult);
4809 break;
4810 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004811 hdd_info("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004812 /*
4813 * To Do - address probable memory leak with WEP encryption upon
4814 * successful association.
4815 */
4816 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4817 /* Clear saved connection information in HDD */
4818 hdd_conn_remove_connect_info(
4819 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4820 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304821 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822 hdd_association_completion_handler(pAdapter, pRoamInfo,
4823 roamId, roamStatus,
4824 roamResult);
4825#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4826 if (pRoamInfo)
4827 pRoamInfo->roamSynchInProgress = false;
4828#endif
4829 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07004830 case eCSR_ROAM_CANCELLED:
4831 hdd_info("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004832 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304833 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004834 pRoamInfo,
4835 roamId,
4836 roamStatus,
4837 roamResult);
4838 break;
4839 case eCSR_ROAM_IBSS_IND:
4840 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4841 roamStatus, roamResult);
4842 break;
4843
4844 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304845 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004846 roam_roam_connect_status_update_handler(pAdapter,
4847 pRoamInfo,
4848 roamId,
4849 roamStatus,
4850 roamResult);
4851 break;
4852
4853 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304854 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004855 hdd_roam_mic_error_indication_handler(pAdapter,
4856 pRoamInfo,
4857 roamId,
4858 roamStatus,
4859 roamResult);
4860 break;
4861
4862 case eCSR_ROAM_SET_KEY_COMPLETE:
4863 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304864 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004865 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4866 roamId, roamStatus,
4867 roamResult);
4868 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4869 pHddStaCtx->hdd_ReassocScenario = false;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004870 hdd_info("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871 pHddStaCtx->hdd_ReassocScenario,
4872 pAdapter->sessionId);
4873 }
4874 }
4875#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4876 if (pRoamInfo != NULL)
4877 pRoamInfo->roamSynchInProgress = false;
4878#endif
4879 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004880
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004881 case eCSR_ROAM_FT_RESPONSE:
4882 hdd_send_ft_event(pAdapter);
4883 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004884
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004885 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304886 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4887 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004888 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304889 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004890 wlan_hdd_cfg80211_pmksa_candidate_notify(
4891 pAdapter, pRoamInfo, 1, false);
4892 }
4893 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004894
4895#ifdef FEATURE_WLAN_LFR_METRICS
4896 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4897 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304898 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4900 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304901 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004902 }
4903 break;
4904 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4905 /*
4906 * This event will notify pre-auth completion in case of success
4907 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304908 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4910 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304911 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004912 }
4913 break;
4914 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4915 /*
4916 * This event will notify pre-auth completion incase of failure.
4917 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304918 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004919 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4920 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304921 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004922 }
4923 break;
4924 case eCSR_ROAM_HANDOVER_SUCCESS:
4925 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08004926 * It will be only invoked on success
4927 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304928 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004929 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4930 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304931 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 }
4933 break;
4934#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004935 case eCSR_ROAM_REMAIN_CHAN_READY:
4936 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4937 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004938#ifdef FEATURE_WLAN_TDLS
4939 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304940 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004941 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4942 roamId,
4943 roamStatus,
4944 roamResult);
4945 break;
4946 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4947 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4948 pRoamInfo->reasonCode);
4949 break;
4950#endif
4951#ifdef WLAN_FEATURE_11W
4952 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4953 hdd_indicate_unprot_mgmt_frame(pAdapter,
4954 pRoamInfo->nFrameLength,
4955 pRoamInfo->pbFrames,
4956 pRoamInfo->frameType);
4957 break;
4958#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004959#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004960 case eCSR_ROAM_TSM_IE_IND:
4961 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4962 pRoamInfo->tsmIe.state,
4963 pRoamInfo->tsmIe.msmt_interval);
4964 break;
4965
4966 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4967 {
4968 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4969 pHddStaCtx->conn_info.authType
4970 || eCSR_AUTH_TYPE_CCKM_RSN ==
4971 pHddStaCtx->conn_info.authType) {
4972 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4973 }
4974 break;
4975 }
4976
4977 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4978 {
4979 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4980 break;
4981 }
4982
4983 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4984 {
4985 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4986 break;
4987 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004988#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304989 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304990 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304991 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304992
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304993 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4994 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
4995 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
4996 pAdapter, pRoamInfo->pBssDesc);
4997 if (NULL == bss_status)
4998 hdd_info("UPDATE_SCAN_RESULT returned NULL");
4999 else
5000 cfg80211_put_bss(
5001#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5002 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5003#endif
5004 bss_status);
5005 }
5006 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005007 case eCSR_ROAM_NDP_STATUS_UPDATE:
5008 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5009 roamResult);
5010 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005011 case eCSR_ROAM_START:
5012 hdd_info("Process ROAM_START from firmware");
5013 wlan_hdd_netif_queue_control(pAdapter,
5014 WLAN_NETIF_TX_DISABLE,
5015 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005016 hdd_napi_serialize(1);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005017 cds_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005018 hdd_set_roaming_in_progress(true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005019 cds_restart_opportunistic_timer(true);
5020 break;
5021 case eCSR_ROAM_ABORT:
5022 hdd_info("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005023 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005024 wlan_hdd_netif_queue_control(pAdapter,
5025 WLAN_WAKE_ALL_NETIF_QUEUE,
5026 WLAN_CONTROL_PATH);
5027 cds_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005028 hdd_set_roaming_in_progress(false);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005029 break;
5030
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005031 default:
5032 break;
5033 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305034 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035}
5036
5037/**
5038 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5039 * @auth_suite: auth suite
5040 *
5041 * Return: eCsrAuthType enumeration
5042 */
5043eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5044{
5045 eCsrAuthType auth_type;
5046 /* is the auth type supported? */
5047 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5048 auth_type = eCSR_AUTH_TYPE_RSN;
5049 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5050 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005051 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005052 /* Check for 11r FT Authentication with PSK */
5053 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5054 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5055 /* Check for 11R FT Authentication with 802.1X */
5056 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5057 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005058#ifdef FEATURE_WLAN_ESE
5059 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5060 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5061 } else
5062#endif /* FEATURE_WLAN_ESE */
5063#ifdef WLAN_FEATURE_11W
5064 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5065 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5066 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5067 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5068 } else
5069#endif
5070 {
5071 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5072 }
5073 return auth_type;
5074}
5075
5076/**
5077 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5078 * @auth_suite: auth suite
5079 *
5080 * Return: eCsrAuthType enumeration
5081 */
5082eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5083{
5084 eCsrAuthType auth_type;
5085 /* is the auth type supported? */
5086 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5087 auth_type = eCSR_AUTH_TYPE_WPA;
5088 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5089 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5090 } else
5091#ifdef FEATURE_WLAN_ESE
5092 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5093 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5094 } else
5095#endif /* FEATURE_WLAN_ESE */
5096 {
5097 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5098 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005099 hdd_info("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005100 return auth_type;
5101}
5102
5103/**
5104 * hdd_translate_rsn_to_csr_encryption_type() -
5105 * Translate RSN to CSR encryption type
5106 * @cipher_suite: cipher suite
5107 *
5108 * Return: eCsrEncryptionType enumeration
5109 */
5110eCsrEncryptionType
5111hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5112{
5113 eCsrEncryptionType cipher_type;
5114
5115 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5116 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5117 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5118 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5119 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5120 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5121 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5122 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5123 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5124 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5125 else
5126 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5127
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005128 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005129 return cipher_type;
5130}
5131
5132/**
5133 * hdd_translate_wpa_to_csr_encryption_type() -
5134 * Translate WPA to CSR encryption type
5135 * @cipher_suite: cipher suite
5136 *
5137 * Return: eCsrEncryptionType enumeration
5138 */
5139eCsrEncryptionType
5140hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5141{
5142 eCsrEncryptionType cipher_type;
5143
5144 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5145 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5146 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5147 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5148 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5149 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5150 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5151 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5152 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5153 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5154 else
5155 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5156
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005157 hdd_info("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005158 return cipher_type;
5159}
5160
5161/**
5162 * hdd_process_genie() - process gen ie
5163 * @pAdapter: pointer to adapter
5164 * @bssid: pointer to mac address
5165 * @pEncryptType: pointer to encryption type
5166 * @mcEncryptType: pointer to multicast encryption type
5167 * @pAuthType: pointer to auth type
5168 *
5169 * Return: 0 on success, error number otherwise
5170 */
5171static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5172 u8 *bssid,
5173 eCsrEncryptionType *pEncryptType,
5174 eCsrEncryptionType *mcEncryptType,
5175 eCsrAuthType *pAuthType,
5176#ifdef WLAN_FEATURE_11W
5177 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5178#endif
5179 uint16_t gen_ie_len, uint8_t *gen_ie)
5180{
5181 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305182 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005183 tDot11fIERSN dot11RSNIE;
5184 tDot11fIEWPA dot11WPAIE;
5185 uint32_t i;
5186 uint8_t *pRsnIe;
5187 uint16_t RSNIeLen;
5188 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5189 bool updatePMKCache = false;
5190
5191 /*
5192 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5193 * setting present flag to 0.
5194 */
5195 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5196 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5197
5198 /* Type check */
5199 if (gen_ie[0] == DOT11F_EID_RSN) {
5200 /* Validity checks */
5201 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5202 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005203 hdd_err("Invalid DOT11F RSN IE length :%d",
5204 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005205 return -EINVAL;
5206 }
5207 /* Skip past the EID byte and length byte */
5208 pRsnIe = gen_ie + 2;
5209 RSNIeLen = gen_ie_len - 2;
5210 /* Unpack the RSN IE */
5211 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
5212 pRsnIe, RSNIeLen, &dot11RSNIE);
5213 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005214 hdd_info("pairwise cipher suite count: %d",
5215 dot11RSNIE.pwise_cipher_suite_count);
5216 hdd_info("authentication suite count: %d",
5217 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005218 /* dot11RSNIE.akm_suite_count */
5219 /* Just translate the FIRST one */
5220 *pAuthType =
5221 hdd_translate_rsn_to_csr_auth_type(
5222 dot11RSNIE.akm_suites[0]);
5223 /* dot11RSNIE.pwise_cipher_suite_count */
5224 *pEncryptType =
5225 hdd_translate_rsn_to_csr_encryption_type(
5226 dot11RSNIE.pwise_cipher_suites[0]);
5227 /* dot11RSNIE.gp_cipher_suite_count */
5228 *mcEncryptType =
5229 hdd_translate_rsn_to_csr_encryption_type(
5230 dot11RSNIE.gp_cipher_suite);
5231#ifdef WLAN_FEATURE_11W
5232 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
5233 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
5234#endif
5235 /* Set the PMKSA ID Cache for this interface */
5236 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5237 if (is_zero_ether_addr(bssid)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005238 hdd_err("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005239 break;
5240 }
5241 updatePMKCache = true;
5242 /*
5243 * For right now, I assume setASSOCIATE() has passed
5244 * in the bssid.
5245 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305246 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305247 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305248 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005249 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5250 }
5251
5252 if (updatePMKCache) {
5253 /*
5254 * Calling csr_roam_set_pmkid_cache to configure the
5255 * PMKIDs into the cache.
5256 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005257 hdd_info("Calling sme_roam_set_pmkid_cache with cache entry %d.",
5258 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005259 /* Finally set the PMKSA ID Cache in CSR */
5260 result =
5261 sme_roam_set_pmkid_cache(halHandle,
5262 pAdapter->sessionId,
5263 PMKIDCache,
5264 dot11RSNIE.pmkid_count,
5265 false);
5266 }
5267 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5268 /* Validity checks */
5269 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5270 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005271 hdd_err("Invalid DOT11F WPA IE length :%d",
5272 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005273 return -EINVAL;
5274 }
5275 /* Skip past the EID and length byte - and four byte WiFi OUI */
5276 pRsnIe = gen_ie + 2 + 4;
5277 RSNIeLen = gen_ie_len - (2 + 4);
5278 /* Unpack the WPA IE */
5279 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
5280 pRsnIe, RSNIeLen, &dot11WPAIE);
5281 /* Copy out the encryption and authentication types */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005282 hdd_info("WPA unicast cipher suite count: %d",
5283 dot11WPAIE.unicast_cipher_count);
5284 hdd_info("WPA authentication suite count: %d",
5285 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005286 /* dot11WPAIE.auth_suite_count */
5287 /* Just translate the FIRST one */
5288 *pAuthType =
5289 hdd_translate_wpa_to_csr_auth_type(
5290 dot11WPAIE.auth_suites[0]);
5291 /* dot11WPAIE.unicast_cipher_count */
5292 *pEncryptType =
5293 hdd_translate_wpa_to_csr_encryption_type(
5294 dot11WPAIE.unicast_ciphers[0]);
5295 /* dot11WPAIE.unicast_cipher_count */
5296 *mcEncryptType =
5297 hdd_translate_wpa_to_csr_encryption_type(
5298 dot11WPAIE.multicast_cipher);
5299 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005300 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005301 return -EINVAL;
5302 }
5303 return 0;
5304}
5305
5306/**
5307 * hdd_set_genie_to_csr() - set genie to csr
5308 * @pAdapter: pointer to adapter
5309 * @RSNAuthType: pointer to auth type
5310 *
5311 * Return: 0 on success, error number otherwise
5312 */
5313int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5314{
5315 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5316 uint32_t status = 0;
5317 eCsrEncryptionType RSNEncryptType;
5318 eCsrEncryptionType mcRSNEncryptType;
5319#ifdef WLAN_FEATURE_11W
5320 uint8_t RSNMfpRequired = 0;
5321 uint8_t RSNMfpCapable = 0;
5322#endif
5323 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5324 /* MAC address of assoc peer */
5325 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305326 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005327 pWextState->roamProfile.BSSIDs.bssid,
5328 sizeof(bssid));
5329 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5330 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5331 /* continue */
5332 } else {
5333 return 0;
5334 }
5335 /* The actual processing may eventually be more extensive than this. */
5336 /* Right now, just consume any PMKIDs that are sent in by the app. */
5337 status = hdd_process_genie(pAdapter, bssid,
5338 &RSNEncryptType,
5339 &mcRSNEncryptType, RSNAuthType,
5340#ifdef WLAN_FEATURE_11W
5341 &RSNMfpRequired, &RSNMfpCapable,
5342#endif
5343 pWextState->WPARSNIE[1] + 2,
5344 pWextState->WPARSNIE);
5345 if (status == 0) {
5346 /*
5347 * Now copy over all the security attributes
5348 * you have parsed out.
5349 */
5350 pWextState->roamProfile.EncryptionType.numEntries = 1;
5351 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5352
5353 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5354 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5355 mcRSNEncryptType;
5356
Krunal Sonibe766b02016-03-10 13:00:44 -08005357 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005358 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
5359 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5360 /*
5361 * For wpa none supplicant sends the WPA IE with unicast
5362 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5363 * multicast cipher as either AES/TKIP based on group
5364 * cipher configuration mentioned in the
5365 * wpa_supplicant.conf.
5366 */
5367
5368 /* Set the unicast cipher same as multicast cipher */
5369 pWextState->roamProfile.EncryptionType.encryptionType[0]
5370 = mcRSNEncryptType;
5371 }
5372#ifdef WLAN_FEATURE_11W
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005373 hdd_info("RSNMfpRequired = %d, RSNMfpCapable = %d",
5374 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005375 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5376 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5377#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005378 hdd_info("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
5379 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005380 }
5381 return 0;
5382}
5383
5384/**
5385 * hdd_set_csr_auth_type() - set csr auth type
5386 * @pAdapter: pointer to adapter
5387 * @RSNAuthType: auth type
5388 *
5389 * Return: 0 on success, error number otherwise
5390 */
5391int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5392{
5393 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5394 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5395 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005396
5397 pRoamProfile->AuthType.numEntries = 1;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005398 hdd_info("pHddStaCtx->conn_info.authType = %d",
5399 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005400
5401 switch (pHddStaCtx->conn_info.authType) {
5402 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5403#ifdef FEATURE_WLAN_ESE
5404 case eCSR_AUTH_TYPE_CCKM_WPA:
5405 case eCSR_AUTH_TYPE_CCKM_RSN:
5406#endif
5407 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5408
5409 pRoamProfile->AuthType.authType[0] =
5410 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5411 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5412
5413#ifdef FEATURE_WLAN_ESE
5414 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5415 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5416 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005417 hdd_info("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005418 pRoamProfile->AuthType.authType[0] =
5419 eCSR_AUTH_TYPE_CCKM_WPA;
5420 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005421 hdd_info("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005422 pRoamProfile->AuthType.authType[0] =
5423 eCSR_AUTH_TYPE_CCKM_WPA;
5424 } else
5425#endif
5426 if ((pWextState->
5427 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5428 == IW_AUTH_KEY_MGMT_802_1X) {
5429 pRoamProfile->AuthType.authType[0] =
5430 eCSR_AUTH_TYPE_WPA;
5431 } else
5432 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5433 == IW_AUTH_KEY_MGMT_PSK) {
5434 pRoamProfile->AuthType.authType[0] =
5435 eCSR_AUTH_TYPE_WPA_PSK;
5436 } else {
5437 pRoamProfile->AuthType.authType[0] =
5438 eCSR_AUTH_TYPE_WPA_NONE;
5439 }
5440 }
5441 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5442#ifdef FEATURE_WLAN_ESE
5443 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5444 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5445 == IW_AUTH_KEY_MGMT_802_1X)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005446 hdd_info("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 pRoamProfile->AuthType.authType[0] =
5448 eCSR_AUTH_TYPE_CCKM_RSN;
5449 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005450 hdd_info("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005451 pRoamProfile->AuthType.authType[0] =
5452 eCSR_AUTH_TYPE_CCKM_RSN;
5453 } else
5454#endif
5455
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005456 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5457 ((pWextState->
5458 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5459 == IW_AUTH_KEY_MGMT_802_1X)) {
5460 pRoamProfile->AuthType.authType[0] =
5461 eCSR_AUTH_TYPE_FT_RSN;
5462 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5463 &&
5464 ((pWextState->
5465 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5466 == IW_AUTH_KEY_MGMT_PSK)) {
5467 pRoamProfile->AuthType.authType[0] =
5468 eCSR_AUTH_TYPE_FT_RSN_PSK;
5469 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005470
5471#ifdef WLAN_FEATURE_11W
5472 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5473 pRoamProfile->AuthType.authType[0] =
5474 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5475 } else if (RSNAuthType ==
5476 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5477 pRoamProfile->AuthType.authType[0] =
5478 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5479 } else
5480#endif
5481
5482 if ((pWextState->
5483 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5484 == IW_AUTH_KEY_MGMT_802_1X) {
5485 pRoamProfile->AuthType.authType[0] =
5486 eCSR_AUTH_TYPE_RSN;
5487 } else
5488 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5489 == IW_AUTH_KEY_MGMT_PSK) {
5490 pRoamProfile->AuthType.authType[0] =
5491 eCSR_AUTH_TYPE_RSN_PSK;
5492 } else {
5493 pRoamProfile->AuthType.authType[0] =
5494 eCSR_AUTH_TYPE_UNKNOWN;
5495 }
5496 }
5497 break;
5498
5499 case eCSR_AUTH_TYPE_SHARED_KEY:
5500
5501 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5502 break;
5503 default:
5504
5505#ifdef FEATURE_WLAN_ESE
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005506 hdd_info("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005507#endif /* FEATURE_WLAN_ESE */
5508 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5509 break;
5510 }
5511
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005512 hdd_info("Set roam Authtype to %d",
5513 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005514
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 return 0;
5516}
5517
5518/**
5519 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5520 * to the CSR roam profile.
5521 *
5522 * @dev: Pointer to the net device.
5523 * @info: Pointer to the iw_request_info.
5524 * @wrqu: Pointer to the iwreq_data.
5525 * @extra: Pointer to the data.
5526 *
5527 * Return: 0 for success, error number on failure
5528 */
5529static int __iw_set_essid(struct net_device *dev,
5530 struct iw_request_info *info,
5531 union iwreq_data *wrqu, char *extra)
5532{
5533 unsigned long rc;
5534 uint32_t status = 0;
5535 hdd_wext_state_t *pWextState;
5536 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5537 hdd_context_t *hdd_ctx;
5538 uint32_t roamId;
5539 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005540 eCsrAuthType RSNAuthType;
5541 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
5542 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5543 int ret;
5544
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005545 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005546
5547 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5548 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305549 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005550 return ret;
5551
Krunal Sonibe766b02016-03-10 13:00:44 -08005552 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005553 pAdapter->device_mode != QDF_IBSS_MODE &&
5554 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005555 hdd_warn("device mode %s(%d) is not allowed",
5556 hdd_device_mode_to_string(pAdapter->device_mode),
5557 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005558 return -EINVAL;
5559 }
5560
5561 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5562
5563 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005564 hdd_info("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005565 return -EBUSY;
5566 }
5567 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5568 return -EINVAL;
5569
5570 pRoamProfile = &pWextState->roamProfile;
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005571 if (hdd_conn_is_connected(pHddStaCtx) ||
5572 (pAdapter->device_mode == QDF_IBSS_MODE)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305573 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005574
5575 /* Need to issue a disconnect to CSR. */
5576 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305577 qdf_status = sme_roam_disconnect(hHal, pAdapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005578 eCSR_DISCONNECT_REASON_UNSPECIFIED);
5579
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305580 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005581 rc = wait_for_completion_timeout(&pAdapter->
5582 disconnect_comp_var,
5583 msecs_to_jiffies
5584 (WLAN_WAIT_TIME_DISCONNECT));
5585 if (!rc)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005586 hdd_err("Disconnect event timed out");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005587 }
5588 }
5589
5590 /*
5591 * when cfg80211 defined, wpa_supplicant wext driver uses
5592 * zero-length, null-string ssid for force disconnection.
5593 * after disconnection (if previously connected) and cleaning ssid,
5594 * driver MUST return success.
5595 */
5596 if (0 == wrqu->essid.length)
5597 return 0;
5598
5599 status = hdd_wmm_get_uapsd_mask(pAdapter,
5600 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305601 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005602 pWextState->roamProfile.uapsd_mask = 0;
5603
5604 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5605
5606 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5607 wrqu->essid.length;
5608
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305609 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005610 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305611 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612 ssId), extra, wrqu->essid.length);
5613 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5614 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5615
5616 /* set gen ie */
5617 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5618
5619 /* set auth */
5620 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5621 }
5622#ifdef FEATURE_WLAN_WAPI
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005623 hdd_notice("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005624 if (pAdapter->wapi_info.nWapiMode) {
5625 switch (pAdapter->wapi_info.wapiAuthMode) {
5626 case WAPI_AUTH_MODE_PSK:
5627 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005628 hdd_notice("WAPI AUTH TYPE: PSK: %d",
5629 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005630 pRoamProfile->AuthType.numEntries = 1;
5631 pRoamProfile->AuthType.authType[0] =
5632 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5633 break;
5634 }
5635 case WAPI_AUTH_MODE_CERT:
5636 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005637 hdd_notice("WAPI AUTH TYPE: CERT: %d",
5638 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005639 pRoamProfile->AuthType.numEntries = 1;
5640 pRoamProfile->AuthType.authType[0] =
5641 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5642 break;
5643 }
5644 } /* End of switch */
5645 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5646 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005647 hdd_notice("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005648 pRoamProfile->EncryptionType.numEntries = 1;
5649 pRoamProfile->EncryptionType.encryptionType[0] =
5650 eCSR_ENCRYPT_TYPE_WPI;
5651 pRoamProfile->mcEncryptionType.numEntries = 1;
5652 pRoamProfile->mcEncryptionType.encryptionType[0] =
5653 eCSR_ENCRYPT_TYPE_WPI;
5654 }
5655 }
5656#endif /* FEATURE_WLAN_WAPI */
5657 /* if previous genIE is not NULL, update AssocIE */
5658 if (0 != pWextState->genIE.length) {
5659 memset(&pWextState->assocAddIE, 0,
5660 sizeof(pWextState->assocAddIE));
5661 memcpy(pWextState->assocAddIE.addIEdata,
5662 pWextState->genIE.addIEdata, pWextState->genIE.length);
5663 pWextState->assocAddIE.length = pWextState->genIE.length;
5664 pWextState->roamProfile.pAddIEAssoc =
5665 pWextState->assocAddIE.addIEdata;
5666 pWextState->roamProfile.nAddIEAssocLength =
5667 pWextState->assocAddIE.length;
5668
5669 /* clear previous genIE after use it */
5670 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5671 }
5672
5673 /*
5674 * Assumes it is not WPS Association by default, except when
5675 * pAddIEAssoc has WPS IE.
5676 */
5677 pWextState->roamProfile.bWPSAssociation = false;
5678
5679 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5680 pWextState->roamProfile.
5681 nAddIEAssocLength))
5682 pWextState->roamProfile.bWPSAssociation = true;
5683
5684 /* Disable auto BMPS entry by PMC until DHCP is done */
5685 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5686 true);
5687
5688 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5689
5690 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005691 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005693 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5694 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005695 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005696
Agrawal Ashish6b015762016-05-05 11:22:18 +05305697 /*
5698 * Change conn_state to connecting before sme_roam_connect(),
5699 * because sme_roam_connect() has a direct path to call
5700 * hdd_sme_roam_callback(), which will change the conn_state
5701 * If direct path, conn_state will be accordingly changed to
5702 * NotConnected or Associated by either
5703 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5704 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5705 * Connecting state will remain until it is completed.
5706 *
5707 * If connection state is not changed,
5708 * connection state will remain in eConnectionState_NotConnected state.
5709 * In hdd_association_completion_handler, "hddDisconInProgress" is
5710 * set to true if conn state is eConnectionState_NotConnected.
5711 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5712 * informed of connect result indication which is an issue.
5713 */
5714 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305715 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305716 hdd_conn_set_connection_state(pAdapter,
5717 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305718
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005719 status = sme_roam_connect(hHal, pAdapter->sessionId,
5720 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305721 if ((QDF_STATUS_SUCCESS != status) &&
5722 (QDF_STA_MODE == pAdapter->device_mode ||
5723 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5724 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5725 pAdapter->sessionId, status);
5726 /* change back to NotAssociated */
5727 hdd_conn_set_connection_state(pAdapter,
5728 eConnectionState_NotConnected);
5729 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005730 pRoamProfile->ChannelInfo.ChannelList = NULL;
5731 pRoamProfile->ChannelInfo.numOfChannels = 0;
5732
5733 EXIT();
5734 return status;
5735}
5736
5737/**
5738 * iw_set_essid() - set essid handler function
5739 * @dev: Pointer to the net device.
5740 * @info: Pointer to the iw_request_info.
5741 * @wrqu: Pointer to the iwreq_data.
5742 * @extra: Pointer to the data.
5743 *
5744 * Return: 0 for success, error number on failure
5745 */
5746int iw_set_essid(struct net_device *dev,
5747 struct iw_request_info *info,
5748 union iwreq_data *wrqu, char *extra)
5749{
5750 int ret;
5751
5752 cds_ssr_protect(__func__);
5753 ret = __iw_set_essid(dev, info, wrqu, extra);
5754 cds_ssr_unprotect(__func__);
5755
5756 return ret;
5757}
5758
5759/**
5760 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5761 * @dev: pointer to the net device
5762 * @info: pointer to the iw request info
5763 * @dwrq: pointer to iw_point
5764 * @extra: pointer to the data
5765 *
5766 * Return: 0 on success, error number otherwise
5767 */
5768static int __iw_get_essid(struct net_device *dev,
5769 struct iw_request_info *info,
5770 struct iw_point *dwrq, char *extra)
5771{
5772 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5773 hdd_context_t *hdd_ctx;
5774 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5775 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5776 int ret;
5777
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005778 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005779
5780 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5781 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305782 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005783 return ret;
5784
5785 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5786 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5787 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5788 || pHddStaCtx->conn_info.connState ==
5789 eConnectionState_IbssDisconnected)
5790 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5791 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5792 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5793 dwrq->length);
5794 dwrq->flags = 1;
5795 } else {
5796 memset(extra, 0, dwrq->length);
5797 dwrq->length = 0;
5798 dwrq->flags = 0;
5799 }
5800 EXIT();
5801 return 0;
5802}
5803
5804/**
5805 * iw_get_essid() - get essid handler function
5806 * @dev: Pointer to the net device.
5807 * @info: Pointer to the iw_request_info.
5808 * @wrqu: Pointer to the iwreq_data.
5809 * @extra: Pointer to the data.
5810 *
5811 * Return: 0 for success, error number on failure
5812 */
5813int iw_get_essid(struct net_device *dev,
5814 struct iw_request_info *info,
5815 struct iw_point *wrqu, char *extra)
5816{
5817 int ret;
5818
5819 cds_ssr_protect(__func__);
5820 ret = __iw_get_essid(dev, info, wrqu, extra);
5821 cds_ssr_unprotect(__func__);
5822
5823 return ret;
5824}
5825
5826/**
5827 * __iw_set_auth() -
5828 * This function sets the auth type received from the wpa_supplicant
5829 * @dev: pointer to the net device
5830 * @info: pointer to the iw request info
5831 * @wrqu: pointer to iwreq_data
5832 * @extra: pointer to the data
5833 *
5834 * Return: 0 on success, error number otherwise
5835 */
5836static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5837 union iwreq_data *wrqu, char *extra)
5838{
5839 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5840 hdd_context_t *hdd_ctx;
5841 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5842 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5843 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5844 eCsrEncryptionType mcEncryptionType;
5845 eCsrEncryptionType ucEncryptionType;
5846 int ret;
5847
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005848 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005849
5850 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5851 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305852 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005853 return ret;
5854
5855 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5856 case IW_AUTH_WPA_VERSION:
5857 pWextState->wpaVersion = wrqu->param.value;
5858 break;
5859
5860 case IW_AUTH_CIPHER_PAIRWISE:
5861 {
5862 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5863 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5864 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5865 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5866 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5867 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5868 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5869 if ((IW_AUTH_KEY_MGMT_802_1X
5870 ==
5871 (pWextState->
5872 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5873 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5874 pHddStaCtx->conn_info.authType))
5875 /*Dynamic WEP key */
5876 ucEncryptionType =
5877 eCSR_ENCRYPT_TYPE_WEP40;
5878 else
5879 /*Static WEP key */
5880 ucEncryptionType =
5881 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5882 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5883 if ((IW_AUTH_KEY_MGMT_802_1X
5884 ==
5885 (pWextState->
5886 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5887 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5888 pHddStaCtx->conn_info.authType))
5889 /*Dynamic WEP key */
5890 ucEncryptionType =
5891 eCSR_ENCRYPT_TYPE_WEP104;
5892 else
5893 /*Static WEP key */
5894 ucEncryptionType =
5895 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5896 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005897 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
5898 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005899 return -EINVAL;
5900 }
5901
5902 pRoamProfile->EncryptionType.numEntries = 1;
5903 pRoamProfile->EncryptionType.encryptionType[0] =
5904 ucEncryptionType;
5905 }
5906 break;
5907 case IW_AUTH_CIPHER_GROUP:
5908 {
5909 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5910 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5911 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5912 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5913 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5914 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5915 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5916 if ((IW_AUTH_KEY_MGMT_802_1X
5917 ==
5918 (pWextState->
5919 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5920 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5921 pHddStaCtx->conn_info.authType))
5922 mcEncryptionType =
5923 eCSR_ENCRYPT_TYPE_WEP40;
5924 else
5925 mcEncryptionType =
5926 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5927 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5928 /* Dynamic WEP keys won't work with shared keys */
5929 if ((IW_AUTH_KEY_MGMT_802_1X
5930 ==
5931 (pWextState->
5932 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5933 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5934 pHddStaCtx->conn_info.authType)) {
5935 mcEncryptionType =
5936 eCSR_ENCRYPT_TYPE_WEP104;
5937 } else {
5938 mcEncryptionType =
5939 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5940 }
5941 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005942 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005943 wrqu->param.value);
5944 return -EINVAL;
5945 }
5946
5947 pRoamProfile->mcEncryptionType.numEntries = 1;
5948 pRoamProfile->mcEncryptionType.encryptionType[0] =
5949 mcEncryptionType;
5950 }
5951 break;
5952
5953 case IW_AUTH_80211_AUTH_ALG:
5954 {
Jeff Johnson5a062372017-01-12 09:51:25 -08005955 /* Save the auth algo here and set auth type to SME
5956 * Roam profile in the iw_set_ap_address
5957 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005958 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5959 pHddStaCtx->conn_info.authType =
5960 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5961
5962 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5963 pHddStaCtx->conn_info.authType =
5964 eCSR_AUTH_TYPE_SHARED_KEY;
5965
5966 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5967 /*Not supported */
5968 pHddStaCtx->conn_info.authType =
5969 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5970 pWextState->roamProfile.AuthType.authType[0] =
5971 pHddStaCtx->conn_info.authType;
5972 }
5973 break;
5974
5975 case IW_AUTH_KEY_MGMT:
5976 {
5977#ifdef FEATURE_WLAN_ESE
5978#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5979 /*Check for CCKM AKM type */
5980 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005981 hdd_info("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005982 /* Set the CCKM bit in authKeyMgmt */
5983 /*
5984 * Right now, this breaks all ref to authKeyMgmt because
5985 * our code doesn't realize it is a "bitfield"
5986 */
5987 pWextState->authKeyMgmt |=
5988 IW_AUTH_KEY_MGMT_CCKM;
5989 /* Set the key management to 802.1X */
5990 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5991 pWextState->isESEConnection = true;
5992 /*
5993 * This is test code. I need to actually KNOW whether
5994 * this is an RSN Assoc or WPA.
5995 */
5996 pWextState->collectedAuthType =
5997 eCSR_AUTH_TYPE_CCKM_RSN;
5998 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5999 /* Save the key management */
6000 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
6001 pWextState->collectedAuthType =
6002 eCSR_AUTH_TYPE_RSN;
6003 } else
6004 if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
6005 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE;
6006 /* Save the key management anyway */
6007 pWextState->authKeyMgmt = wrqu->param.value;
6008 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6009 /* Save the key management */
6010 pWextState->authKeyMgmt |=
6011 IW_AUTH_KEY_MGMT_802_1X;
6012 pWextState->collectedAuthType =
6013 eCSR_AUTH_TYPE_RSN;
6014 }
6015#else
6016 /* Save the key management */
6017 pWextState->authKeyMgmt = wrqu->param.value;
6018#endif /* FEATURE_WLAN_ESE */
6019 }
6020 break;
6021
6022 case IW_AUTH_TKIP_COUNTERMEASURES:
6023 {
6024 if (wrqu->param.value) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006025 hdd_info("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006026 wrqu->param.value);
6027 pWextState->mTKIPCounterMeasures =
6028 TKIP_COUNTER_MEASURE_STARTED;
6029 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006030 hdd_info("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006031 wrqu->param.value);
6032 pWextState->mTKIPCounterMeasures =
6033 TKIP_COUNTER_MEASURE_STOPED;
6034 }
6035 }
6036 break;
6037 case IW_AUTH_DROP_UNENCRYPTED:
6038 case IW_AUTH_WPA_ENABLED:
6039 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6040 case IW_AUTH_ROAMING_CONTROL:
6041 case IW_AUTH_PRIVACY_INVOKED:
6042
6043 default:
6044
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006045 hdd_warn("called with unsupported auth type %d",
6046 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006047 break;
6048 }
6049
6050 EXIT();
6051 return 0;
6052}
6053
6054/**
6055 * iw_set_auth() - set auth callback function
6056 * @dev: Pointer to the net device.
6057 * @info: Pointer to the iw_request_info.
6058 * @wrqu: Pointer to the iwreq_data.
6059 * @extra: Pointer to the data.
6060 *
6061 * Return: 0 for success, error number on failure.
6062 */
6063int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6064 union iwreq_data *wrqu, char *extra)
6065{
6066 int ret;
6067
6068 cds_ssr_protect(__func__);
6069 ret = __iw_set_auth(dev, info, wrqu, extra);
6070 cds_ssr_unprotect(__func__);
6071
6072 return ret;
6073}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006074/**
6075 * __iw_get_auth() -
6076 * This function returns the auth type to the wpa_supplicant
6077 * @dev: pointer to the net device
6078 * @info: pointer to the iw request info
6079 * @wrqu: pointer to iwreq_data
6080 * @extra: pointer to the data
6081 *
6082 * Return: 0 on success, error number otherwise
6083 */
6084static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6085 union iwreq_data *wrqu, char *extra)
6086{
6087 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6088 hdd_context_t *hdd_ctx;
6089 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6090 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6091 int ret;
6092
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006093 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006094
6095 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6096 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306097 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006098 return ret;
6099
6100 switch (pRoamProfile->negotiatedAuthType) {
6101 case eCSR_AUTH_TYPE_WPA_NONE:
6102 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6103 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6104 break;
6105 case eCSR_AUTH_TYPE_WPA:
6106 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6107 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6108 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006109
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006110 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006111 case eCSR_AUTH_TYPE_RSN:
6112 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6113 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6114 break;
6115 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6116 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6117 break;
6118 case eCSR_AUTH_TYPE_SHARED_KEY:
6119 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6120 break;
6121 case eCSR_AUTH_TYPE_UNKNOWN:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006122 hdd_info("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006123 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6124 break;
6125 case eCSR_AUTH_TYPE_AUTOSWITCH:
6126 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6127 break;
6128 case eCSR_AUTH_TYPE_WPA_PSK:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006129 hdd_info("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006130 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6131 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006132
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006133 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006134 case eCSR_AUTH_TYPE_RSN_PSK:
6135#ifdef WLAN_FEATURE_11W
6136 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6137 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6138#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006139 hdd_info("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006140 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6141 return -EIO;
6142 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006143 hdd_err("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006144 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6145 return -EIO;
6146 }
6147 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6148 switch (pRoamProfile->negotiatedUCEncryptionType) {
6149 case eCSR_ENCRYPT_TYPE_NONE:
6150 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6151 break;
6152 case eCSR_ENCRYPT_TYPE_WEP40:
6153 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6154 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6155 break;
6156 case eCSR_ENCRYPT_TYPE_TKIP:
6157 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6158 break;
6159 case eCSR_ENCRYPT_TYPE_WEP104:
6160 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6161 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6162 break;
6163 case eCSR_ENCRYPT_TYPE_AES:
6164 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6165 break;
6166 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006167 hdd_notice("called with unknown auth type %d",
6168 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006169 return -EIO;
6170 }
6171 }
6172
6173 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6174 switch (pRoamProfile->negotiatedMCEncryptionType) {
6175 case eCSR_ENCRYPT_TYPE_NONE:
6176 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6177 break;
6178 case eCSR_ENCRYPT_TYPE_WEP40:
6179 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6180 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6181 break;
6182 case eCSR_ENCRYPT_TYPE_TKIP:
6183 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6184 break;
6185 case eCSR_ENCRYPT_TYPE_WEP104:
6186 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6187 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6188 break;
6189 case eCSR_ENCRYPT_TYPE_AES:
6190 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6191 break;
6192 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006193 hdd_info("called with unknown auth type %d",
6194 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006195 return -EIO;
6196 }
6197 }
6198
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006199 hdd_info("called with auth type %d",
6200 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006201 EXIT();
6202 return 0;
6203}
6204
6205/**
6206 * iw_get_auth() - get auth callback function
6207 * @dev: Pointer to the net device.
6208 * @info: Pointer to the iw_request_info.
6209 * @wrqu: Pointer to the iwreq_data.
6210 * @extra: Pointer to the data.
6211 *
6212 * Return: 0 for success, error number on failure.
6213 */
6214int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6215 union iwreq_data *wrqu, char *extra)
6216{
6217 int ret;
6218
6219 cds_ssr_protect(__func__);
6220 ret = __iw_get_auth(dev, info, wrqu, extra);
6221 cds_ssr_unprotect(__func__);
6222
6223 return ret;
6224}
6225
6226/**
6227 * __iw_set_ap_address() - set ap address
6228 * @dev: pointer to the net device
6229 * @info: pointer to the iw request info
6230 * @wrqu: pointer to iwreq_data
6231 * @extra: pointer to the data
6232 *
6233 * This function updates the HDD global station context connection info
6234 * BSSID with the MAC address received from the wpa_supplicant.
6235 *
6236 * Return: 0 on success, error number otherwise
6237 */
6238static int __iw_set_ap_address(struct net_device *dev,
6239 struct iw_request_info *info,
6240 union iwreq_data *wrqu, char *extra)
6241{
6242
6243 hdd_adapter_t *adapter;
6244 hdd_context_t *hdd_ctx;
6245 hdd_station_ctx_t *pHddStaCtx =
6246 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6247 uint8_t *pMacAddress = NULL;
6248 int ret;
6249
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006250 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006251
6252 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6253
6254 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6255 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306256 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006257 return ret;
6258
6259 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006260 hdd_info(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306261 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306262 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006263 EXIT();
6264
6265 return 0;
6266}
6267
6268/**
6269 * iw_set_ap_address() - set ap addresses callback function
6270 * @dev: Pointer to the net device.
6271 * @info: Pointer to the iw_request_info.
6272 * @wrqu: Pointer to the iwreq_data.
6273 * @extra: Pointer to the data.
6274 *
6275 * Return: 0 for success, error number on failure.
6276 */
6277int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6278 union iwreq_data *wrqu, char *extra)
6279{
6280 int ret;
6281
6282 cds_ssr_protect(__func__);
6283 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6284 cds_ssr_unprotect(__func__);
6285
6286 return ret;
6287}
6288
6289/**
6290 * __iw_get_ap_address() - get ap address
6291 * @dev: pointer to the net device
6292 * @info: pointer to the iw request info
6293 * @wrqu: pointer to iwreq_data
6294 * @extra: pointer to the data
6295 *
6296 * This function returns currently associated BSSID.
6297 *
6298 * Return: 0 on success, error number otherwise
6299 */
6300static int __iw_get_ap_address(struct net_device *dev,
6301 struct iw_request_info *info,
6302 union iwreq_data *wrqu, char *extra)
6303{
6304 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6305 hdd_context_t *hdd_ctx;
6306 hdd_station_ctx_t *pHddStaCtx =
6307 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6308 int ret;
6309
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006310 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006311
6312 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6313 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306314 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006315 return ret;
6316
6317 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6318 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306319 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006320 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306321 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006322 } else {
6323 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6324 }
6325 EXIT();
6326 return 0;
6327}
6328
6329/**
6330 * iw_get_ap_address() - get ap addresses callback function
6331 * @dev: Pointer to the net device.
6332 * @info: Pointer to the iw_request_info.
6333 * @wrqu: Pointer to the iwreq_data.
6334 * @extra: Pointer to the data.
6335 *
6336 * Return: 0 for success, error number on failure.
6337 */
6338int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6339 union iwreq_data *wrqu, char *extra)
6340{
6341 int ret;
6342
6343 cds_ssr_protect(__func__);
6344 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6345 cds_ssr_unprotect(__func__);
6346
6347 return ret;
6348}