blob: 4c0236a0ab8e4f72ee2c606b99065dd0d3fb6cb9 [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05302 * Copyright (c) 2012-2017 The Linux Foundation. All rights reserved.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
28/**
29 * DOC: wlan_hdd_assoc.c
30 *
31 * WLAN Host Device Driver implementation
32 *
33 */
34
35#include "wlan_hdd_includes.h"
36#include <ani_global.h>
37#include "dot11f.h"
38#include "wlan_hdd_power.h"
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +053039#include "wlan_hdd_trace.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080040#include <linux/ieee80211.h>
41#include <linux/wireless.h>
42#include <linux/etherdevice.h>
43#include <net/cfg80211.h>
44#include "wlan_hdd_cfg80211.h"
45#include "csr_inside_api.h"
46#include "wlan_hdd_p2p.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080047#include "wlan_hdd_tdls.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080048#include "sme_api.h"
49#include "wlan_hdd_hostapd.h"
50#include <wlan_hdd_ipa.h>
Jeff Johnson2b0a7b82016-05-18 15:08:02 -070051#include "wlan_hdd_lpass.h"
Leo Changfdb45c32016-10-28 11:09:23 -070052#include <wlan_logging_sock_svc.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080053#include <cds_sched.h>
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -080054#include "wlan_policy_mgr_api.h"
Anurag Chouhan5de8d172016-07-13 14:44:28 +053055#include <cds_utils.h>
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080056#include "sme_power_save_api.h"
Varun Reddy Yeturu04251862016-09-16 10:33:19 -070057#include "wlan_hdd_napi.h"
Leo Changfdb45c32016-10-28 11:09:23 -070058#include <cdp_txrx_cmn.h>
59#include <cdp_txrx_flow_ctrl_legacy.h>
60#include <cdp_txrx_peer_ops.h>
61#include <cdp_txrx_misc.h>
Kabilan Kannan256e3182017-05-02 16:02:37 -070062#include <cdp_txrx_ctrl.h>
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +053063#include <wlan_logging_sock_svc.h>
Rajeev Kumar59e011b2017-01-13 11:42:20 -080064#include <wlan_hdd_object_manager.h>
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -080065#include <cdp_txrx_handle.h>
Mukul Sharma3d36c392017-01-18 18:39:12 +053066#include "wlan_pmo_ucfg_api.h"
Yu Wang000dc2f2017-05-26 17:38:48 +080067#include "wlan_hdd_tsf.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080068
69/* These are needed to recognize WPA and RSN suite types */
70#define HDD_WPA_OUI_SIZE 4
71#define HDD_RSN_OUI_SIZE 4
72uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
73uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
74uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
75uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
76uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
77uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
78
79#ifdef FEATURE_WLAN_ESE
80/* CCKM */
81uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
82/* CCKM */
83uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
84#endif /* FEATURE_WLAN_ESE */
85
86/* group cipher */
87uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
88
89/* WEP-40 or RSN */
90uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
91
92/* TKIP or RSN-PSK */
93uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
94
95/* Reserved */
96uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
97
98/* AES-CCMP */
99uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
100
101/* WEP-104 */
102uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
103
104#ifdef WLAN_FEATURE_11W
105/* RSN-PSK-SHA256 */
106uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
107
108/* RSN-8021X-SHA256 */
109uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
110#endif
111
Mukul Sharma05504ac2017-06-08 12:35:53 +0530112/* AES-GCMP-128 */
113uint8_t ccp_rsn_oui09[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x08 };
114
115/* AES-GCMP-256 */
116uint8_t ccp_rsn_oui0a[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x09 };
117
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800118/* Offset where the EID-Len-IE, start. */
119#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
120#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800121
122#define BEACON_FRAME_IES_OFFSET 12
123#define HDD_PEER_AUTHORIZE_WAIT 10
124
125/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700126 * beacon_filter_table - table of IEs used for beacon filtering
127 */
128static const int beacon_filter_table[] = {
129 SIR_MAC_DS_PARAM_SET_EID,
130 SIR_MAC_ERP_INFO_EID,
131 SIR_MAC_EDCA_PARAM_SET_EID,
132 SIR_MAC_QOS_CAPABILITY_EID,
133 SIR_MAC_HT_INFO_EID,
134 SIR_MAC_VHT_OPMODE_EID,
135 SIR_MAC_VHT_OPERATION_EID,
Krunal Sonib7f20432017-04-27 13:01:02 -0700136#ifdef WLAN_FEATURE_11AX_BSS_COLOR
137 /*
138 * EID: 221 vendor IE is being used temporarily by 11AX
139 * bss-color-change IE till it gets any fixed number. This
140 * vendor EID needs to be replaced with bss-color-change IE
141 * number.
142 */
143 SIR_MAC_EID_VENDOR,
144#endif
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700145};
146
147/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800148 * hdd_conn_set_authenticated() - set authentication state
149 * @pAdapter: pointer to the adapter
150 * @authState: authentication state
151 *
152 * This function updates the global HDD station context
153 * authentication state.
154 *
155 * Return: none
156 */
157static void
158hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
159{
160 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
161 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
162
163 /* save the new connection state */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700164 hdd_debug("Authenticated state Changed from oldState:%d to State:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700165 pHddStaCtx->conn_info.uIsAuthenticated, authState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800166 pHddStaCtx->conn_info.uIsAuthenticated = authState;
167
168 /* Check is pending ROC request or not when auth state changed */
169 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
170}
171
172/**
173 * hdd_conn_set_connection_state() - set connection state
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700174 * @adapter: pointer to the adapter
175 * @conn_state: connection state
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800176 *
177 * This function updates the global HDD station context connection state.
178 *
179 * Return: none
180 */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700181void hdd_conn_set_connection_state(hdd_adapter_t *adapter,
182 eConnectionState conn_state)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800183{
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700184 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
185 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800186
187 /* save the new connection state */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700188 hdd_debug("%pS Changed conn state from old:%d to new:%d for dev %s",
189 (void *)_RET_IP_, hdd_sta_ctx->conn_info.connState,
190 conn_state, adapter->dev->name);
Yu Wang000dc2f2017-05-26 17:38:48 +0800191
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700192 hdd_tsf_notify_wlan_state_change(adapter,
193 hdd_sta_ctx->conn_info.connState,
194 conn_state);
195 hdd_sta_ctx->conn_info.connState = conn_state;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800196
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -0700197 schedule_delayed_work(&hdd_ctx->roc_req_work, 0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800198}
199
200/**
201 * hdd_conn_get_connection_state() - get connection state
202 * @pAdapter: pointer to the adapter
203 * @pConnState: pointer to connection state
204 *
205 * This function updates the global HDD station context connection state.
206 *
207 * Return: true if (Infra Associated or IBSS Connected)
208 * and sets output parameter pConnState;
209 * false otherwise
210 */
211static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
212 eConnectionState *pConnState)
213{
214 bool fConnected = false;
215 eConnectionState connState;
216
217 /* get the connection state. */
218 connState = pHddStaCtx->conn_info.connState;
219
220 if (eConnectionState_Associated == connState ||
221 eConnectionState_IbssConnected == connState ||
222 eConnectionState_IbssDisconnected == connState) {
223 fConnected = true;
224 }
225
226 if (pConnState)
227 *pConnState = connState;
228
229 return fConnected;
230}
231
232/**
233 * hdd_is_connecting() - Function to check connection progress
234 * @hdd_sta_ctx: pointer to global HDD Station context
235 *
236 * Return: true if connecting, false otherwise
237 */
238bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
239{
240 return hdd_sta_ctx->conn_info.connState ==
241 eConnectionState_Connecting;
242}
243
244/**
245 * hdd_conn_is_connected() - Function to check connection status
246 * @pHddStaCtx: pointer to global HDD Station context
247 *
248 * Return: false if any errors encountered, true otherwise
249 */
250bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
251{
252 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
253}
254
255/**
256 * hdd_conn_get_connected_band() - get current connection radio band
257 * @pHddStaCtx: pointer to global HDD Station context
258 *
259 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
260 * eCSR_BAND_ALL if not connected
261 */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700262enum band_info hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800263{
264 uint8_t staChannel = 0;
265
266 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
267 staChannel = pHddStaCtx->conn_info.operationChannel;
268
269 if (staChannel > 0 && staChannel < 14)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700270 return BAND_2G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800271 else if (staChannel >= 36 && staChannel <= 184)
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700272 return BAND_5G;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800273 else /* If station is not connected return as eCSR_BAND_ALL */
Kiran Kumar Lokereb1d412e2017-04-23 17:19:43 -0700274 return BAND_ALL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800275}
276
277/**
278 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
279 * @pHddStaCtx: pointer to global HDD Station context
280 * @pConnectedCipherAlgo: pointer to connected cipher algo
281 *
282 * Return: false if any errors encountered, true otherwise
283 */
284static inline bool
285hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
286 eCsrEncryptionType *pConnectedCipherAlgo)
287{
288 bool fConnected = false;
289
290 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
291
292 if (pConnectedCipherAlgo)
293 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
294
295 return fConnected;
296}
297
298/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700299 * hdd_remove_beacon_filter() - remove beacon filter
300 * @adapter: Pointer to the hdd adapter
301 *
302 * Return: 0 on success and errno on failure
303 */
304static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
305{
306 QDF_STATUS status;
307 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
308
309 status = sme_remove_beacon_filter(hdd_ctx->hHal,
310 adapter->sessionId);
311 if (!QDF_IS_STATUS_SUCCESS(status)) {
312 hdd_err("sme_remove_beacon_filter() failed");
313 return -EFAULT;
314 }
315
316 return 0;
317}
318
319/**
320 * hdd_add_beacon_filter() - add beacon filter
321 * @adapter: Pointer to the hdd adapter
322 *
323 * Return: 0 on success and errno on failure
324 */
325static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
326{
327 int i;
328 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
329 QDF_STATUS status;
330 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
331
332 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
Kapil Gupta80f4a8d2016-09-22 16:54:35 +0530333 qdf_set_bit((beacon_filter_table[i]),
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700334 (unsigned long int *)ie_map);
335
336 status = sme_add_beacon_filter(hdd_ctx->hHal,
337 adapter->sessionId, ie_map);
338 if (!QDF_IS_STATUS_SUCCESS(status)) {
339 hdd_err("sme_add_beacon_filter() failed");
340 return -EFAULT;
341 }
342 return 0;
343}
344
345/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530346 * hdd_copy_vht_caps()- copy vht caps info from roam info to
347 * hdd station context.
348 * @hdd_sta_ctx: pointer to hdd station context
349 * @roam_info: pointer to roam info
350 *
351 * Return: None
352 */
353static void hdd_copy_ht_caps(hdd_station_ctx_t *hdd_sta_ctx,
354 tCsrRoamInfo *roam_info)
355{
356 tDot11fIEHTCaps *roam_ht_cap = &roam_info->ht_caps;
357 struct ieee80211_ht_cap *hdd_ht_cap = &hdd_sta_ctx->conn_info.ht_caps;
358 uint32_t i, temp_ht_cap;
359
360 qdf_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
361
362 if (roam_ht_cap->advCodingCap)
363 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
364 if (roam_ht_cap->supportedChannelWidthSet)
365 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
366 temp_ht_cap = roam_ht_cap->mimoPowerSave &
367 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
368 if (temp_ht_cap)
369 hdd_ht_cap->cap_info |=
370 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
371 if (roam_ht_cap->greenField)
372 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
373 if (roam_ht_cap->shortGI20MHz)
374 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
375 if (roam_ht_cap->shortGI40MHz)
376 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
377 if (roam_ht_cap->txSTBC)
378 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
379 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
380 IEEE80211_HT_CAP_RX_STBC_SHIFT);
381 if (temp_ht_cap)
382 hdd_ht_cap->cap_info |=
383 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
384 if (roam_ht_cap->delayedBA)
385 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
386 if (roam_ht_cap->maximalAMSDUsize)
387 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
388 if (roam_ht_cap->dsssCckMode40MHz)
389 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
390 if (roam_ht_cap->psmp)
391 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
392 if (roam_ht_cap->stbcControlFrame)
393 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
394 if (roam_ht_cap->lsigTXOPProtection)
395 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
396
397 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
398 if (roam_ht_cap->maxRxAMPDUFactor)
399 hdd_ht_cap->ampdu_params_info |=
400 IEEE80211_HT_AMPDU_PARM_FACTOR;
401 temp_ht_cap = roam_ht_cap->mpduDensity &
402 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
403 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
404 if (temp_ht_cap)
405 hdd_ht_cap->ampdu_params_info |=
406 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
407
408 /* 802.11n HT extended capabilities masks */
409 if (roam_ht_cap->pco)
410 hdd_ht_cap->extended_ht_cap_info |=
411 IEEE80211_HT_EXT_CAP_PCO;
412 temp_ht_cap = roam_ht_cap->transitionTime &
413 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
414 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
415 if (temp_ht_cap)
416 hdd_ht_cap->extended_ht_cap_info |=
417 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
418 temp_ht_cap = roam_ht_cap->mcsFeedback &
419 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
420 if (temp_ht_cap)
421 hdd_ht_cap->extended_ht_cap_info |=
422 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
423
424 /* tx_bf_cap_info capabilities */
425 if (roam_ht_cap->txBF)
426 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
427 if (roam_ht_cap->rxStaggeredSounding)
428 hdd_ht_cap->tx_BF_cap_info |=
429 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
430 if (roam_ht_cap->txStaggeredSounding)
431 hdd_ht_cap->tx_BF_cap_info |=
432 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
433 if (roam_ht_cap->rxZLF)
434 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
435 if (roam_ht_cap->txZLF)
436 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
437 if (roam_ht_cap->implicitTxBF)
438 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
439 temp_ht_cap = roam_ht_cap->calibration &
440 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
441 if (temp_ht_cap)
442 hdd_ht_cap->tx_BF_cap_info |=
443 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
444 if (roam_ht_cap->explicitCSITxBF)
445 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
446 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
447 hdd_ht_cap->tx_BF_cap_info |=
448 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
449 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
450 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
451 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
452 if (temp_ht_cap)
453 hdd_ht_cap->tx_BF_cap_info |=
454 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
455 temp_ht_cap =
456 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
457 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
458 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
459 if (temp_ht_cap)
460 hdd_ht_cap->tx_BF_cap_info |=
461 temp_ht_cap <<
462 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
463 temp_ht_cap =
464 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
465 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
466 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
467 if (temp_ht_cap)
468 hdd_ht_cap->tx_BF_cap_info |=
469 temp_ht_cap <<
470 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
471 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
472 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
473 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
474 if (temp_ht_cap)
475 hdd_ht_cap->tx_BF_cap_info |=
476 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
477 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
478 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
479 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
480 if (temp_ht_cap)
481 hdd_ht_cap->tx_BF_cap_info |=
482 temp_ht_cap <<
483 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
484 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
485 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
486 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
487 if (temp_ht_cap)
488 hdd_ht_cap->tx_BF_cap_info |=
489 temp_ht_cap <<
490 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
491
492 /* antenna selection */
493 if (roam_ht_cap->antennaSelection)
494 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
495 if (roam_ht_cap->explicitCSIFeedbackTx)
496 hdd_ht_cap->antenna_selection_info |=
497 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
498 if (roam_ht_cap->antennaIndicesFeedbackTx)
499 hdd_ht_cap->antenna_selection_info |=
500 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
501 if (roam_ht_cap->explicitCSIFeedback)
502 hdd_ht_cap->antenna_selection_info |=
503 ANTENNA_SEL_INFO_EXP_CSI_FB;
504 if (roam_ht_cap->antennaIndicesFeedback)
505 hdd_ht_cap->antenna_selection_info |=
506 ANTENNA_SEL_INFO_ANT_ID_FB;
507 if (roam_ht_cap->rxAS)
508 hdd_ht_cap->antenna_selection_info |=
509 ANTENNA_SEL_INFO_RX_AS;
510 if (roam_ht_cap->txSoundingPPDUs)
511 hdd_ht_cap->antenna_selection_info |=
512 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
513
514 /* mcs data rate */
515 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
516 hdd_ht_cap->mcs.rx_mask[i] =
517 roam_ht_cap->supportedMCSSet[i];
wadesong42968e92017-06-08 14:11:21 +0800518 hdd_ht_cap->mcs.rx_highest =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530519 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
520 ((short) (roam_ht_cap->supportedMCSSet[10]));
wadesong42968e92017-06-08 14:11:21 +0800521 hdd_ht_cap->mcs.tx_params =
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530522 roam_ht_cap->supportedMCSSet[12];
523}
524
525#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
526#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
527#define VHT_CAP_RXSTBC_MASK_SHIFT 8
528#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
529#define VHT_CAP_BEAMFORMEE_STS_MASK \
530 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
531#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
532#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
533 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
534#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
535#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
536 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
537#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
538
539/**
540 * hdd_copy_ht_caps()- copy ht caps info from roam info to
541 * hdd station context.
542 * @hdd_sta_ctx: pointer to hdd station context
543 * @roam_info: pointer to roam info
544 *
545 * Return: None
546 */
547static void hdd_copy_vht_caps(hdd_station_ctx_t *hdd_sta_ctx,
548 tCsrRoamInfo *roam_info)
549{
550 tDot11fIEVHTCaps *roam_vht_cap = &roam_info->vht_caps;
551 struct ieee80211_vht_cap *hdd_vht_cap =
552 &hdd_sta_ctx->conn_info.vht_caps;
553 uint32_t temp_vht_cap;
554
555 qdf_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
556
557 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
558 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
559 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
560 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
561 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
wadesong42968e92017-06-08 14:11:21 +0800562 if (temp_vht_cap) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530563 if (roam_vht_cap->supportedChannelWidthSet &
564 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
565 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
566 hdd_vht_cap->vht_cap_info |=
567 temp_vht_cap <<
568 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
569 if (roam_vht_cap->supportedChannelWidthSet &
570 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
571 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
572 hdd_vht_cap->vht_cap_info |=
573 temp_vht_cap <<
574 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
wadesong42968e92017-06-08 14:11:21 +0800575 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530576 if (roam_vht_cap->ldpcCodingCap)
577 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
578 if (roam_vht_cap->shortGI80MHz)
579 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
580 if (roam_vht_cap->shortGI160and80plus80MHz)
581 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
582 if (roam_vht_cap->txSTBC)
583 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
584 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
585 VHT_CAP_RXSTBC_MASK_SHIFT);
586 if (temp_vht_cap)
587 hdd_vht_cap->vht_cap_info |=
588 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
589 if (roam_vht_cap->suBeamFormerCap)
590 hdd_vht_cap->vht_cap_info |=
591 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
592 if (roam_vht_cap->suBeamformeeCap)
593 hdd_vht_cap->vht_cap_info |=
594 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
595 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
596 (VHT_CAP_BEAMFORMEE_STS_MASK);
597 if (temp_vht_cap)
598 hdd_vht_cap->vht_cap_info |=
599 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
600 temp_vht_cap = roam_vht_cap->numSoundingDim &
601 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
602 if (temp_vht_cap)
603 hdd_vht_cap->vht_cap_info |=
604 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
605 if (roam_vht_cap->muBeamformerCap)
606 hdd_vht_cap->vht_cap_info |=
607 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
608 if (roam_vht_cap->muBeamformeeCap)
609 hdd_vht_cap->vht_cap_info |=
610 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
611 if (roam_vht_cap->vhtTXOPPS)
612 hdd_vht_cap->vht_cap_info |=
613 IEEE80211_VHT_CAP_VHT_TXOP_PS;
614 if (roam_vht_cap->htcVHTCap)
615 hdd_vht_cap->vht_cap_info |=
616 IEEE80211_VHT_CAP_HTC_VHT;
617 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
618 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
619 if (temp_vht_cap)
620 hdd_vht_cap->vht_cap_info |=
621 temp_vht_cap <<
622 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
623 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
624 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
625 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
626 if (temp_vht_cap)
627 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
628 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
629 if (roam_vht_cap->rxAntPattern)
630 hdd_vht_cap->vht_cap_info |=
631 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
632 if (roam_vht_cap->txAntPattern)
633 hdd_vht_cap->vht_cap_info |=
634 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
635 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
636 hdd_vht_cap->supp_mcs.rx_highest =
637 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
638 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
639 hdd_vht_cap->supp_mcs.tx_highest =
640 ((uint16_t)roam_vht_cap->txSupDataRate);
641}
642
643/* ht param */
644#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
645#define HT_PARAM_SERVICE_INT_GRAN 0xe0
646#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
647
648/* operatinon mode */
649#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
650
651/* stbc_param */
652#define HT_STBC_PARAM_MCS 0x007f
653
654/**
655 * hdd_copy_ht_operation()- copy HT operation element from roam info to
656 * hdd station context.
657 * @hdd_sta_ctx: pointer to hdd station context
658 * @roam_info: pointer to roam info
659 *
660 * Return: None
661 */
662static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
663 tCsrRoamInfo *roam_info)
664{
665 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
666 struct ieee80211_ht_operation *hdd_ht_ops =
667 &hdd_sta_ctx->conn_info.ht_operation;
668 uint32_t i, temp_ht_ops;
669
670 qdf_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
671
672 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
673
674 /* HT_PARAMS */
675 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
676 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
677 if (temp_ht_ops)
678 hdd_ht_ops->ht_param |= temp_ht_ops;
679 else
680 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
681 if (roam_ht_ops->recommendedTxWidthSet)
682 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
683 if (roam_ht_ops->rifsMode)
684 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
685 if (roam_ht_ops->controlledAccessOnly)
686 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
687 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
688 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
689 if (temp_ht_ops)
690 hdd_ht_ops->ht_param |= temp_ht_ops <<
691 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
692
693 /* operation mode */
694 temp_ht_ops = roam_ht_ops->opMode &
695 IEEE80211_HT_OP_MODE_PROTECTION;
696 switch (temp_ht_ops) {
697 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
698 hdd_ht_ops->operation_mode |=
699 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
700 break;
701 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
702 hdd_ht_ops->operation_mode |=
703 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
704 break;
705 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
706 hdd_ht_ops->operation_mode |=
707 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
708 break;
709 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
710 default:
711 hdd_ht_ops->operation_mode |=
712 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
713 }
714 if (roam_ht_ops->nonGFDevicesPresent)
715 hdd_ht_ops->operation_mode |=
716 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
717 if (roam_ht_ops->transmitBurstLimit)
718 hdd_ht_ops->operation_mode |=
719 HT_OP_MODE_TX_BURST_LIMIT;
720 if (roam_ht_ops->obssNonHTStaPresent)
721 hdd_ht_ops->operation_mode |=
722 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
723
724 /* stbc_param */
725 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
726 HT_STBC_PARAM_MCS;
727 if (temp_ht_ops)
728 hdd_ht_ops->stbc_param |= temp_ht_ops;
729 if (roam_ht_ops->dualCTSProtection)
730 hdd_ht_ops->stbc_param |=
731 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
732 if (roam_ht_ops->secondaryBeacon)
733 hdd_ht_ops->stbc_param |=
734 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
735 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
736 hdd_ht_ops->stbc_param |=
737 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
738 if (roam_ht_ops->pcoActive)
739 hdd_ht_ops->stbc_param |=
740 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
741 if (roam_ht_ops->pcoPhase)
742 hdd_ht_ops->stbc_param |=
743 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
744
745 /* basic MCs set */
746 for (i = 0; i < 16; ++i)
747 hdd_ht_ops->basic_set[i] =
748 roam_ht_ops->basicMCSSet[i];
749}
750
751/**
752 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
753 * hdd station context.
754 * @hdd_sta_ctx: pointer to hdd station context
755 * @roam_info: pointer to roam info
756 *
757 * Return: None
758 */
759static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
760 tCsrRoamInfo *roam_info)
761{
762 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
763 struct ieee80211_vht_operation *hdd_vht_ops =
764 &hdd_sta_ctx->conn_info.vht_operation;
765
766 qdf_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
767
768 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
769 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
770 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
771 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
772}
773
774
775/**
776 * hdd_save_bss_info() - save connection info in hdd sta ctx
777 * @adapter: Pointer to adapter
778 * @roam_info: pointer to roam info
779 *
780 * Return: None
781 */
782static void hdd_save_bss_info(hdd_adapter_t *adapter,
783 tCsrRoamInfo *roam_info)
784{
785 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
786
787 hdd_sta_ctx->conn_info.freq = cds_chan_to_freq(
788 hdd_sta_ctx->conn_info.operationChannel);
789 if (roam_info->vht_caps.present) {
790 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
791 hdd_copy_vht_caps(hdd_sta_ctx, roam_info);
792 } else {
793 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
794 }
795 if (roam_info->ht_caps.present) {
796 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
797 hdd_copy_ht_caps(hdd_sta_ctx, roam_info);
798 } else {
799 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
800 }
801 if (roam_info->reassoc)
802 hdd_sta_ctx->conn_info.roam_count++;
803 if (roam_info->hs20vendor_ie.present) {
804 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
805 qdf_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
806 &roam_info->hs20vendor_ie,
807 sizeof(roam_info->hs20vendor_ie));
808 } else {
809 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
810 }
811 if (roam_info->ht_operation.present) {
812 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
813 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
814 } else {
815 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
816 }
817 if (roam_info->vht_operation.present) {
818 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
819 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
820 } else {
821 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
822 }
823}
824
825/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800826 * hdd_conn_save_connect_info() - save current connection information
827 * @pAdapter: pointer to adapter
828 * @pRoamInfo: pointer to roam info
829 * @eBssType: bss type
830 *
831 * Return: none
832 */
833static void
834hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
835 eCsrRoamBssType eBssType)
836{
837 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
838 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
839
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530840 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800841
842 if (pRoamInfo) {
843 /* Save the BSSID for the connection */
844 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530845 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530846 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800847 &pRoamInfo->bssid);
848
849 /*
850 * Save the Station ID for this station from
851 * the 'Roam Info'. For IBSS mode, staId is
852 * assigned in NEW_PEER_IND. For reassoc,
853 * the staID doesn't change and it may be invalid
854 * in this structure so no change here.
855 */
856 if (!pRoamInfo->fReassocReq) {
857 pHddStaCtx->conn_info.staId[0] =
858 pRoamInfo->staId;
859 }
860 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530861 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800862 &pRoamInfo->bssid);
863 } else {
864 /*
865 * can't happen. We need a valid IBSS or Infra setting
866 * in the BSSDescription or we can't function.
867 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530868 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800869 }
870
871 /* notify WMM */
872 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
873
874 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530875 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800876 } else {
877 /* Get Multicast Encryption Type */
878 encryptType =
879 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
880 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
881 /* Get Unicast Encryption Type */
882 encryptType =
883 pRoamInfo->u.pConnectedProfile->EncryptionType;
884 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
885
886 pHddStaCtx->conn_info.authType =
887 pRoamInfo->u.pConnectedProfile->AuthType;
Zhang Qian32fd43e2017-08-24 18:36:28 +0800888 pHddStaCtx->conn_info.last_auth_type =
889 pHddStaCtx->conn_info.authType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800890
891 pHddStaCtx->conn_info.operationChannel =
892 pRoamInfo->u.pConnectedProfile->operationChannel;
893
894 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530895 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800896 &pRoamInfo->u.pConnectedProfile->SSID,
897 sizeof(tSirMacSSid));
Zhang Qian32fd43e2017-08-24 18:36:28 +0800898 qdf_mem_copy(&pHddStaCtx->conn_info.last_ssid.SSID,
899 &pRoamInfo->u.pConnectedProfile->SSID,
900 sizeof(tSirMacSSid));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800901
902 /* Save dot11mode in which STA associated to AP */
903 pHddStaCtx->conn_info.dot11Mode =
904 pRoamInfo->u.pConnectedProfile->dot11Mode;
905
906 pHddStaCtx->conn_info.proxyARPService =
907 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530908
909 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
910
911 pHddStaCtx->conn_info.rate_flags =
912 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800913 }
Anurag Chouhan5de8d172016-07-13 14:44:28 +0530914 hdd_save_bss_info(pAdapter, pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800915 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800916}
917
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800918/**
919 * hdd_send_ft_assoc_response() - send fast transition assoc response
920 * @dev: pointer to net device
921 * @pAdapter: pointer to adapter
922 * @pCsrRoamInfo: pointer to roam info
923 *
924 * Send the 11R key information to the supplicant. Only then can the supplicant
925 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
926 * for the same purpose.)
927 *
928 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
929 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
930 * This is the Assoc Response.
931 *
932 * Return: none
933 */
934static void
935hdd_send_ft_assoc_response(struct net_device *dev,
936 hdd_adapter_t *pAdapter,
937 tCsrRoamInfo *pCsrRoamInfo)
938{
939 union iwreq_data wrqu;
940 char *buff;
941 unsigned int len = 0;
942 u8 *pFTAssocRsp = NULL;
943
944 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700945 hdd_debug("assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800946 return;
947 }
948
949 pFTAssocRsp =
950 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
951 pCsrRoamInfo->nAssocReqLength);
952 if (pFTAssocRsp == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700953 hdd_debug("AssocReq or AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800954 return;
955 }
956 /* pFTAssocRsp needs to point to the IEs */
957 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -0700958 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -0700959 (unsigned int)pFTAssocRsp[0],
960 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800961
962 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700963 buff = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800964 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700965 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800966 return;
967 }
968 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
969 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
970 wrqu.data.length = len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800971 memcpy(buff, pFTAssocRsp, len);
972 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
973
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -0700974 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800975}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800977/**
978 * hdd_send_ft_event() - send fast transition event
979 * @pAdapter: pointer to adapter
980 *
981 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
982 * FT events to the supplicant. At the reception of Auth2 we send the RIC
983 * followed by the auth response IEs to the supplicant.
984 * Once both are received in the supplicant, an FT event is generated
985 * to the supplicant.
986 *
987 * Return: none
988 */
989static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
990{
991 uint16_t auth_resp_len = 0;
992 uint32_t ric_ies_length = 0;
993 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
994
995#if defined(KERNEL_SUPPORT_11R_CFG80211)
996 struct cfg80211_ft_event_params ftEvent;
997 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
998 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
999 struct net_device *dev = pAdapter->dev;
1000#else
1001 char *buff;
1002 union iwreq_data wrqu;
1003 uint16_t str_len;
1004#endif
1005
1006#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301007 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
1008 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001009
1010 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
1011 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001012 if (ric_ies_length == 0)
1013 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001014
1015 ftEvent.ric_ies = ricIe;
1016 ftEvent.ric_ies_len = ric_ies_length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001017 hdd_debug("RIC IEs is of length %d", (int)ric_ies_length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001018
1019 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1020 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
1021 &auth_resp_len);
1022
1023 if (auth_resp_len == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001024 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001025 return;
1026 }
1027
1028 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
1029
1030 ftEvent.target_ap = ftIe;
1031
Anurag Chouhan6d760662016-02-20 16:05:43 +05301032 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
1033 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001034
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001035 hdd_debug("ftEvent.ies_len %zu", ftEvent.ies_len);
1036 hdd_debug("ftEvent.ric_ies_len %zu", ftEvent.ric_ies_len);
1037 hdd_debug("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001038 ftEvent.target_ap[0], ftEvent.target_ap[1],
1039 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1040 ftEvent.target_ap[5]);
1041
1042 (void)cfg80211_ft_event(dev, &ftEvent);
1043
1044#else
1045 /* We need to send the IEs to the supplicant */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001046 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001047 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001048 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001049 return;
1050 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001051
1052 /* Sme needs to send the RIC IEs first */
1053 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
1054 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
1055 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
1056 &ric_ies_length);
1057 if (ric_ies_length == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001058 hdd_warn("Do not send RIC IEs as length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001059 } else {
1060 wrqu.data.length = str_len + ric_ies_length;
1061 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1062 }
1063
1064 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301065 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001066 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
1067 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
1068 (u8 *) &buff[str_len],
1069 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
1070
1071 if (auth_resp_len == 0) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001072 qdf_mem_free(buff);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001073 hdd_debug("AuthRsp FTIES is of length 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001074 return;
1075 }
1076
1077 wrqu.data.length = str_len + auth_resp_len;
1078 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1079
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001080 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001081#endif
1082}
1083
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001084#ifdef FEATURE_WLAN_ESE
1085/**
1086 * hdd_send_new_ap_channel_info() - send new ap channel info
1087 * @dev: pointer to net device
1088 * @pAdapter: pointer to adapter
1089 * @pCsrRoamInfo: pointer to roam info
1090 *
1091 * Send the ESE required "new AP Channel info" to the supplicant.
1092 * (This keeps the supplicant "up to date" on the current channel.)
1093 *
1094 * The current (new AP) channel information is passed in.
1095 *
1096 * Return: none
1097 */
1098static void
1099hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
1100 tCsrRoamInfo *pCsrRoamInfo)
1101{
1102 union iwreq_data wrqu;
1103 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
1104
1105 if (descriptor == NULL) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001106 hdd_err("bss descriptor is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001107 return;
1108 }
1109 /*
1110 * Send the Channel event, the supplicant needs this to generate
1111 * the Adjacent AP report.
1112 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001113 hdd_debug("Sending up an SIOCGIWFREQ, channelId: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001114 descriptor->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115 memset(&wrqu, '\0', sizeof(wrqu));
1116 wrqu.freq.m = descriptor->channelId;
1117 wrqu.freq.e = 0;
1118 wrqu.freq.i = 0;
1119 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1120}
1121
1122#endif /* FEATURE_WLAN_ESE */
1123
1124/**
1125 * hdd_send_update_beacon_ies_event() - send update beacons ie event
1126 * @pAdapter: pointer to adapter
1127 * @pCsrRoamInfo: pointer to roam info
1128 *
1129 * Return: none
1130 */
1131static void
1132hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
1133 tCsrRoamInfo *pCsrRoamInfo)
1134{
1135 union iwreq_data wrqu;
1136 u8 *pBeaconIes;
1137 u8 currentLen = 0;
1138 char *buff;
1139 int totalIeLen = 0, currentOffset = 0, strLen;
1140
1141 memset(&wrqu, '\0', sizeof(wrqu));
1142
1143 if (0 == pCsrRoamInfo->nBeaconLength) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001144 hdd_debug("beacon frame length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001145 return;
1146 }
1147 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
1148 if (pBeaconIes == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001149 hdd_warn("Beacon IEs is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001150 return;
1151 }
1152 /* pBeaconIes needs to point to the IEs */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001153 hdd_debug("Beacon IEs is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001154 (unsigned int)pBeaconIes[0],
1155 (unsigned int)pBeaconIes[1]);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001156 hdd_debug("Beacon IEs length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001157 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001158
1159 /* We need to send the IEs to the supplicant. */
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001160 buff = qdf_mem_malloc(IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001161 if (buff == NULL) {
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001162 hdd_err("unable to allocate memory");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001163 return;
1164 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001165
1166 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
1167 currentLen = strLen + 1;
1168
1169 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1170 do {
1171 /*
1172 * If the beacon size exceeds max CUSTOM event size, break it
1173 * into chunks of CUSTOM event max size and send it to
1174 * supplicant. Changes are done in supplicant to handle this.
1175 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301176 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001177 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +05301178 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301179 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001180 currentLen);
1181 currentOffset += currentLen;
1182 totalIeLen -= currentLen;
1183 wrqu.data.length = strLen + 1 + currentLen;
1184 if (totalIeLen)
1185 buff[strLen] = 1; /* more chunks pending */
1186 else
1187 buff[strLen] = 0; /* last chunk */
1188
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001189 hdd_debug("Beacon IEs length to supplicant = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001190 currentLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001191 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1192 } while (totalIeLen > 0);
1193
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07001194 qdf_mem_free(buff);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001195}
1196
1197/**
1198 * hdd_send_association_event() - send association event
1199 * @dev: pointer to net device
1200 * @pCsrRoamInfo: pointer to roam info
1201 *
1202 * Return: none
1203 */
1204static void hdd_send_association_event(struct net_device *dev,
1205 tCsrRoamInfo *pCsrRoamInfo)
1206{
Rajeev Kumar78427682017-01-13 16:13:11 -08001207 int ret;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001208 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1209 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1210 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1211 union iwreq_data wrqu;
1212 int we_event;
1213 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +05301214 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001215
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 /* Added to find the auth type on the fly at run time */
1217 /* rather than with cfg to see if FT is enabled */
1218 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1219 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001220
1221 memset(&wrqu, '\0', sizeof(wrqu));
1222 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
1223 we_event = SIOCGIWAP;
1224#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1225 if (NULL != pCsrRoamInfo)
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301226 if (pCsrRoamInfo->roamSynchInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001227 /* change logging before release */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001228 hdd_debug("LFR3:hdd_send_association_event");
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301229 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001230 hdd_notify_sta_disconnect(pAdapter->sessionId,
1231 true, pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301232 wlan_hdd_tdls_notify_disconnect(pAdapter, true);
Nitesh Shahd11bfa22016-12-22 12:06:23 +05301233 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234#endif
1235 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
Naveen Rawat910726a2017-03-06 11:42:51 -08001236 tSirSmeChanInfo chan_info = {0};
Abhishek Singh1c676222016-05-09 14:20:28 +05301237
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001238 if (!pCsrRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001239 hdd_warn("STA in associated state but pCsrRoamInfo is null");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001240 return;
1241 }
1242
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001243 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001244 policy_mgr_incr_active_session(pHddCtx->hdd_psoc,
1245 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001246 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
1247 sizeof(pCsrRoamInfo->pBssDesc->bssId));
1248
1249#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001250 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 if (global_p2p_connection_status ==
1252 P2P_CLIENT_CONNECTING_STATE_1) {
1253 global_p2p_connection_status =
1254 P2P_CLIENT_CONNECTED_STATE_1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001255 hdd_debug("[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001256 } else if (global_p2p_connection_status ==
1257 P2P_CLIENT_CONNECTING_STATE_2) {
1258 global_p2p_connection_status =
1259 P2P_CLIENT_COMPLETED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001260 hdd_debug("[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261 }
1262 }
1263#endif
1264 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
1265 MAC_ADDRESS_STR "\n",
1266 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1267 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
1268 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
1269
1270 /*
1271 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
1272 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08001273 * fFTEnable is true.
1274 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001276 if ((pRoamProfile->AuthType.authType[0] ==
1277 eCSR_AUTH_TYPE_FT_RSN_PSK)
1278 || (pRoamProfile->AuthType.authType[0] ==
1279 eCSR_AUTH_TYPE_FT_RSN)
1280#ifdef FEATURE_WLAN_ESE
1281 || (pRoamProfile->AuthType.authType[0] ==
1282 eCSR_AUTH_TYPE_CCKM_RSN)
1283 || (pRoamProfile->AuthType.authType[0] ==
1284 eCSR_AUTH_TYPE_CCKM_WPA)
1285#endif
1286 ) {
1287 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
1288 }
Abhishek Singh1c676222016-05-09 14:20:28 +05301289 qdf_copy_macaddr(&peerMacAddr,
1290 &pHddStaCtx->conn_info.bssId);
1291 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
1292 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
1293 chan_info.info = pCsrRoamInfo->chan_info.info;
1294 chan_info.band_center_freq1 =
1295 pCsrRoamInfo->chan_info.band_center_freq1;
1296 chan_info.band_center_freq2 =
1297 pCsrRoamInfo->chan_info.band_center_freq2;
1298 chan_info.reg_info_1 =
1299 pCsrRoamInfo->chan_info.reg_info_1;
1300 chan_info.reg_info_2 =
1301 pCsrRoamInfo->chan_info.reg_info_2;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301302
Dustin Brown7d043f62017-03-27 12:07:36 -07001303 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1304 pAdapter->device_mode,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301305 peerMacAddr.bytes,
1306 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001307 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301308 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1309 MAC_ADDR_ARRAY(peerMacAddr.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001310 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1311 WLAN_ASSOC_STATE);
Mukul Sharma5678be42017-01-24 12:20:01 +05301312 if (ret)
1313 hdd_err("Peer object %pM fail to set associated state",
1314 peerMacAddr.bytes);
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301315
Abhishek Singh1c676222016-05-09 14:20:28 +05301316 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001317 hdd_send_peer_status_ind_to_app(&peerMacAddr,
1318 ePeerConnected,
1319 pCsrRoamInfo->timingMeasCap,
1320 pAdapter->sessionId, &chan_info,
1321 pAdapter->device_mode);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001322 /* Update tdls module about connection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001323 hdd_notify_sta_connect(pAdapter->sessionId,
1324 pCsrRoamInfo->tdls_chan_swit_prohibited,
1325 pCsrRoamInfo->tdls_prohibited,
1326 pAdapter->hdd_vdev);
1327
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001328 wlan_hdd_tdls_notify_connect(pAdapter, pCsrRoamInfo);
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07001329
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001330
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001331#ifdef MSM_PLATFORM
Ravi Joshiae8e9a72016-08-03 17:38:03 -07001332#if defined(CONFIG_ICNSS) || defined(CONFIG_CNSS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001333 /* start timer in sta/p2p_cli */
1334 spin_lock_bh(&pHddCtx->bus_bw_lock);
1335 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
1336 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
Leo Changfdb45c32016-10-28 11:09:23 -07001337 cdp_get_intra_bss_fwd_pkts_count(
1338 cds_get_context(QDF_MODULE_ID_SOC), pAdapter->sessionId,
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301339 &pAdapter->prev_fwd_tx_packets,
1340 &pAdapter->prev_fwd_rx_packets);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001341 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001342 hdd_bus_bw_compute_timer_start(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343#endif
1344#endif
1345 } else if (eConnectionState_IbssConnected == /* IBss Associated */
1346 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001347 policy_mgr_update_connection_info(pHddCtx->hdd_psoc,
1348 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001350 ETH_ALEN);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001351 hdd_info("wlan: new IBSS connection to " MAC_ADDRESS_STR,
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001352 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301353
Dustin Brown7d043f62017-03-27 12:07:36 -07001354 ret = hdd_objmgr_add_peer_object(pAdapter->hdd_vdev,
1355 QDF_IBSS_MODE,
Rachit Kankane2487f8f2017-04-19 14:30:19 +05301356 pCsrRoamInfo->bssid.bytes,
1357 false);
Rajeev Kumar78427682017-01-13 16:13:11 -08001358 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301359 hdd_err("Peer object "MAC_ADDRESS_STR" add fails!",
1360 MAC_ADDR_ARRAY(pCsrRoamInfo->bssid.bytes));
Dustin Brown7d043f62017-03-27 12:07:36 -07001361 ret = hdd_objmgr_set_peer_mlme_state(pAdapter->hdd_vdev,
1362 WLAN_ASSOC_STATE);
Mukul Sharmaeb01e132017-02-16 13:01:03 +05301363 if (ret)
1364 hdd_err("Peer object %pM fail to set associated state",
1365 peerMacAddr.bytes);
1366
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001367 } else { /* Not Associated */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001368 hdd_info("wlan: disconnected");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001369 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08001370 policy_mgr_decr_session_set_pcl(pHddCtx->hdd_psoc,
1371 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001372
1373#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1374 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1375#endif
1376
Abhishek Singh1c676222016-05-09 14:20:28 +05301377 if ((pAdapter->device_mode == QDF_STA_MODE) ||
1378 (pAdapter->device_mode == QDF_P2P_CLIENT_MODE)) {
Anurag Chouhanc5548422016-02-24 18:33:27 +05301379 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001380 &pHddStaCtx->conn_info.bssId);
1381
1382 /* send peer status indication to oem app */
Naveen Rawat910726a2017-03-06 11:42:51 -08001383 hdd_send_peer_status_ind_to_app(&peerMacAddr,
Abhishek Singh1c676222016-05-09 14:20:28 +05301384 ePeerDisconnected, 0,
1385 pAdapter->sessionId,
1386 NULL,
1387 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001388 }
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301389
Dustin Brown7d043f62017-03-27 12:07:36 -07001390 ret = hdd_objmgr_remove_peer_object(pAdapter->hdd_vdev,
1391 peerMacAddr.bytes);
Rajeev Kumardfa37072017-01-13 16:27:22 -08001392 if (ret)
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05301393 hdd_err("Peer obj "MAC_ADDRESS_STR" delete fails",
1394 MAC_ADDR_ARRAY(peerMacAddr.bytes));
1395
Jeff Johnsoncef59bb2016-09-23 15:28:47 -07001396 hdd_lpass_notify_disconnect(pAdapter);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001397 /* Update tdls module about the disconnection event */
Kabilan Kannan1c1c4022017-04-06 22:49:26 -07001398 hdd_notify_sta_disconnect(pAdapter->sessionId,
1399 false,
1400 pAdapter->hdd_vdev);
Nitesh Shahb9d3dbb2017-01-16 16:37:20 +05301401 wlan_hdd_tdls_notify_disconnect(pAdapter, false);
Kabilan Kannan32eb5022016-10-04 12:24:50 -07001402
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001403#ifdef MSM_PLATFORM
1404 /* stop timer in sta/p2p_cli */
1405 spin_lock_bh(&pHddCtx->bus_bw_lock);
1406 pAdapter->prev_tx_packets = 0;
1407 pAdapter->prev_rx_packets = 0;
Himanshu Agarwal5ac2f7b2016-05-06 20:08:10 +05301408 pAdapter->prev_fwd_tx_packets = 0;
1409 pAdapter->prev_fwd_rx_packets = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001410 spin_unlock_bh(&pHddCtx->bus_bw_lock);
Dustin Brown5ec6b552017-03-31 12:11:40 -07001411 hdd_bus_bw_compute_timer_try_stop(pHddCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001412#endif
1413 }
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08001414 hdd_ipa_set_tx_flow_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001415 /* Send SCC/MCC Switching event to IPA */
1416 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
1417
1418 msg = NULL;
Jeff Johnson5a062372017-01-12 09:51:25 -08001419 /* During the WLAN uninitialization,supplicant is stopped before the
1420 * driver so not sending the status of the connection to supplicant
1421 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001422 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001423 wireless_send_event(dev, we_event, &wrqu, msg);
1424#ifdef FEATURE_WLAN_ESE
1425 if (eConnectionState_Associated ==
1426 pHddStaCtx->conn_info.connState) {
1427 if ((pRoamProfile->AuthType.authType[0] ==
1428 eCSR_AUTH_TYPE_CCKM_RSN) ||
1429 (pRoamProfile->AuthType.authType[0] ==
1430 eCSR_AUTH_TYPE_CCKM_WPA))
1431 hdd_send_new_ap_channel_info(dev, pAdapter,
1432 pCsrRoamInfo);
1433 }
1434#endif
1435 }
1436}
1437
1438/**
1439 * hdd_conn_remove_connect_info() - remove connection info
1440 * @pHddStaCtx: pointer to global HDD station context
1441 * @pCsrRoamInfo: pointer to roam info
1442 *
1443 * Return: none
1444 */
1445static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
1446{
1447 /* Remove staId, bssId and peerMacAddress */
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301448 pHddStaCtx->conn_info.staId[0] = HDD_WLAN_INVALID_STA_ID;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301449 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
1450 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301451 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001452
1453 /* Clear all security settings */
1454 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1455 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1456 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1457
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301458 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
1459 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001460
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001461 pHddStaCtx->conn_info.proxyARPService = 0;
1462
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301463 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001464}
1465
1466/**
1467 * hdd_roam_deregister_sta() - deregister station
1468 * @pAdapter: pointer to adapter
1469 * @staId: station identifier
1470 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301471 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001472 */
Abhishek Singh07c627e2017-03-20 17:56:34 +05301473QDF_STATUS hdd_roam_deregister_sta(hdd_adapter_t *adapter, uint8_t staid)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001474{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301475 QDF_STATUS qdf_status;
Abhishek Singh07c627e2017-03-20 17:56:34 +05301476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1477 int ret = 0;
1478 uint8_t *peer_mac = NULL;
1479 struct qdf_mac_addr broadcastMacAddr =
1480 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001481 if (eConnectionState_IbssDisconnected ==
1482 pHddStaCtx->conn_info.connState) {
1483 /*
1484 * Do not set the carrier off when the last peer leaves.
1485 * We will set the carrier off while stopping the IBSS.
1486 */
1487 }
1488
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08001489 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001490 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
Abhishek Singh07c627e2017-03-20 17:56:34 +05301491 staid);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301492 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Abhishek Singh07c627e2017-03-20 17:56:34 +05301493 hdd_err("cdp_clear_peer() failed for staid %d. Status(%d) [0x%08X]",
1494 staid, qdf_status, qdf_status);
1495 }
1496
1497 if (adapter->device_mode == QDF_STA_MODE) {
1498 peer_mac = pHddStaCtx->conn_info.bssId.bytes;
1499 } else if (adapter->device_mode == QDF_IBSS_MODE) {
1500 if (pHddStaCtx->broadcast_staid == staid)
1501 peer_mac = broadcastMacAddr.bytes;
1502 else
1503 peer_mac = pHddStaCtx->conn_info.
1504 peerMacAddress[staid].bytes;
1505 }
1506
Dustin Brown7d043f62017-03-27 12:07:36 -07001507 ret = hdd_objmgr_remove_peer_object(adapter->hdd_vdev, peer_mac);
Abhishek Singh07c627e2017-03-20 17:56:34 +05301508 if (ret) {
1509 hdd_err("Peer obj %pM delete fails", peer_mac);
1510 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001511 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301512 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001513}
1514
1515/**
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301516 * hdd_print_bss_info() - print bss info
1517 * @hdd_sta_ctx: pointer to hdd station context
1518 *
1519 * Return: None
1520 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001521static void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301522{
1523 uint32_t *cap_info;
1524
1525 hdd_info("WIFI DATA LOGGER");
1526 hdd_info("channel: %d",
1527 hdd_sta_ctx->conn_info.freq);
1528 hdd_info("dot11mode: %d",
1529 hdd_sta_ctx->conn_info.dot11Mode);
1530 hdd_info("AKM: %d",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001531 hdd_sta_ctx->conn_info.last_auth_type);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301532 hdd_info("ssid: %.*s",
Zhang Qian32fd43e2017-08-24 18:36:28 +08001533 hdd_sta_ctx->conn_info.last_ssid.SSID.length,
1534 hdd_sta_ctx->conn_info.last_ssid.SSID.ssId);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301535 hdd_info("roam count: %d",
1536 hdd_sta_ctx->conn_info.roam_count);
1537 hdd_info("ant_info: %d",
1538 hdd_sta_ctx->conn_info.txrate.nss);
1539 hdd_info("datarate legacy %d",
1540 hdd_sta_ctx->conn_info.txrate.legacy);
1541 hdd_info("datarate mcs: %d",
1542 hdd_sta_ctx->conn_info.txrate.mcs);
1543 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1544 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1545 hdd_info("ht caps: %x", *cap_info);
1546 }
1547 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1548 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1549 hdd_info("vht caps: %x", *cap_info);
1550 }
1551 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1552 hdd_info("hs20 info: %x",
1553 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1554 hdd_info("signal: %d",
1555 hdd_sta_ctx->conn_info.signal);
1556 hdd_info("noise: %d",
1557 hdd_sta_ctx->conn_info.noise);
1558}
1559
1560/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561 * hdd_dis_connect_handler() - disconnect event handler
1562 * @pAdapter: pointer to adapter
1563 * @pRoamInfo: pointer to roam info
1564 * @roamId: roam identifier
1565 * @roamStatus: roam status
1566 * @roamResult: roam result
1567 *
1568 * This function handles disconnect event:
1569 * 1. Disable transmit queues;
1570 * 2. Clean up internal connection states and data structures;
1571 * 3. Send disconnect indication to supplicant.
1572 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301573 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001574 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301575static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001576 tCsrRoamInfo *pRoamInfo,
1577 uint32_t roamId,
1578 eRoamCmdStatus roamStatus,
1579 eCsrRoamResult roamResult)
1580{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301581 QDF_STATUS status = QDF_STATUS_SUCCESS;
1582 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001583 struct net_device *dev = pAdapter->dev;
1584 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1585 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1586 uint8_t sta_id;
1587 bool sendDisconInd = true;
1588
1589 if (dev == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001590 hdd_err("net_dev is released return");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301591 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001592 }
1593 /* notify apps that we can't pass traffic anymore */
Varun Reddy Yeturu8a5d3d42017-08-02 13:03:27 -07001594 hdd_debug("Disabling queues");
Himanshu Agarwal865201d2017-04-12 15:45:31 +05301595 wlan_hdd_netif_queue_control(pAdapter,
1596 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
1597 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001598
1599 if (hdd_ipa_is_enabled(pHddCtx))
1600 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
Mohit Khannafa99aea2016-05-12 21:43:13 -07001601 HDD_IPA_STA_DISCONNECT,
1602 pHddStaCtx->conn_info.bssId.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001603
1604#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1605 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1606#endif
1607
Nirav Shah1da77682016-05-03 20:16:39 +05301608 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
1609 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07001610 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05301611 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_DISASSOC));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001612
1613 /* HDD has initiated disconnect, do not send disconnect indication
1614 * to kernel. Sending disconnected event to kernel for userspace
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301615 * initiated disconnect will be handled by disconnect handler call
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001616 * to cfg80211_disconnected.
1617 */
1618 if ((eConnectionState_Disconnecting ==
1619 pHddStaCtx->conn_info.connState) ||
1620 (eConnectionState_NotConnected ==
1621 pHddStaCtx->conn_info.connState)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001622 hdd_debug("HDD has initiated a disconnect, no need to send disconnect indication to kernel");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001623 sendDisconInd = false;
1624 }
1625
1626 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1627 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001628 hdd_conn_set_connection_state(pAdapter,
1629 eConnectionState_Disconnecting);
1630 }
1631
1632 hdd_clear_roam_profile_ie(pAdapter);
1633 hdd_wmm_init(pAdapter);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001634 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05301635 wlan_deregister_txrx_packetdump();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001636
1637 /* indicate 'disconnect' status to wpa_supplicant... */
1638 hdd_send_association_event(dev, pRoamInfo);
1639 /* indicate disconnected event to nl80211 */
1640 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1641 /*
1642 * Only send indication to kernel if not initiated
1643 * by kernel
1644 */
1645 if (sendDisconInd) {
1646 /*
1647 * To avoid wpa_supplicant sending "HANGED" CMD
1648 * to ICS UI.
1649 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001650 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1651 if (pRoamInfo->reasonCode ==
1652 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1653 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301654 wlan_hdd_cfg80211_indicate_disconnect(
1655 dev, false,
1656 pRoamInfo->reasonCode);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001657 } else {
Mahesh A Saptasagarc35e8bf2016-06-17 20:03:46 +05301658 wlan_hdd_cfg80211_indicate_disconnect(
1659 dev, false,
1660 WLAN_REASON_UNSPECIFIED
1661 );
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001662 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663
Sreelakshmi Konamki58c72432016-11-09 17:06:44 +05301664 hdd_info("sent disconnected event to nl80211, reason code %d",
1665 (eCSR_ROAM_LOSTLINK == roamStatus) ?
1666 pRoamInfo->reasonCode :
1667 WLAN_REASON_UNSPECIFIED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001668 }
1669 /*
1670 * During the WLAN uninitialization,supplicant is stopped
1671 * before the driver so not sending the status of the
1672 * connection to supplicant.
1673 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001674 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001675#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001676 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001677 if (global_p2p_connection_status ==
1678 P2P_CLIENT_CONNECTED_STATE_1) {
1679 global_p2p_connection_status =
1680 P2P_CLIENT_DISCONNECTED_STATE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001681 hdd_debug("[P2P State] 8 way Handshake completed and moved to disconnected state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001682 } else if (global_p2p_connection_status ==
1683 P2P_CLIENT_COMPLETED_STATE) {
1684 global_p2p_connection_status =
1685 P2P_NOT_ACTIVE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001686 hdd_debug("[P2P State] P2P Client is removed and moved to inactive state");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001687 }
1688 }
1689#endif
1690
1691 }
1692 }
1693
1694 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001695 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001696 if (hdd_remove_beacon_filter(pAdapter) != 0)
1697 hdd_err("hdd_remove_beacon_filter() failed");
1698
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001699 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301700 uint8_t i;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001701
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07001702 sta_id = pHddStaCtx->broadcast_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001703 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301704 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001705 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status: %d [0x%x]",
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301706 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301707 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001708 }
1709 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301710 /* Clear all the peer sta register with TL. */
Naveen Rawatc45d1622016-07-05 12:20:09 -07001711 for (i = 0; i < MAX_PEERS; i++) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07001712 if (HDD_WLAN_INVALID_STA_ID ==
1713 pHddStaCtx->conn_info.staId[i])
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301714 continue;
1715 sta_id = pHddStaCtx->conn_info.staId[i];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001716 hdd_debug("Deregister StaID %d", sta_id);
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301717 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301718 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001719 hdd_err("hdd_roam_deregister_sta() failed to for staID %d Status: %d [0x%x]",
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301720 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301721 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301722 }
1723 /* set the staid and peer mac as 0, all other
1724 * reset are done in hdd_connRemoveConnectInfo.
1725 */
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05301726 pHddStaCtx->conn_info.staId[i] =
1727 HDD_WLAN_INVALID_STA_ID;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301728 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301729 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301730 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1731 pHddCtx->sta_to_adapter[sta_id] = NULL;
1732 }
1733 } else {
1734 sta_id = pHddStaCtx->conn_info.staId[0];
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001735 hdd_debug("roamResult: %d", roamResult);
Abhishek Singhc9941602016-08-09 16:06:22 +05301736
1737 /* clear scan cache for Link Lost */
Sandeep Puligillaf0b30582017-01-12 08:39:41 -08001738 if (eCSR_ROAM_RESULT_DEAUTH_IND == roamResult ||
1739 eCSR_ROAM_RESULT_DISASSOC_IND == roamResult ||
yeshwanth sriram guntuka951725a2017-03-15 19:33:04 +05301740 eCSR_ROAM_LOSTLINK == roamStatus) {
Abhishek Singhc9941602016-08-09 16:06:22 +05301741 wlan_hdd_cfg80211_update_bss_list(pAdapter,
1742 pHddStaCtx->conn_info.bssId.bytes);
1743 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1744 pHddStaCtx->conn_info.bssId.bytes);
1745 }
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301746 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001747 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001748 /* Clear saved connection information in HDD */
1749 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001750 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
Mukul Sharma3d36c392017-01-18 18:39:12 +05301751 pmo_ucfg_flush_gtk_offload_req(pAdapter->hdd_vdev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001752
1753#ifdef FEATURE_WLAN_TDLS
1754 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1755 wlan_hdd_tdls_disconnection_callback(pAdapter);
1756#endif
1757
Krunal Sonibe766b02016-03-10 13:00:44 -08001758 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1759 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001760 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1761 (pAdapter),
1762 pAdapter->sessionId);
1763 }
Mahesh A Saptasagar6dda2022016-09-03 12:59:09 +05301764 wlan_hdd_clear_link_layer_stats(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 /* Unblock anyone waiting for disconnect to complete */
1766 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05301767 hdd_print_bss_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001768 return status;
1769}
1770
1771/**
1772 * hdd_set_peer_authorized_event() - set peer_authorized_event
1773 * @vdev_id: vdevid
1774 *
1775 * Return: None
1776 */
Jeff Johnson018d7d32016-10-05 14:31:11 -07001777static void hdd_set_peer_authorized_event(uint32_t vdev_id)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001778{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301779 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 hdd_adapter_t *adapter = NULL;
1781
1782 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1783 if (adapter == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001784 hdd_err("Invalid vdev_id");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001785 return;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001786 }
1787 complete(&adapter->sta_authorized_event);
1788}
1789
1790/**
1791 * hdd_change_peer_state() - change peer state
1792 * @pAdapter: HDD adapter
1793 * @sta_state: peer state
1794 * @roam_synch_in_progress: roam synch in progress
1795 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301796 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001797 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301798QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001799 uint8_t sta_id,
1800 enum ol_txrx_peer_state sta_state,
1801 bool roam_synch_in_progress)
1802{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301803 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001804 uint8_t *peer_mac_addr;
Leo Changfdb45c32016-10-28 11:09:23 -07001805 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
1806 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1807 void *peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808
1809 if (!pdev) {
1810 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301811 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001812 }
1813
1814 if (sta_id >= WLAN_MAX_STA_COUNT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001815 hdd_err("Invalid sta id: %d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301816 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001817 }
1818
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001819 peer = cdp_peer_find_by_local_id(soc,
1820 (struct cdp_pdev *)pdev, sta_id);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001821 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301822 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001823
Leo Changfdb45c32016-10-28 11:09:23 -07001824 peer_mac_addr = cdp_peer_get_peer_mac_addr(soc, peer);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001825 if (peer_mac_addr == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001826 hdd_err("peer mac addr is NULL");
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001827 return QDF_STATUS_E_FAULT;
1828 }
1829
Leo Changfdb45c32016-10-28 11:09:23 -07001830 err = cdp_peer_state_update(soc, pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301831 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001832 hdd_err("peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301833 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001834 }
1835#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1836 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301837 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001838#endif
1839
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001840 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1842 /* make sure event is reset */
1843 INIT_COMPLETION(pAdapter->sta_authorized_event);
1844#endif
1845
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001846 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001847 hdd_set_peer_authorized_event,
1848 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301849 if (err != QDF_STATUS_SUCCESS) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001850 hdd_err("Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301851 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001852 }
1853
Krunal Sonibe766b02016-03-10 13:00:44 -08001854 if (pAdapter->device_mode == QDF_STA_MODE ||
1855 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Leo Changfdb45c32016-10-28 11:09:23 -07001857 void *vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001858 unsigned long rc;
1859
1860 /* wait for event from firmware to set the event */
1861 rc = wait_for_completion_timeout(
1862 &pAdapter->sta_authorized_event,
1863 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001864 if (!rc)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001865 hdd_debug("timeout waiting for sta_authorized_event");
Srinivas Girigowda0325c592017-03-25 16:11:25 -07001866
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001867 vdev = (void *)cdp_peer_get_vdev(soc, peer);
1868 cdp_fc_vdev_unpause(soc, (struct cdp_vdev *)vdev,
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001869 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001870#endif
1871 }
1872 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301873 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001874}
1875
1876/**
Kabilan Kannan256e3182017-05-02 16:02:37 -07001877 * hdd_update_dp_vdev_flags() - update datapath vdev flags
1878 * @cbk_data: callback data
1879 * @sta_id: station id
1880 * @vdev_param: vdev parameter
1881 * @is_link_up: link state up or down
1882 *
1883 * Return: QDF status
1884 */
1885QDF_STATUS hdd_update_dp_vdev_flags(void *cbk_data,
1886 uint8_t sta_id,
1887 uint32_t vdev_param,
1888 bool is_link_up)
1889{
1890 struct cdp_vdev *data_vdev;
1891 QDF_STATUS status = QDF_STATUS_SUCCESS;
1892 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1893 hdd_context_t *hdd_ctx;
1894 struct wlan_objmgr_psoc **psoc;
1895
1896 if (!cbk_data)
1897 return status;
1898
1899 psoc = cbk_data;
1900 hdd_ctx = container_of(psoc, hdd_context_t, hdd_psoc);
1901
1902 if (!hdd_ctx->tdls_nap_active)
1903 return status;
1904
1905 data_vdev = cdp_peer_get_vdev_by_sta_id(soc, sta_id);
1906 if (NULL == data_vdev) {
1907 status = QDF_STATUS_E_FAILURE;
1908 return status;
1909 }
1910
1911 cdp_txrx_set_vdev_param(soc, data_vdev, vdev_param, is_link_up);
1912
1913 return status;
1914}
1915
1916/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001917 * hdd_roam_register_sta() - register station
1918 * @pAdapter: pointer to adapter
1919 * @pRoamInfo: pointer to roam info
1920 * @staId: station identifier
1921 * @pPeerMacAddress: peer MAC address
1922 * @pBssDesc: pointer to BSS description
1923 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301924 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001925 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07001926QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001927 tCsrRoamInfo *pRoamInfo,
1928 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301929 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001930 tSirBssDescription *pBssDesc)
1931{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301932 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001933 struct ol_txrx_desc_type staDesc = { 0 };
1934 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001935 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07001936 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
1937 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001938
1939 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301940 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001941
1942 /* Get the Station ID from the one saved during the association */
1943 staDesc.sta_id = staId;
1944
1945 /* set the QoS field appropriately */
1946 if (hdd_wmm_is_active(pAdapter))
1947 staDesc.is_qos_enabled = 1;
1948 else
1949 staDesc.is_qos_enabled = 0;
1950
1951#ifdef FEATURE_WLAN_WAPI
Varun Reddy Yeturudd51e8d2017-05-14 14:51:13 -07001952 hdd_debug("WAPI STA Registered: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001953 pAdapter->wapi_info.fIsWapiSta);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001954 if (pAdapter->wapi_info.fIsWapiSta)
1955 staDesc.is_wapi_supported = 1;
1956 else
1957 staDesc.is_wapi_supported = 0;
1958#endif /* FEATURE_WLAN_WAPI */
1959
Dhanashri Atre50141c52016-04-07 13:15:29 -07001960 /* Register the vdev transmit and receive functions */
1961 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1962 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07001963
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001964 pAdapter->txrx_vdev = (void *)cdp_get_vdev_from_vdev_id(soc,
1965 (struct cdp_pdev *)pdev,
1966 pAdapter->sessionId);
Leo Changfdb45c32016-10-28 11:09:23 -07001967 if (!pAdapter->txrx_vdev) {
1968 hdd_err("%s find vdev fail", __func__);
1969 return QDF_STATUS_E_FAILURE;
1970 }
1971
1972 txrx_ops.tx.tx = NULL;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001973 cdp_vdev_register(soc,
1974 (struct cdp_vdev *)pAdapter->txrx_vdev, pAdapter, &txrx_ops);
Leo Changfdb45c32016-10-28 11:09:23 -07001975 if (!txrx_ops.tx.tx) {
1976 hdd_err("%s vdev register fail", __func__);
1977 return QDF_STATUS_E_FAILURE;
1978 }
1979
Dhanashri Atre50141c52016-04-07 13:15:29 -07001980 pAdapter->tx_fn = txrx_ops.tx.tx;
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08001981 qdf_status = cdp_peer_register(soc,
1982 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301983 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07001984 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07001985 qdf_status, qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301986 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001987 }
1988
1989 if (!pRoamInfo->fAuthRequired) {
1990 /*
1991 * Connections that do not need Upper layer auth, transition
1992 * TLSHIM directly to 'Authenticated' state
1993 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301994 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001995 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001996 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001997#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1998 pRoamInfo->roamSynchInProgress
1999#else
2000 false
2001#endif
2002 );
2003
2004 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002005 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002006 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002007 hdd_debug("ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002008 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302009 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002010 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002011 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002012#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2013 pRoamInfo->roamSynchInProgress
2014#else
2015 false
2016#endif
2017 );
2018 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002019 hdd_objmgr_set_peer_mlme_auth_state(pAdapter->hdd_vdev, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002020 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302021 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002022}
2023
2024/**
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302025 * hdd_send_roamed_ind() - send roamed indication to cfg80211
2026 * @dev: network device
2027 * @bss: cfg80211 roamed bss pointer
2028 * @req_ie: IEs used in reassociation request
2029 * @req_ie_len: Length of the @req_ie
2030 * @resp_ie: IEs received in successful reassociation response
2031 * @resp_ie_len: Length of @resp_ie
2032 *
2033 * Return: none
2034 */
2035#if defined CFG80211_ROAMED_API_UNIFIED || \
2036 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
2037static void hdd_send_roamed_ind(struct net_device *dev,
2038 struct cfg80211_bss *bss, const uint8_t *req_ie,
2039 size_t req_ie_len, const uint8_t *resp_ie,
2040 size_t resp_ie_len)
2041{
2042 struct cfg80211_roam_info info = {0};
2043
2044 info.bss = bss;
2045 info.req_ie = req_ie;
2046 info.req_ie_len = req_ie_len;
2047 info.resp_ie = resp_ie;
2048 info.resp_ie_len = resp_ie_len;
2049 cfg80211_roamed(dev, &info, GFP_KERNEL);
2050}
2051#else
2052static inline void hdd_send_roamed_ind(struct net_device *dev,
2053 struct cfg80211_bss *bss,
2054 const uint8_t *req_ie, size_t req_ie_len,
2055 const uint8_t *resp_ie,
2056 size_t resp_ie_len)
2057{
2058 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
2059 GFP_KERNEL);
2060}
2061#endif
2062
2063/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002064 * hdd_send_re_assoc_event() - send reassoc event
2065 * @dev: pointer to net device
2066 * @pAdapter: pointer to adapter
2067 * @pCsrRoamInfo: pointer to roam info
2068 * @reqRsnIe: pointer to RSN Information element
2069 * @reqRsnLength: length of RSN IE
2070 *
2071 * Return: none
2072 */
2073static void hdd_send_re_assoc_event(struct net_device *dev,
2074 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
2075 uint8_t *reqRsnIe, uint32_t reqRsnLength)
2076{
2077 unsigned int len = 0;
2078 u8 *pFTAssocRsp = NULL;
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002079 uint8_t *rspRsnIe = qdf_mem_malloc(IW_GENERIC_IE_MAX);
2080 uint8_t *assoc_req_ies = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002081 uint32_t rspRsnLength = 0;
2082 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002083 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
2084 uint8_t *buf_ptr, ssid_ie_len;
2085 struct cfg80211_bss *bss = NULL;
2086 uint8_t *final_req_ie = NULL;
2087 tCsrRoamConnectedProfile roam_profile;
2088 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002089 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090
Jeff Johnsonfdb73432016-10-11 08:07:27 -07002091 qdf_mem_zero(&roam_profile, sizeof(roam_profile));
2092
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002093 if (!rspRsnIe) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002094 hdd_err("Unable to allocate RSN IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002095 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002096 }
2097
Naveen Rawat14298b92015-11-25 16:27:41 -08002098 if (!assoc_req_ies) {
2099 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08002100 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08002101 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002102 if (pCsrRoamInfo == NULL) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002103 hdd_err("Invalid CSR roam info");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002104 goto done;
2105 }
2106
2107 if (pCsrRoamInfo->nAssocRspLength == 0) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002108 hdd_err("Assoc rsp length is 0");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002109 goto done;
2110 }
2111
2112 pFTAssocRsp =
2113 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2114 pCsrRoamInfo->nAssocReqLength);
2115 if (pFTAssocRsp == NULL)
2116 goto done;
2117
2118 /* pFTAssocRsp needs to point to the IEs */
2119 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002120 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002121 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002122
2123 /*
2124 * Active session count is decremented upon disconnection, but during
2125 * roaming, there is no disconnect indication and hence active session
2126 * count is not decremented.
2127 * After roaming is completed, active session count is incremented
2128 * as a part of connect indication but effectively after roaming the
2129 * active session count should still be the same and hence upon
2130 * successful reassoc decrement the active session count here.
2131 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002132 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002133 policy_mgr_decr_session_set_pcl(hdd_ctx->hdd_psoc,
2134 pAdapter->device_mode, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135
2136 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
2137 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
2138 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302139 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2140 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002141
2142 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302143 (int)pCsrRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002144 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
2145 &roam_profile);
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302146
2147 bss = hdd_cfg80211_get_bss(pAdapter->wdev.wiphy,
2148 chan, pCsrRoamInfo->bssid.bytes,
2149 &roam_profile.SSID.ssId[0],
2150 roam_profile.SSID.length);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002151
2152 if (bss == NULL)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002153 hdd_warn("Get BSS returned NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002154 buf_ptr = buf_ssid_ie;
2155 *buf_ptr = SIR_MAC_SSID_EID;
2156 buf_ptr++;
2157 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
2158 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302159 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002160 roam_profile.SSID.length);
2161 ssid_ie_len = 2 + roam_profile.SSID.length;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002162 hdd_debug("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302163 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002164 buf_ssid_ie, ssid_ie_len);
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002165 final_req_ie = qdf_mem_malloc(IW_GENERIC_IE_MAX);
Kapil Gupta8731e812017-07-11 18:42:39 +05302166 if (final_req_ie == NULL) {
2167 if (bss)
2168 cfg80211_put_bss(pAdapter->wdev.wiphy, bss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002169 goto done;
Kapil Gupta8731e812017-07-11 18:42:39 +05302170 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002171 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302172 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002173 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302174 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
2175 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
2176 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002177 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002178 hdd_debug("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302179 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08002180 final_req_ie, (ssid_ie_len + reqRsnLength));
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302181 hdd_send_roamed_ind(dev, bss, final_req_ie,
2182 (ssid_ie_len + reqRsnLength), rspRsnIe,
2183 rspRsnLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002184
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302185 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08002186 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
2187 pCsrRoamInfo->nAssocReqLength);
2188
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002189 hdd_debug("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302190 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002191 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
2192
Prakash Dhavali989127d2016-11-29 14:56:44 +05302193 wlan_hdd_send_roam_auth_event(pAdapter, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08002194 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
2195 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002196 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002197done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08002198 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002199 if (final_req_ie)
Mahesh Kumar Kalikot Veetil9c656182016-11-02 10:28:03 -07002200 qdf_mem_free(final_req_ie);
2201 qdf_mem_free(rspRsnIe);
2202 qdf_mem_free(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002203}
2204
2205/**
Govind Singhedc5cda2015-10-23 17:11:35 +05302206 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002207 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05302208 *
2209 * Return: roam sync status if roaming offloaded else false
2210 */
2211#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002212bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05302213{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002214 if (roaminfo)
2215 return roaminfo->roamSynchInProgress;
2216 else
2217 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05302218}
2219#endif
2220
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002221/**
2222 * hdd_get_ibss_peer_staid() - get sta id for IBSS peer
2223 * @hddstactx: pointer to HDD sta context
2224 * @roaminfo: pointer to roaminfo structure
2225 *
2226 * This function returns staid for IBSS peer. If peer is broadcast
2227 * MAC address return self staid(0) else find the peer sta id of
2228 * the peer.
2229 *
2230 * Return: sta_id (HDD_WLAN_INVALID_STA_ID if peer not found).
2231 */
2232static uint8_t hdd_get_ibss_peer_staid(hdd_station_ctx_t *hddstactx,
2233 tCsrRoamInfo *roaminfo)
2234{
2235 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
2236 QDF_STATUS status;
2237
2238 if (qdf_is_macaddr_broadcast(&roaminfo->peerMac)) {
2239 staid = 0;
2240 } else {
2241 status = hdd_get_peer_sta_id(hddstactx,
2242 &roaminfo->peerMac, &staid);
2243 if (status != QDF_STATUS_SUCCESS) {
2244 hdd_err("Unable to find staid for " MAC_ADDRESS_STR,
2245 MAC_ADDR_ARRAY(roaminfo->peerMac.bytes));
2246 }
2247 }
2248
2249 return staid;
2250}
Govind Singhedc5cda2015-10-23 17:11:35 +05302251
2252/**
2253 * hdd_change_sta_state_authenticated()-
2254 * This function changes STA state to authenticated
2255 * @adapter: pointer to the adapter structure.
2256 * @roaminfo: pointer to the RoamInfo structure.
2257 *
2258 * This is called from hdd_RoamSetKeyCompleteHandler
2259 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
2260 *
2261 * Return: 0 on success and errno on failure
2262 */
2263static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
2264 tCsrRoamInfo *roaminfo)
2265{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002266 QDF_STATUS status;
Dustin Brownf660fb42016-09-09 12:04:00 -07002267 uint32_t timeout;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002268 uint8_t staid = HDD_WLAN_INVALID_STA_ID;
Govind Singhedc5cda2015-10-23 17:11:35 +05302269 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002270 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Govind Singhedc5cda2015-10-23 17:11:35 +05302271
Dustin Brownf660fb42016-09-09 12:04:00 -07002272 timeout = hddstactx->hdd_ReassocScenario ?
2273 AUTO_PS_ENTRY_TIMER_DEFAULT_VALUE :
Kiran Kumar Lokere0ac679c2016-11-17 17:43:36 -08002274 hdd_ctx->config->auto_bmps_timer_val * 1000;
Dustin Brownf660fb42016-09-09 12:04:00 -07002275
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002276 if (QDF_IBSS_MODE == adapter->device_mode)
2277 staid = hdd_get_ibss_peer_staid(hddstactx, roaminfo);
2278 else
2279 staid = hddstactx->conn_info.staId[0];
2280
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002281 hdd_debug("Changing Peer state to AUTHENTICATED for StaId = %d", staid);
Govind Singhedc5cda2015-10-23 17:11:35 +05302282
2283 /* Connections that do not need Upper layer authentication,
2284 * transition TL to 'Authenticated' state after the keys are set
2285 */
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002286 status = hdd_change_peer_state(adapter, staid, OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05302287 hdd_is_roam_sync_in_progress(roaminfo));
2288 hdd_conn_set_authenticated(adapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002289 hdd_objmgr_set_peer_mlme_auth_state(adapter->hdd_vdev, true);
2290
Krunal Sonibe766b02016-03-10 13:00:44 -08002291 if ((QDF_STA_MODE == adapter->device_mode) ||
2292 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05302293 sme_ps_enable_auto_ps_timer(
2294 WLAN_HDD_GET_HAL_CTX(adapter),
2295 adapter->sessionId,
Dustin Brown84411b02017-07-21 16:44:44 -07002296 timeout);
Govind Singhedc5cda2015-10-23 17:11:35 +05302297 }
2298
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002299 return qdf_status_to_os_return(status);
2300}
2301
2302/**
2303 * hdd_is_key_install_required_for_ibss() - check encryption type to identify
2304 * if key installation is required
2305 * @encr_type: encryption type
2306 *
2307 * Return: true if key installation is required and false otherwise.
2308 */
2309static inline bool hdd_is_key_install_required_for_ibss(
2310 eCsrEncryptionType encr_type)
2311{
2312 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == encr_type ||
2313 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == encr_type ||
2314 eCSR_ENCRYPT_TYPE_TKIP == encr_type ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05302315 eCSR_ENCRYPT_TYPE_AES_GCMP == encr_type ||
2316 eCSR_ENCRYPT_TYPE_AES_GCMP_256 == encr_type ||
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002317 eCSR_ENCRYPT_TYPE_AES == encr_type)
2318 return true;
2319 else
2320 return false;
2321}
2322
2323/**
2324 * hdd_change_peer_state_after_set_key() - change the peer state on set key
2325 * complete
2326 * @adapter: pointer to HDD adapter
2327 * @roaminfo: pointer to roam info
2328 * @roam_result: roam result
2329 *
2330 * Peer state will be OL_TXRX_PEER_STATE_CONN until set key is complete.
2331 * This function checks for the successful set key completion and update
2332 * the peer state to OL_TXRX_PEER_STATE_AUTH.
2333 *
2334 * Return: None
2335 */
2336static void hdd_change_peer_state_after_set_key(hdd_adapter_t *adapter,
2337 tCsrRoamInfo *roaminfo, eCsrRoamResult roam_result)
2338{
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002339 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
2340 eCsrEncryptionType encr_type = hdd_sta_ctx->conn_info.ucEncryptionType;
2341
2342 /*
2343 * If the security mode is one of the following, IBSS peer will be
2344 * waiting in CONN state and we will move the peer state to AUTH
2345 * here. For non-secure connection, no need to wait for set-key complete
2346 * peer will be moved to AUTH in hdd_roam_register_sta.
2347 */
2348 if (QDF_IBSS_MODE == adapter->device_mode) {
2349 if (hdd_is_key_install_required_for_ibss(encr_type))
2350 hdd_change_sta_state_authenticated(adapter, roaminfo);
2351
2352 return;
2353 }
2354
2355 if (eCSR_ROAM_RESULT_AUTHENTICATED == roam_result) {
2356 hdd_sta_ctx->conn_info.gtk_installed = true;
2357 /*
2358 * PTK exchange happens in preauthentication itself if key_mgmt
2359 * is FT-PSK, ptk_installed was false as there is no set PTK
2360 * after roaming. STA TL state moves to authenticated only if
2361 * ptk_installed is true. So, make ptk_installed to true in
2362 * case of 11R roaming.
2363 */
yeshwanth sriram guntukaa1ba9a22017-02-28 16:17:32 +05302364 if (sme_neighbor_roam_is11r_assoc(WLAN_HDD_GET_HAL_CTX(adapter),
2365 adapter->sessionId))
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002366 hdd_sta_ctx->conn_info.ptk_installed = true;
2367 } else {
2368 hdd_sta_ctx->conn_info.ptk_installed = true;
2369 }
2370
2371 /* In WPA case move STA to authenticated when ptk is installed. Earlier
2372 * in WEP case STA was moved to AUTHENTICATED prior to setting the
2373 * unicast key and it was resulting in sending few un-encrypted packet.
2374 * Now in WEP case STA state will be moved to AUTHENTICATED after we
2375 * set the unicast and broadcast key.
2376 */
2377 if ((encr_type == eCSR_ENCRYPT_TYPE_WEP40) ||
2378 (encr_type == eCSR_ENCRYPT_TYPE_WEP104) ||
2379 (encr_type == eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2380 (encr_type == eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
2381 if (hdd_sta_ctx->conn_info.gtk_installed &&
2382 hdd_sta_ctx->conn_info.ptk_installed)
2383 hdd_change_sta_state_authenticated(adapter, roaminfo);
2384 } else if (hdd_sta_ctx->conn_info.ptk_installed) {
2385 hdd_change_sta_state_authenticated(adapter, roaminfo);
2386 }
2387
2388 if (hdd_sta_ctx->conn_info.gtk_installed &&
2389 hdd_sta_ctx->conn_info.ptk_installed) {
2390 hdd_sta_ctx->conn_info.gtk_installed = false;
2391 hdd_sta_ctx->conn_info.ptk_installed = false;
2392 }
2393
2394 hdd_sta_ctx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2395
2396 return;
Govind Singhedc5cda2015-10-23 17:11:35 +05302397}
2398
2399/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400 * hdd_roam_set_key_complete_handler() - Update the security parameters
2401 * @pAdapter: pointer to adapter
2402 * @pRoamInfo: pointer to roam info
2403 * @roamId: roam id
2404 * @roamStatus: roam status
2405 * @roamResult: roam result
2406 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302407 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302409static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410 tCsrRoamInfo *pRoamInfo,
2411 uint32_t roamId,
2412 eRoamCmdStatus roamStatus,
2413 eCsrRoamResult roamResult)
2414{
2415 eCsrEncryptionType connectedCipherAlgo;
2416 bool fConnected = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002417 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05302418
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002419 ENTER();
2420
2421 if (NULL == pRoamInfo) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002422 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302423 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002424 }
2425 /*
2426 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
2427 * then go to 'authenticated'. For all other authentication types
2428 * (those that do not require upper layer authentication) we can put TL
2429 * directly into 'authenticated' state.
2430 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002431 hdd_info("Set Key completion roamStatus =%d roamResult=%d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002432 MAC_ADDRESS_STR, roamStatus, roamResult,
2433 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
2434
2435 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
2436 &connectedCipherAlgo);
2437 if (fConnected) {
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08002438 hdd_change_peer_state_after_set_key(pAdapter, pRoamInfo,
2439 roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002440 } else {
2441 /*
2442 * possible disassoc after issuing set key and waiting
2443 * set key complete.
2444 */
2445 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2446 }
2447
2448 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302449 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002450}
2451
2452/**
2453 * hdd_perform_roam_set_key_complete() - perform set key complete
2454 * @pAdapter: pointer to adapter
2455 *
2456 * Return: none
2457 */
2458void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
2459{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302460 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002461 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2462 tCsrRoamInfo roamInfo;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07002463
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002464 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302465 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302466 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302467 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302468 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002469
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302470 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002471 hdd_roam_set_key_complete_handler(pAdapter,
2472 &roamInfo,
2473 pHddStaCtx->roam_info.roamId,
2474 pHddStaCtx->roam_info.roamStatus,
2475 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05302476 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002477 hdd_err("Set Key complete failure");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002478
2479 pHddStaCtx->roam_info.deferKeyComplete = false;
2480}
2481
2482/**
2483 * hdd_association_completion_handler() - association completion handler
2484 * @pAdapter: pointer to adapter
2485 * @pRoamInfo: pointer to roam info
2486 * @roamId: roam id
2487 * @roamStatus: roam status
2488 * @roamResult: roam result
2489 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302490 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002491 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302492static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002493 tCsrRoamInfo *pRoamInfo,
2494 uint32_t roamId,
2495 eRoamCmdStatus roamStatus,
2496 eCsrRoamResult roamResult)
2497{
2498 struct net_device *dev = pAdapter->dev;
2499 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2500 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302501 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002502 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
Krunal Soni364e0872017-05-10 21:24:34 -07002503 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN, ie_len;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002504 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002505 bool hddDisconInProgress = false;
2506 unsigned long rc;
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302507 tSirResultCodes timeout_reason = 0;
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302508 bool ok;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002509
2510 if (!pHddCtx) {
2511 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302512 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002513 }
2514
Anurag Chouhan2c4e0a12016-09-12 14:52:45 +05302515 /* validate config */
2516 if (!pHddCtx->config) {
2517 hdd_err("config is NULL");
2518 return QDF_STATUS_E_NULL_VALUE;
2519 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002520 /* HDD has initiated disconnect, do not send connect result indication
2521 * to kernel as it will be handled by __cfg80211_disconnect.
2522 */
Edhar, Mahesh Kumar732f6982016-07-01 11:23:06 +05302523 if (((eConnectionState_Disconnecting ==
2524 pHddStaCtx->conn_info.connState) ||
2525 (eConnectionState_NotConnected ==
2526 pHddStaCtx->conn_info.connState)) &&
2527 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2528 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07002529 hdd_info("hddDisconInProgress state=%d, result=%d, status=%d",
2530 pHddStaCtx->conn_info.connState,
2531 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002532 hddDisconInProgress = true;
2533 }
2534
2535 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
2536 if (NULL == pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002537 hdd_err("pRoamInfo is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302538 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002539 }
2540 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002541 hdd_conn_set_connection_state(pAdapter,
2542 eConnectionState_Associated);
2543 }
Abhishek Singh07c627e2017-03-20 17:56:34 +05302544
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002545 /* Save the connection info from CSR... */
2546 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
2547 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07002548
2549 if (hdd_add_beacon_filter(pAdapter) != 0)
2550 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002551#ifdef FEATURE_WLAN_WAPI
2552 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2553 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
2554 || pRoamInfo->u.pConnectedProfile->AuthType ==
2555 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
2556 pAdapter->wapi_info.fIsWapiSta = 1;
2557 } else {
2558 pAdapter->wapi_info.fIsWapiSta = 0;
2559 }
2560#endif /* FEATURE_WLAN_WAPI */
Krunal Soni364e0872017-05-10 21:24:34 -07002561 hdd_debug("bss_descr[%d] devicemode[%d]", !!pRoamInfo->pBssDesc,
2562 pAdapter->device_mode);
2563 if ((QDF_STA_MODE == pAdapter->device_mode) &&
2564 pRoamInfo->pBssDesc) {
2565 ie_len = GET_IE_LEN_IN_BSS(pRoamInfo->pBssDesc->length);
2566 pHddStaCtx->ap_supports_immediate_power_save =
2567 wlan_hdd_is_ap_supports_immediate_power_save(
2568 (uint8_t *) pRoamInfo->pBssDesc->ieFields,
2569 ie_len);
2570 hdd_debug("ap_supports_immediate_power_save flag [%d]",
2571 pHddStaCtx->ap_supports_immediate_power_save);
2572 }
2573
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002574 /* Indicate 'connect' status to user space */
2575 hdd_send_association_event(dev, pRoamInfo);
2576
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002577 if (policy_mgr_is_mcc_in_24G(pHddCtx->hdd_psoc)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002578 if (pHddCtx->miracast_value)
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002579 wlan_hdd_set_mas(pAdapter,
2580 pHddCtx->miracast_value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002581 }
2582
2583 /* Initialize the Linkup event completion variable */
2584 INIT_COMPLETION(pAdapter->linkup_event_var);
2585
2586 /*
2587 * Sometimes Switching ON the Carrier is taking time to activate
2588 * the device properly. Before allowing any packet to go up to
2589 * the application, device activation has to be ensured for
2590 * proper queue mapping by the kernel. we have registered net
2591 * device notifier for device change notification. With this we
2592 * will come to know that the device is getting
2593 * activated properly.
2594 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002595 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002596 /*
2597 * Enable Linkup Event Servicing which allows the net
2598 * device notifier to set the linkup event variable.
2599 */
2600 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002601
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002602 /* Switch on the Carrier to activate the device */
2603 wlan_hdd_netif_queue_control(pAdapter,
2604 WLAN_NETIF_CARRIER_ON,
2605 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002606
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002607 /*
2608 * Wait for the Link to up to ensure all the queues
2609 * are set properly by the kernel.
2610 */
2611 rc = wait_for_completion_timeout(
2612 &pAdapter->linkup_event_var,
2613 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
2614 );
2615 if (!rc)
2616 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002617
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002618 /*
2619 * Disable Linkup Event Servicing - no more service
2620 * required from the net device notifier call.
2621 */
2622 pAdapter->isLinkUpSvcNeeded = false;
2623 } else {
2624 pHddStaCtx->ft_carrier_on = false;
2625 ft_carrier_on = true;
2626 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002627 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
2628 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2629 else
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002630 hdd_err("Wrong Staid: %d", pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002631
2632 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2633
2634 if (hdd_ipa_is_enabled(pHddCtx))
2635 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
Mohit Khannafa99aea2016-05-12 21:43:13 -07002636 HDD_IPA_STA_CONNECT,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002637 pRoamInfo->bssid.bytes);
2638
2639#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
2640 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
2641#endif
2642
Ajit Pal Singh7983af62017-04-18 16:54:09 +05302643 hdd_debug("check if STA chan ok for DNBS");
2644 if (policy_mgr_is_chan_ok_for_dnbs(pHddCtx->hdd_psoc,
2645 pHddStaCtx->conn_info.operationChannel,
2646 &ok)) {
2647 hdd_err("Unable to check DNBS eligibility for chan:%d",
2648 pHddStaCtx->conn_info.operationChannel);
2649 return QDF_STATUS_E_FAILURE;
2650 }
2651
2652 if (!ok) {
2653 hdd_err("Chan:%d not suitable for DNBS",
2654 pHddStaCtx->conn_info.operationChannel);
2655 wlan_hdd_netif_queue_control(pAdapter,
2656 WLAN_NETIF_CARRIER_OFF,
2657 WLAN_CONTROL_PATH);
2658 if (!hddDisconInProgress) {
2659 hdd_err("Disconnecting...");
2660 sme_roam_disconnect(
2661 WLAN_HDD_GET_HAL_CTX(pAdapter),
2662 pAdapter->sessionId,
2663 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2664 }
2665 return QDF_STATUS_E_FAILURE;
2666 }
2667
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002668 hdd_debug("check for SAP restart");
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002669 policy_mgr_check_concurrent_intf_and_restart_sap(
2670 pHddCtx->hdd_psoc);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002671
Nirav Shah1da77682016-05-03 20:16:39 +05302672 DPTRACE(qdf_dp_trace_mgmt_pkt(QDF_DP_TRACE_MGMT_PACKET_RECORD,
2673 pAdapter->sessionId,
Venkata Sharath Chandra Manchala0b9fc632017-05-15 14:35:15 -07002674 QDF_TRACE_DEFAULT_PDEV_ID,
Nirav Shah1da77682016-05-03 20:16:39 +05302675 QDF_PROTO_TYPE_MGMT, QDF_PROTO_MGMT_ASSOC));
2676
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002677 /*
2678 * For reassoc, the station is already registered, all we need
2679 * is to change the state of the STA in TL.
2680 * If authentication is required (WPA/WPA2/DWEP), change TL to
2681 * CONNECTED instead of AUTHENTICATED.
2682 */
2683 if (!pRoamInfo->fReassocReq) {
2684 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002685 u8 *pFTAssocRsp = NULL;
2686 unsigned int assocRsplen = 0;
2687 u8 *pFTAssocReq = NULL;
2688 unsigned int assocReqlen = 0;
2689 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
2691 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
2692
2693 /* add bss_id to cfg80211 data base */
2694 bss =
2695 wlan_hdd_cfg80211_update_bss_db(pAdapter,
2696 pRoamInfo);
2697 if (NULL == bss) {
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302698 hdd_err("wlan: Not able to create BSS entry");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002699 wlan_hdd_netif_queue_control(pAdapter,
2700 WLAN_NETIF_CARRIER_OFF,
2701 WLAN_CONTROL_PATH);
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302702 if (!hddDisconInProgress) {
2703 /*
2704 * Here driver was not able to add bss
2705 * in cfg80211 database this can happen
2706 * if connected channel is not valid,
2707 * i.e reg domain was changed during
2708 * connection. Queue disconnect for the
2709 * session if disconnect is not in
2710 * progress.
2711 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002712 hdd_debug("Disconnecting...");
Abhishek Singhcdcc5e72016-09-13 12:45:10 +05302713 sme_roam_disconnect(
2714 WLAN_HDD_GET_HAL_CTX(pAdapter),
2715 pAdapter->sessionId,
2716 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2717 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302718 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002719 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002720 if (pRoamInfo->u.pConnectedProfile->AuthType ==
2721 eCSR_AUTH_TYPE_FT_RSN
2722 || pRoamInfo->u.pConnectedProfile->AuthType ==
2723 eCSR_AUTH_TYPE_FT_RSN_PSK) {
2724
2725 /* Association Response */
2726 pFTAssocRsp =
2727 (u8 *) (pRoamInfo->pbFrames +
2728 pRoamInfo->nBeaconLength +
2729 pRoamInfo->nAssocReqLength);
2730 if (pFTAssocRsp != NULL) {
2731 /*
2732 * pFTAssocRsp needs to point to the IEs
2733 */
2734 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002735 hdd_debug("AssocRsp is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002736 (unsigned int)pFTAssocRsp[0],
2737 (unsigned int)pFTAssocRsp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002738 assocRsplen =
2739 pRoamInfo->nAssocRspLength -
2740 FT_ASSOC_RSP_IES_OFFSET;
2741 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002742 hdd_debug("AssocRsp is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002743 assocRsplen = 0;
2744 }
2745
2746 /* Association Request */
2747 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
2748 pRoamInfo->nBeaconLength);
2749 if (pFTAssocReq != NULL) {
2750 if (!ft_carrier_on) {
2751 /*
2752 * pFTAssocReq needs to point to
2753 * the IEs
2754 */
2755 pFTAssocReq +=
2756 FT_ASSOC_REQ_IES_OFFSET;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002757 hdd_debug("pFTAssocReq is now at %02x%02x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002758 (unsigned int)
2759 pFTAssocReq[0],
2760 (unsigned int)
2761 pFTAssocReq[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002762 assocReqlen =
2763 pRoamInfo->nAssocReqLength -
2764 FT_ASSOC_REQ_IES_OFFSET;
2765 } else {
2766 /*
2767 * This should contain only the
2768 * FTIEs
2769 */
2770 assocReqlen =
2771 pRoamInfo->nAssocReqLength;
2772 }
2773 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002774 hdd_debug("AssocReq is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002775 assocReqlen = 0;
2776 }
2777
2778 if (ft_carrier_on) {
Will Huang03b54ee2017-06-21 10:57:05 +08002779 if (!hddDisconInProgress &&
2780 pRoamInfo->pBssDesc) {
Abhishek Singhb5e38ef2017-01-02 12:09:34 +05302781 struct cfg80211_bss *roam_bss;
2782
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002783 /*
2784 * After roaming is completed,
2785 * active session count is
2786 * incremented as a part of
2787 * connect indication but
2788 * effectively the active
2789 * session count should still
2790 * be the same and hence upon
2791 * successful reassoc
2792 * decrement the active session
2793 * count here.
2794 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002795 if (!hdd_is_roam_sync_in_progress
2796 (pRoamInfo))
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08002797 policy_mgr_decr_session_set_pcl(
2798 pHddCtx->hdd_psoc,
2799 pAdapter->device_mode,
2800 pAdapter->sessionId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002801 hdd_debug("ft_carrier_on is %d, sending roamed indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002802 ft_carrier_on);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002803 chan =
2804 ieee80211_get_channel
2805 (pAdapter->wdev.wiphy,
2806 (int)pRoamInfo->pBssDesc->
2807 channelId);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002808 hdd_debug(
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002809 "assocReqlen %d assocRsplen %d",
2810 assocReqlen,
2811 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002812
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002813 hdd_debug(
Naveen Rawat14298b92015-11-25 16:27:41 -08002814 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302815 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302816 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302817 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002818 pFTAssocReq,
2819 assocReqlen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302820 roam_bss =
2821 hdd_cfg80211_get_bss(
2822 pAdapter->wdev.wiphy,
2823 chan,
2824 pRoamInfo->bssid.bytes,
2825 pRoamInfo->u.
2826 pConnectedProfile->SSID.ssId,
2827 pRoamInfo->u.
2828 pConnectedProfile->SSID.length);
Vidyullatha Kanchanapallyf9a0c382017-07-26 17:55:59 +05302829 hdd_send_roamed_ind(
2830 dev,
2831 roam_bss,
2832 pFTAssocReq,
2833 assocReqlen,
2834 pFTAssocRsp,
2835 assocRsplen);
Abhishek Singh533c9da2017-05-04 10:23:34 +05302836 wlan_hdd_send_roam_auth_event(
2837 pAdapter,
2838 pRoamInfo->bssid.bytes,
2839 pFTAssocReq,
2840 assocReqlen,
2841 pFTAssocRsp,
2842 assocRsplen,
2843 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002844 }
2845 if (sme_get_ftptk_state
2846 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2847 pAdapter->sessionId)) {
2848 sme_set_ftptk_state
2849 (WLAN_HDD_GET_HAL_CTX
2850 (pAdapter),
2851 pAdapter->sessionId,
2852 false);
2853 pRoamInfo->fAuthRequired =
2854 false;
2855
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302856 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002857 roam_info.bssid,
2858 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302859 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302860 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002861 roam_info.peerMac,
2862 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302863 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002864 pHddStaCtx->roam_info.roamId =
2865 roamId;
2866 pHddStaCtx->roam_info.
2867 roamStatus = roamStatus;
2868 pHddStaCtx->roam_info.
2869 deferKeyComplete = true;
2870 }
2871 } else if (!hddDisconInProgress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002872 hdd_debug("ft_carrier_on is %d, sending connect indication",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002873 ft_carrier_on);
Anurag Chouhanc4092922016-09-08 15:56:11 +05302874 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302875 pRoamInfo->
2876 bssid.bytes,
2877 pRoamInfo,
2878 pFTAssocReq,
2879 assocReqlen,
2880 pFTAssocRsp,
2881 assocRsplen,
2882 WLAN_STATUS_SUCCESS,
2883 GFP_KERNEL,
2884 false,
2885 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002886 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002887 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002888 /*
2889 * wpa supplicant expecting WPA/RSN IE in
2890 * connect result.
2891 */
2892 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2893 (pAdapter),
2894 pAdapter->sessionId,
2895 &reqRsnLength,
2896 reqRsnIe);
2897
2898 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2899 (pAdapter),
2900 pAdapter->sessionId,
2901 &rspRsnLength,
2902 rspRsnIe);
2903 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002904 if (ft_carrier_on)
2905 hdd_send_re_assoc_event(dev,
2906 pAdapter,
2907 pRoamInfo,
2908 reqRsnIe,
2909 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002910 else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002911 hdd_debug("sending connect indication to nl80211:for bssid "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002912 MAC_ADDRESS_STR
2913 " result:%d and Status:%d",
2914 MAC_ADDR_ARRAY
2915 (pRoamInfo->bssid.bytes),
2916 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002917
2918 /* inform connect result to nl80211 */
Anurag Chouhanc4092922016-09-08 15:56:11 +05302919 hdd_connect_result(dev,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05302920 pRoamInfo->
2921 bssid.bytes,
2922 pRoamInfo,
2923 reqRsnIe,
2924 reqRsnLength,
2925 rspRsnIe,
2926 rspRsnLength,
2927 WLAN_STATUS_SUCCESS,
2928 GFP_KERNEL,
2929 false,
2930 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002931 }
2932 }
2933 }
2934 if (!hddDisconInProgress) {
2935 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002937 bss);
2938
2939 /*
2940 * Perform any WMM-related association
2941 * processing.
2942 */
2943 hdd_wmm_assoc(pAdapter, pRoamInfo,
2944 eCSR_BSS_TYPE_INFRASTRUCTURE);
2945
2946 /*
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002947 * Register the Station with DP after associated
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002948 */
Krishna Kumaar Natarajan6736d812017-02-01 16:36:30 -08002949 qdf_status = hdd_roam_register_sta(pAdapter,
2950 pRoamInfo,
2951 pHddStaCtx->conn_info.staId[0],
2952 NULL, pRoamInfo->pBssDesc);
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002953 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954 wlan_hdd_netif_queue_control(pAdapter,
2955 WLAN_WAKE_ALL_NETIF_QUEUE,
2956 WLAN_CONTROL_PATH);
2957
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 }
2959 } else {
2960 /*
2961 * wpa supplicant expecting WPA/RSN IE in connect result
2962 * in case of reassociation also need to indicate it to
2963 * supplicant.
2964 */
2965 csr_roam_get_wpa_rsn_req_ie(
2966 WLAN_HDD_GET_HAL_CTX(pAdapter),
2967 pAdapter->sessionId,
2968 &reqRsnLength, reqRsnIe);
2969
2970 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2971 reqRsnIe, reqRsnLength);
2972 /* Reassoc successfully */
2973 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302974 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002975 hdd_change_peer_state(pAdapter,
2976 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002977 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002978#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2979 pRoamInfo->roamSynchInProgress
2980#else
2981 false
2982#endif
2983 );
2984 hdd_conn_set_authenticated(pAdapter, false);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07002985 hdd_objmgr_set_peer_mlme_auth_state(
2986 pAdapter->hdd_vdev,
2987 false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002988 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07002989 hdd_debug("staId: %d Changing TL state to AUTHENTICATED",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07002990 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302991 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002992 hdd_change_peer_state(pAdapter,
2993 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002994 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002995#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2996 pRoamInfo->roamSynchInProgress
2997#else
2998 false
2999#endif
3000 );
3001 hdd_conn_set_authenticated(pAdapter, true);
Kabilan Kannanf56f9d52017-04-05 03:31:34 -07003002 hdd_objmgr_set_peer_mlme_auth_state(
3003 pAdapter->hdd_vdev,
3004 true);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003005 }
3006
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303007 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003008 /*
3009 * Perform any WMM-related association
3010 * processing
3011 */
3012 hdd_wmm_assoc(pAdapter, pRoamInfo,
3013 eCSR_BSS_TYPE_INFRASTRUCTURE);
3014 }
3015
3016 /* Start the tx queues */
3017#ifdef WLAN_FEATURE_ROAM_OFFLOAD
3018 if (pRoamInfo->roamSynchInProgress)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003019 hdd_debug("LFR3:netif_tx_wake_all_queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003020#endif
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003021 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003022 wlan_hdd_netif_queue_control(pAdapter,
3023 WLAN_WAKE_ALL_NETIF_QUEUE,
3024 WLAN_CONTROL_PATH);
3025 }
3026
Padma, Santhosh Kumar724f63d2016-08-09 16:04:31 +05303027#ifdef FEATURE_WLAN_TDLS
3028 wlan_hdd_tdls_connection_callback(pAdapter);
3029#endif
3030
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303031 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003032 hdd_err("STA register with TL failed status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303033 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003034 }
3035#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303036 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003037 sizeof(pAdapter->hdd_stats.hddPmfStats));
3038#endif
3039 } else {
Abhishek Singha84d3952016-09-13 13:45:05 +05303040 bool connect_timeout = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003041 hdd_wext_state_t *pWextState =
3042 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3043 if (pRoamInfo)
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303044 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003045 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303046 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3047 roamResult, roamStatus);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003048 else
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303049 hdd_err("wlan: connection failed with " MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003050 " result: %d and Status: %d",
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303051 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3052 roamResult, roamStatus);
Abhishek Singhc9941602016-08-09 16:06:22 +05303053
3054 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
3055 (pRoamInfo &&
3056 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
3057 pRoamInfo->statusCode) ||
3058 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
3059 pRoamInfo->statusCode) ||
3060 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
3061 pRoamInfo->statusCode)))) {
3062 wlan_hdd_cfg80211_update_bss_list(pAdapter,
3063 pRoamInfo ?
3064 pRoamInfo->bssid.bytes :
3065 pWextState->req_bssId.bytes);
3066 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
3067 pRoamInfo ?
3068 pRoamInfo->bssid.bytes :
3069 pWextState->req_bssId.bytes);
Abhishek Singha84d3952016-09-13 13:45:05 +05303070 connect_timeout = true;
Abhishek Singhc9941602016-08-09 16:06:22 +05303071 }
3072
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003073 /*
3074 * CR465478: Only send up a connection failure result when CSR
3075 * has completed operation - with a ASSOCIATION_FAILURE status.
3076 */
3077 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
3078 && !hddDisconInProgress) {
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303079 if (pRoamInfo) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003080 hdd_err("send connect failure to nl80211: for bssid "
3081 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003082 " result: %d and Status: %d reasoncode: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003083 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3084 roamResult, roamStatus,
3085 pRoamInfo->reasonCode);
Anurag Chouhan5de8d172016-07-13 14:44:28 +05303086 pHddStaCtx->conn_info.assoc_status_code =
3087 pRoamInfo->statusCode;
Jeff Johnson03294f12016-12-09 17:10:24 -08003088 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003089 hdd_err("connect failed: for bssid "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003090 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003091 " result: %d and status: %d ",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003092 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
3093 roamResult, roamStatus);
Jeff Johnson03294f12016-12-09 17:10:24 -08003094 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003095 hdd_debug("Invoking packetdump deregistration API");
Himanshu Agarwalf65bd4c2016-12-05 17:21:12 +05303096 wlan_deregister_txrx_packetdump();
3097
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 /* inform association failure event to nl80211 */
3099 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
3100 roamResult) {
3101 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303102 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003103 pRoamInfo->bssid.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303104 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003105 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303106 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303107 connect_timeout,
3108 pRoamInfo->statusCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003109 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303110 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003111 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303112 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003113 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singha84d3952016-09-13 13:45:05 +05303114 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303115 connect_timeout,
3116 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003117 } else {
Wu Gao77d28352016-11-23 17:50:56 +08003118 if (pRoamInfo)
Anurag Chouhanc4092922016-09-08 15:56:11 +05303119 hdd_connect_result(dev,
3120 pRoamInfo->bssid.bytes,
3121 NULL, NULL, 0, NULL, 0,
Wu Gao77d28352016-11-23 17:50:56 +08003122 pRoamInfo->reasonCode ?
Abhishek Singhac2be142015-12-03 16:16:25 +05303123 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003124 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303125 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303126 connect_timeout,
3127 pRoamInfo->statusCode);
Wu Gao77d28352016-11-23 17:50:56 +08003128 else
Anurag Chouhanc4092922016-09-08 15:56:11 +05303129 hdd_connect_result(dev,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003130 pWextState->req_bssId.bytes,
Anurag Chouhanc4092922016-09-08 15:56:11 +05303131 NULL, NULL, 0, NULL, 0,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003132 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303133 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303134 connect_timeout,
3135 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003136 }
Abhishek Singhac2be142015-12-03 16:16:25 +05303137 hdd_clear_roam_profile_ie(pAdapter);
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003138 } else if ((eCSR_ROAM_CANCELLED == roamStatus
3139 && !hddDisconInProgress)) {
Abhishek Singha84d3952016-09-13 13:45:05 +05303140 hdd_connect_result(dev,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003141 pWextState->req_bssId.bytes,
Abhishek Singha84d3952016-09-13 13:45:05 +05303142 NULL, NULL, 0, NULL, 0,
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003143 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singha84d3952016-09-13 13:45:05 +05303144 GFP_KERNEL,
yeshwanth sriram guntukaaf7b73f2017-02-22 17:35:32 +05303145 connect_timeout,
3146 timeout_reason);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003147 }
3148
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003149 /*
3150 * Set connection state to eConnectionState_NotConnected only
3151 * when CSR has completed operation - with a
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003152 * ASSOCIATION_FAILURE or eCSR_ROAM_CANCELLED status.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003153 */
Sandeep Puligilla0241f012016-07-21 10:58:53 -07003154 if (((eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
3155 (eCSR_ROAM_CANCELLED == roamStatus))
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003156 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003157 hdd_conn_set_connection_state(pAdapter,
3158 eConnectionState_NotConnected);
3159 }
3160 hdd_wmm_init(pAdapter);
3161
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003162 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003163 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303164 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003165 WLAN_CONTROL_PATH);
3166 }
3167
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303168 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003169}
3170
3171/**
3172 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
3173 * @pAdapter: pointer to adapter
3174 * @pRoamInfo: pointer to roam info
3175 * @roamId: roam id
3176 * @roamStatus: roam status
3177 * @roamResult: roam result
3178 *
3179 * Here we update the status of the Ibss when we receive information that we
3180 * have started/joined an ibss session.
3181 *
3182 * Return: none
3183 */
3184static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
3185 tCsrRoamInfo *pRoamInfo,
3186 uint32_t roamId,
3187 eRoamCmdStatus roamStatus,
3188 eCsrRoamResult roamResult)
3189{
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003190 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
3191
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003192 hdd_debug("%s: id %d, status %d, result %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003193 pAdapter->dev->name, roamId,
3194 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003195
3196 switch (roamResult) {
3197 /* both IBSS Started and IBSS Join should come in here. */
3198 case eCSR_ROAM_RESULT_IBSS_STARTED:
3199 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
3200 case eCSR_ROAM_RESULT_IBSS_COALESCED:
3201 {
3202 hdd_context_t *pHddCtx =
3203 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303204 hdd_station_ctx_t *hdd_sta_ctx =
3205 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303206 struct qdf_mac_addr broadcastMacAddr =
3207 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003208
3209 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303210 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003211 return;
3212 }
3213
3214 /* When IBSS Started comes from CSR, we need to move
3215 * connection state to IBSS Disconnected (meaning no peers
3216 * are in the IBSS).
3217 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003218 hdd_conn_set_connection_state(pAdapter,
3219 eConnectionState_IbssDisconnected);
3220 /* notify wmm */
3221 hdd_wmm_connect(pAdapter, pRoamInfo,
3222 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303223
Rakesh Sunkicf1c9ab2016-08-25 14:11:25 -07003224 hdd_sta_ctx->broadcast_staid = pRoamInfo->staId;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303225
3226 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003227 pAdapter;
3228 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05303229 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003230 &broadcastMacAddr,
3231 pRoamInfo->pBssDesc);
3232
3233 if (pRoamInfo->pBssDesc) {
3234 struct cfg80211_bss *bss;
3235#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3236 struct ieee80211_channel *chan;
3237 int chan_no;
3238 unsigned int freq;
3239#endif
3240 /* we created the IBSS, notify supplicant */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003241 hdd_info("%s: created ibss " MAC_ADDRESS_STR,
3242 pAdapter->dev->name,
3243 MAC_ADDR_ARRAY(
3244 pRoamInfo->pBssDesc->bssId));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245
3246 /* we must first give cfg80211 the BSS information */
3247 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
3248 pRoamInfo);
3249 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003250 hdd_err("%s: unable to create IBSS entry",
3251 pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003252 return;
3253 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003254 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003255 wlan_hdd_netif_queue_control(pAdapter,
3256 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3257 WLAN_CONTROL_PATH);
3258
3259#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
3260 chan_no = pRoamInfo->pBssDesc->channelId;
3261
3262 if (chan_no <= 14)
3263 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003264 HDD_NL80211_BAND_2GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003265 else
3266 freq = ieee80211_channel_to_frequency(chan_no,
Srinivas Girigowda38f1ded2017-06-12 23:00:38 -07003267 HDD_NL80211_BAND_5GHZ);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003268
3269 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
3270
3271 if (chan)
3272 cfg80211_ibss_joined(pAdapter->dev,
3273 bss->bssid, chan,
3274 GFP_KERNEL);
3275 else
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003276 hdd_warn("%s: chanId: %d, can't find channel",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003277 pAdapter->dev->name,
3278 (int)pRoamInfo->pBssDesc->channelId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003279#else
3280 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
3281 GFP_KERNEL);
3282#endif
3283 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003284 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003285 bss);
3286 }
Krunal Soni2c68f232015-10-26 20:52:51 -07003287 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003288 policy_mgr_incr_active_session(hdd_ctx->hdd_psoc,
3289 pAdapter->device_mode, pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003290 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
3291 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08003292 policy_mgr_update_connection_info(hdd_ctx->hdd_psoc,
3293 pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07003294 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003295 break;
3296 }
3297
3298 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
3299 {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003300 hdd_err("%s: unable to create IBSS", pAdapter->dev->name);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003301 break;
3302 }
3303
3304 default:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003305 hdd_err("%s: unexpected result %d",
3306 pAdapter->dev->name, (int)roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003307 break;
3308 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003309}
3310
3311/**
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003312 * hdd_save_peer() - Save peer MAC address in adapter peer table.
3313 * @sta_ctx: pointer to hdd station context
3314 * @sta_id: station ID
3315 * @peer_mac_addr: mac address of new peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003316 *
3317 * This information is passed to iwconfig later. The peer that joined
3318 * last is passed as information to iwconfig.
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003319
3320 * Return: true if success, false otherwise
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003321 */
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003322bool hdd_save_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id,
3323 struct qdf_mac_addr *peer_mac_addr)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003324{
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003325 int idx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003326
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003327 for (idx = 0; idx < SIR_MAX_NUM_STA_IN_IBSS; idx++) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303328 if (HDD_WLAN_INVALID_STA_ID == sta_ctx->conn_info.staId[idx]) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003329 hdd_debug("adding peer: %pM, sta_id: %d, at idx: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003330 peer_mac_addr, sta_id, idx);
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003331 sta_ctx->conn_info.staId[idx] = sta_id;
3332 qdf_copy_macaddr(
3333 &sta_ctx->conn_info.peerMacAddress[idx],
3334 peer_mac_addr);
3335 return true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 }
3337 }
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003338 return false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003339}
3340
3341/**
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003342 * hdd_delete_peer() - removes peer from hdd station context peer table
3343 * @sta_ctx: pointer to hdd station context
3344 * @sta_id: station ID
3345 *
3346 * Return: None
3347 */
3348void hdd_delete_peer(hdd_station_ctx_t *sta_ctx, uint8_t sta_id)
3349{
3350 int i;
3351
3352 for (i = 0; i < SIR_MAX_NUM_STA_IN_IBSS; i++) {
3353 if (sta_id == sta_ctx->conn_info.staId[i]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303354 sta_ctx->conn_info.staId[i] = HDD_WLAN_INVALID_STA_ID;
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003355 return;
3356 }
3357 }
Deepak Dhamdherea6d2f4c2016-06-04 00:24:52 -07003358}
3359
3360/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003361 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
3362 * @pAdapter: pointer to adapter
3363 * @staId: station id
3364 *
3365 * Return:
Naveen Rawatc45d1622016-07-05 12:20:09 -07003366 * true if we remove MAX_PEERS or less STA
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003367 * false otherwise.
3368 */
3369static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
3370{
3371 bool fSuccess = false;
3372 int idx = 0;
3373 uint8_t valid_idx = 0;
3374 uint8_t del_idx = 0;
3375 uint8_t empty_slots = 0;
3376 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3377
Naveen Rawatc45d1622016-07-05 12:20:09 -07003378 for (idx = 0; idx < MAX_PEERS; idx++) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003379 if (staId == pHddStaCtx->conn_info.staId[idx]) {
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303380 pHddStaCtx->conn_info.staId[idx] =
3381 HDD_WLAN_INVALID_STA_ID;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003382
Anurag Chouhanc5548422016-02-24 18:33:27 +05303383 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003384 peerMacAddress[idx]);
3385
3386 fSuccess = true;
3387
3388 /*
3389 * Note the deleted Index, if its 0 we need special
3390 * handling.
3391 */
3392 del_idx = idx;
3393
3394 empty_slots++;
3395 } else {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003396 if (pHddStaCtx->conn_info.staId[idx] !=
3397 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003398 valid_idx = idx;
3399 } else {
3400 /* Found an empty slot */
3401 empty_slots++;
3402 }
3403 }
3404 }
3405
Naveen Rawatc45d1622016-07-05 12:20:09 -07003406 if (MAX_PEERS == empty_slots) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003407 /* Last peer departed, set the IBSS state appropriately */
Varun Reddy Yeturu9e0032c2017-07-12 18:39:59 -07003408 hdd_conn_set_connection_state(pAdapter,
3409 eConnectionState_IbssDisconnected);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003410 hdd_debug("Last IBSS Peer Departed!!!");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003411 }
3412 /* Find next active staId, to have a valid sta trigger for TL. */
3413 if (fSuccess == true) {
3414 if (del_idx == 0) {
Naveen Rawatac027cb2017-04-27 15:02:42 -07003415 if (pHddStaCtx->conn_info.staId[valid_idx] !=
3416 HDD_WLAN_INVALID_STA_ID) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003417 pHddStaCtx->conn_info.staId[0] =
3418 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05303419 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003420 peerMacAddress[0],
3421 &pHddStaCtx->conn_info.
3422 peerMacAddress[valid_idx]);
3423
Hanumanth Reddy Pothula18553ae2017-04-28 15:03:10 +05303424 pHddStaCtx->conn_info.staId[valid_idx] =
3425 HDD_WLAN_INVALID_STA_ID;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303426 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003427 peerMacAddress[valid_idx]);
3428 }
3429 }
3430 }
3431 return fSuccess;
3432}
3433
3434/**
3435 * roam_ibss_connect_handler() - IBSS connection handler
3436 * @pAdapter: pointer to adapter
3437 * @pRoamInfo: pointer to roam info
3438 *
3439 * We update the status of the IBSS to connected in this function.
3440 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303441 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003442 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303443static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003444 tCsrRoamInfo *pRoamInfo)
3445{
3446 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003447 /*
3448 * Set the internal connection state to show 'IBSS Connected' (IBSS with
3449 * a partner stations).
3450 */
3451 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
3452
3453 /* Save the connection info from CSR... */
3454 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
3455
3456 /* Send the bssid address to the wext. */
3457 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3458 /* add bss_id to cfg80211 data base */
3459 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3460 if (NULL == bss) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003461 hdd_err("%s: unable to create IBSS entry",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003462 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303463 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003464 }
3465 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003466 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003467 bss);
3468
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303469 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003470}
3471
3472/**
3473 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
3474 * @pAdapter: pointer to adapter
3475 * @pRoamInfo: pointer to roam info
3476 * @roamId: roam id
3477 * @roamStatus: roam status
3478 * @roamResult: roam result
3479 *
3480 * This function indicates the Mic failure to the supplicant
3481 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303482 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003483 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303484static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003485hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
3486 tCsrRoamInfo *pRoamInfo,
3487 uint32_t roamId,
3488 eRoamCmdStatus roamStatus,
3489 eCsrRoamResult roamResult)
3490{
3491 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3492
3493 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3494 TKIP_COUNTER_MEASURE_STOPED ==
3495 pHddStaCtx->WextState.mTKIPCounterMeasures) {
3496 struct iw_michaelmicfailure msg;
3497 union iwreq_data wreq;
Srinivas Girigowda0325c592017-03-25 16:11:25 -07003498
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003499 memset(&msg, '\0', sizeof(msg));
3500 msg.src_addr.sa_family = ARPHRD_ETHER;
3501 memcpy(msg.src_addr.sa_data,
3502 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3503 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003504 hdd_debug("MIC MAC " MAC_ADDRESS_STR,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003505 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003506
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003507 if (pRoamInfo->u.pMICFailureInfo->multicast == true)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003508 msg.flags = IW_MICFAILURE_GROUP;
3509 else
3510 msg.flags = IW_MICFAILURE_PAIRWISE;
3511 memset(&wreq, 0, sizeof(wreq));
3512 wreq.data.length = sizeof(msg);
3513 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
3514 (char *)&msg);
3515 /* inform mic failure to nl80211 */
3516 cfg80211_michael_mic_failure(pAdapter->dev,
3517 pRoamInfo->u.pMICFailureInfo->
3518 taMacAddr,
3519 ((pRoamInfo->u.pMICFailureInfo->
3520 multicast ==
Srinivas Girigowda74a66d62017-06-21 23:28:25 -07003521 true) ?
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003522 NL80211_KEYTYPE_GROUP :
3523 NL80211_KEYTYPE_PAIRWISE),
3524 pRoamInfo->u.pMICFailureInfo->
3525 keyId,
3526 pRoamInfo->u.pMICFailureInfo->TSC,
3527 GFP_KERNEL);
3528
3529 }
3530
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303531 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003532}
3533
3534/**
3535 * roam_roam_connect_status_update_handler() - IBSS connect status update
3536 * @pAdapter: pointer to adapter
3537 * @pRoamInfo: pointer to roam info
3538 * @roamId: roam id
3539 * @roamStatus: roam status
3540 * @roamResult: roam result
3541 *
3542 * The Ibss connection status is updated regularly here in this function.
3543 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303544 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003545 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303546static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003547roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
3548 tCsrRoamInfo *pRoamInfo,
3549 uint32_t roamId,
3550 eRoamCmdStatus roamStatus,
3551 eCsrRoamResult roamResult)
3552{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003553 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Rajeev Kumardfa37072017-01-13 16:27:22 -08003554 QDF_STATUS qdf_status;
Selvaraj, Sridhar0672a122016-12-29 16:11:48 +05303555
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003556 switch (roamResult) {
3557 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3558 {
3559 hdd_station_ctx_t *pHddStaCtx =
3560 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kai Liu7400c5b2016-09-29 15:28:36 +08003561 struct station_info *stainfo;
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003562 eCsrEncryptionType encr_type = pHddStaCtx->ibss_enc_key.encType;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003563
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003564 hdd_info("IBSS New Peer indication from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303565 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3566 MAC_ADDRESS_STR " and stationID= %d",
3567 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3568 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3569 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003570
Deepak Dhamdhere0f076bd2016-06-02 11:29:21 -07003571 if (!hdd_save_peer
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003572 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
3573 pRoamInfo->staId,
3574 &pRoamInfo->peerMac)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003575 hdd_warn("Max reached: Can't register new IBSS peer");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003576 break;
3577 }
3578
3579 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3580
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003581 if (hdd_is_key_install_required_for_ibss(encr_type))
3582 pRoamInfo->fAuthRequired = true;
3583
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003584 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303585 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003586 pRoamInfo,
3587 pRoamInfo->staId,
3588 &pRoamInfo->peerMac,
3589 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303590 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003591 hdd_err("Cannot register STA with TL for IBSS. qdf_status: %d [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303592 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003593 }
3594 pHddStaCtx->ibss_sta_generation++;
Kai Liu7400c5b2016-09-29 15:28:36 +08003595 stainfo = qdf_mem_malloc(sizeof(*stainfo));
3596 if (stainfo == NULL) {
3597 hdd_err("memory allocation for station_info failed");
3598 return QDF_STATUS_E_NOMEM;
3599 }
3600 stainfo->filled = 0;
3601 stainfo->generation = pHddStaCtx->ibss_sta_generation;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003602
3603 cfg80211_new_sta(pAdapter->dev,
3604 (const u8 *)pRoamInfo->peerMac.bytes,
Kai Liu7400c5b2016-09-29 15:28:36 +08003605 stainfo, GFP_KERNEL);
3606 qdf_mem_free(stainfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003607
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003608 if (hdd_is_key_install_required_for_ibss(encr_type)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003609 pHddStaCtx->ibss_enc_key.keyDirection =
3610 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05303611 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003612 &pRoamInfo->peerMac);
3613
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003614 hdd_info("New peer joined set PTK encType=%d",
Krishna Kumaar Natarajan5554cec2017-01-12 19:38:55 -08003615 encr_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003616
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303617 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003618 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
3619 (pAdapter),
3620 pAdapter->sessionId,
3621 &pHddStaCtx->ibss_enc_key,
3622 &roamId);
3623
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303624 if (QDF_STATUS_SUCCESS != qdf_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003625 hdd_err("sme_roam_set_key failed, status: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003626 qdf_status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303627 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003628 }
3629 }
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003630 hdd_info("Enabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003631 wlan_hdd_netif_queue_control(pAdapter,
3632 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
3633 WLAN_CONTROL_PATH);
3634 break;
3635 }
3636
3637 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3638 {
3639
3640 roam_ibss_connect_handler(pAdapter, pRoamInfo);
3641
3642 break;
3643 }
3644 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3645 {
3646 hdd_station_ctx_t *pHddStaCtx =
3647 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3648
3649 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003650 hdd_warn("IBSS peer departed by cannot find peer in our registration table with TL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003651
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003652 hdd_info("IBSS Peer Departed from SME "
Gowri, Deepthi07ac9932016-09-02 15:19:32 +05303653 "with peerMac " MAC_ADDRESS_STR " BSSID: "
3654 MAC_ADDRESS_STR " and stationID= %d",
3655 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3656 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
3657 pRoamInfo->staId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003658
3659 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
3660
3661 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
3662 pHddStaCtx->ibss_sta_generation++;
3663
3664 cfg80211_del_sta(pAdapter->dev,
3665 (const u8 *)&pRoamInfo->peerMac.bytes,
3666 GFP_KERNEL);
3667 break;
3668 }
3669 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3670 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003671 hdd_debug("Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003672 /* Stop only when we are inactive */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003673 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003674 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05303675 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003676 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003677 hdd_conn_set_connection_state(pAdapter,
3678 eConnectionState_NotConnected);
3679
3680 /* Send the bssid address to the wext. */
3681 hdd_send_association_event(pAdapter->dev, pRoamInfo);
3682 break;
3683 }
3684 default:
3685 break;
3686
3687 }
3688
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303689 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003690}
3691
3692#ifdef FEATURE_WLAN_TDLS
3693/**
3694 * hdd_roam_register_tdlssta() - register new TDLS station
3695 * @pAdapter: pointer to adapter
3696 * @peerMac: pointer to peer MAC address
3697 * @staId: station identifier
3698 * @ucastSig: unicast signature
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303699 * @qos: QOS capability of TDLS station/link
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003700 *
3701 * Construct the staDesc and register with TL the new STA.
3702 * This is called as part of ADD_STA in the TDLS setup.
3703 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303704 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003705 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303706QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003707 const uint8_t *peerMac, uint16_t staId,
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303708 uint8_t ucastSig, uint8_t qos)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003709{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303710 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003711 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08003712 struct ol_txrx_ops txrx_ops;
Leo Changfdb45c32016-10-28 11:09:23 -07003713 void *soc = cds_get_context(QDF_MODULE_ID_SOC);
3714 void *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003715
3716 /*
3717 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3718 * be peer MAC, here we are working on direct Link
3719 */
3720 staDesc.sta_id = staId;
3721
3722 /* set the QoS field appropriately .. */
Agrawal Ashishd3f22f62016-09-04 13:46:15 +05303723 staDesc.is_qos_enabled = qos;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003724
Dhanashri Atre50141c52016-04-07 13:15:29 -07003725 /* Register the vdev transmit and receive functions */
3726 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
3727 txrx_ops.rx.rx = hdd_rx_packet_cbk;
Leo Changfdb45c32016-10-28 11:09:23 -07003728 cdp_vdev_register(soc,
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003729 (struct cdp_vdev *)cdp_get_vdev_from_vdev_id(soc,
3730 (struct cdp_pdev *)pdev, pAdapter->sessionId),
Dhanashri Atre50141c52016-04-07 13:15:29 -07003731 pAdapter, &txrx_ops);
3732 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003733
3734 /* Register the Station with TL... */
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003735 qdf_status = cdp_peer_register(soc,
3736 (struct cdp_pdev *)pdev, &staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303737 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003738 hdd_err("cdp_peer_register() failed Status: %d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303739 qdf_status, qdf_status);
3740 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003741 }
3742
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303743 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003744}
3745
3746/**
3747 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
3748 * @pAdapter: pointer to adapter
3749 * @staId: station identifier
3750 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303751 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003752 */
Nitesh Shah99dd9552017-03-20 19:27:47 +05303753QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter, uint8_t staId)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003754{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303755 QDF_STATUS qdf_status;
Krishna Kumaar Natarajane58b4092017-01-25 15:47:35 -08003756 qdf_status = cdp_clear_peer(cds_get_context(QDF_MODULE_ID_SOC),
Venkata Sharath Chandra Manchala0d44d452016-11-23 17:48:15 -08003757 (struct cdp_pdev *)cds_get_context(QDF_MODULE_ID_TXRX),
3758 staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303759 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003760 hdd_err("cdp_clear_peer() failed for staID: %d Status: %d [0x%08X]",
Leo Changfdb45c32016-10-28 11:09:23 -07003761 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003762 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303763 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003764}
3765
3766/**
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003767 * hdd_tdls_connection_tracker_update() - update connection tracker state
3768 * @adapter: pointer to adapter
3769 * @roam_info: pointer to roam info
3770 * @hdd_tdls_ctx: tdls context
3771 *
3772 * Return: QDF_STATUS enumeration
3773 */
3774static QDF_STATUS hdd_tdls_connection_tracker_update(hdd_adapter_t *adapter,
3775 tCsrRoamInfo *roam_info,
3776 tdlsCtx_t *hdd_tdls_ctx)
3777{
3778 hddTdlsPeer_t *curr_peer;
3779 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
3780
3781 curr_peer = wlan_hdd_tdls_find_peer(adapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05303782 roam_info->peerMac.bytes);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003783
3784 if (!curr_peer) {
3785 hdd_err("curr_peer is null");
3786 return QDF_STATUS_E_FAILURE;
3787 }
3788
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003789 if (eTDLS_LINK_CONNECTED ==
3790 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003791 hdd_debug("Received CONNECTION_TRACKER_NOTIFICATION "
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003792 MAC_ADDRESS_STR
3793 " staId: %d, reason: %d",
3794 MAC_ADDR_ARRAY(roam_info->peerMac.bytes),
3795 roam_info->staId,
3796 roam_info->reasonCode);
3797
3798 if (roam_info->reasonCode ==
3799 eWNI_TDLS_PEER_ENTER_BUF_STA ||
3800 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003801 eWNI_TDLS_ENTER_BT_BUSY_MODE ||
3802 roam_info->reasonCode ==
3803 eWMI_TDLS_SCAN_STARTED_EVENT)
3804 hdd_ctx->enable_tdls_connection_tracker = false;
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003805 else if (roam_info->reasonCode ==
3806 eWNI_TDLS_PEER_EXIT_BUF_STA ||
3807 roam_info->reasonCode ==
Kabilan Kannan21eafc22016-11-04 16:33:52 -07003808 eWNI_TDLS_EXIT_BT_BUSY_MODE ||
3809 roam_info->reasonCode ==
3810 eWMI_TDLS_SCAN_COMPLETED_EVENT)
3811 hdd_ctx->enable_tdls_connection_tracker = true;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003812 hdd_debug("hdd_ctx->enable_tdls_connection_tracker %d",
Nitesh Shahc549dd52017-02-23 16:45:44 +05303813 hdd_ctx->enable_tdls_connection_tracker);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003814 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003815 hdd_debug("TDLS not connected, ignore notification, reason: %d",
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003816 roam_info->reasonCode);
3817 }
3818
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07003819 return QDF_STATUS_SUCCESS;
3820}
3821
3822
3823
3824
3825/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003826 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
3827 * @pAdapter: pointer to adapter
3828 * @pRoamInfo: pointer to roam info
3829 * @roamId: roam id
3830 * @roamStatus: roam status
3831 * @roamResult: roam result
3832 *
3833 * HDD interface between SME and TL to ensure TDLS client registration with
3834 * TL in case of new TDLS client is added and deregistration at the time
3835 * TDLS client is deleted.
3836 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303837 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003838 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303839static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003840hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3841 tCsrRoamInfo *pRoamInfo,
3842 uint32_t roamId,
3843 eRoamCmdStatus roamStatus,
3844 eCsrRoamResult roamResult)
3845{
3846 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Nitesh Shahf1f38992017-01-31 16:40:16 +05303847 tdlsCtx_t *pHddTdlsCtx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003848 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303849 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003850 uint8_t staIdx;
3851 hddTdlsPeer_t *curr_peer;
3852 uint32_t reason;
3853
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003854 hdd_debug("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003855 roamResult ==
3856 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3857 ==
3858 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3859 roamResult ==
3860 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3861 : roamResult ==
3862 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3863 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3864 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3865 roamResult ==
3866 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3867 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3868 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3869 : roamResult ==
3870 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3871 : roamResult ==
3872 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3873 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3874 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3875
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003876 switch (roamResult) {
3877 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3878 {
3879 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003880 hdd_err("Add Sta failed. status code: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003881 pRoamInfo->statusCode);
Selvaraj, Sridhar5d95e632016-09-14 17:00:38 +05303882 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003883 } else {
3884 /*
3885 * Check if there is available index for this new TDLS
3886 * STA.
3887 */
3888 for (staIdx = 0;
3889 staIdx < pHddCtx->max_num_tdls_sta;
3890 staIdx++) {
3891 if (0 ==
3892 pHddCtx->tdlsConnInfo[staIdx].
3893 staId) {
3894 pHddCtx->tdlsConnInfo[staIdx].
3895 sessionId =
3896 pRoamInfo->sessionId;
3897 pHddCtx->tdlsConnInfo[staIdx].
3898 staId = pRoamInfo->staId;
3899
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003900 hdd_debug("TDLS: STA IDX at %d is %d "
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003901 "of mac "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003902 MAC_ADDRESS_STR,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 staIdx,
3904 pHddCtx->
3905 tdlsConnInfo[staIdx].
3906 staId,
3907 MAC_ADDR_ARRAY
3908 (pRoamInfo->peerMac.bytes));
3909
Anurag Chouhanc5548422016-02-24 18:33:27 +05303910 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003911 tdlsConnInfo
3912 [staIdx].
3913 peerMac,
3914 &pRoamInfo->
3915 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303916 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003917 break;
3918 }
3919 }
3920 if (staIdx < pHddCtx->max_num_tdls_sta) {
3921 if (-1 ==
3922 wlan_hdd_tdls_set_sta_id(pAdapter,
3923 pRoamInfo->
3924 peerMac.bytes,
3925 pRoamInfo->
3926 staId)) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003927 hdd_err("wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303928 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003929 }
3930
3931 (WLAN_HDD_GET_CTX(pAdapter))->
3932 sta_to_adapter[pRoamInfo->staId] =
3933 pAdapter;
3934 /*
3935 * store the ucast signature,
3936 * if required for further reference.
3937 */
3938
3939 wlan_hdd_tdls_set_signature(pAdapter,
3940 pRoamInfo->
3941 peerMac.bytes,
3942 pRoamInfo->
3943 ucastSig);
3944 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303945 status = QDF_STATUS_E_FAILURE;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003946 hdd_debug("no available slot in conn_info. staId: %d cannot be stored",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003947 pRoamInfo->staId);
3948 }
3949 pAdapter->tdlsAddStaStatus = status;
3950 }
3951 complete(&pAdapter->tdls_add_station_comp);
3952 break;
3953 }
3954 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3955 {
3956 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003957 hdd_err("Add Sta failed. status code: %d",
Varun Reddy Yeturued1215e2017-07-07 16:40:28 -07003958 pRoamInfo->statusCode);
3959 pAdapter->tdlsAddStaStatus = QDF_STATUS_E_FAILURE;
3960 } else {
3961 pAdapter->tdlsAddStaStatus = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003962 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003963 complete(&pAdapter->tdls_add_station_comp);
3964 break;
3965 }
3966 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3967 {
3968 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003969 hdd_err("Link Establish Request failed. status: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003970 pRoamInfo->statusCode);
3971 }
3972 complete(&pAdapter->tdls_link_establish_req_comp);
3973 break;
3974 }
3975 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3976 {
3977 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3978 staIdx++) {
3979 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3980 pRoamInfo->sessionId)
3981 && pRoamInfo->staId ==
3982 pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003983 hdd_debug("HDD: del STA IDX = %x",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07003984 pRoamInfo->staId);
Nitesh Shah3dea6722017-02-01 14:35:57 +05303985 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003986 curr_peer =
3987 wlan_hdd_tdls_find_peer(pAdapter,
3988 pRoamInfo->
Nitesh Shah90a02e92017-02-01 15:28:03 +05303989 peerMac.bytes);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303990 if (NULL != curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07003991 hdd_debug("Current status for peer " MAC_ADDRESS_STR " is %d",
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303992 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3993 curr_peer->link_status);
3994 if (TDLS_IS_CONNECTED(curr_peer)) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05303995 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003996 hdd_roam_deregister_tdlssta
3997 (pAdapter,
3998 pRoamInfo->staId);
3999 wlan_hdd_tdls_decrement_peer_count
4000 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304001 } else if (eTDLS_LINK_CONNECTING ==
4002 curr_peer->link_status) {
Nitesh Shah3dea6722017-02-01 14:35:57 +05304003 mutex_unlock(&pHddCtx->tdls_lock);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05304004 hdd_roam_deregister_tdlssta
4005 (pAdapter,
4006 pRoamInfo->staId);
Nitesh Shah0bf768f2017-03-31 15:01:37 +05304007 } else
4008 mutex_unlock(&pHddCtx->tdls_lock);
Nitesh Shah3dea6722017-02-01 14:35:57 +05304009 } else
4010 mutex_unlock(&pHddCtx->tdls_lock);
4011
Nitesh Shah99dd9552017-03-20 19:27:47 +05304012 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004013 wlan_hdd_tdls_reset_peer(pAdapter,
4014 pRoamInfo->
4015 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304016 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004017
4018 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4019 pHddCtx->tdlsConnInfo[staIdx].
4020 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304021 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004022 tdlsConnInfo[staIdx].
4023 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304024 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304025 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004026 break;
4027 }
4028 }
4029 complete(&pAdapter->tdls_del_station_comp);
4030 }
4031 break;
4032 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
4033 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004034 hdd_debug("Sending teardown to supplicant with reason code %u",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004035 pRoamInfo->reasonCode);
4036
Nitesh Shahf1f38992017-01-31 16:40:16 +05304037 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004038 curr_peer =
4039 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304040 pRoamInfo->peerMac.bytes);
Ganesh Kondabattini9c8dc462017-04-19 10:52:54 +05304041
4042 if (!curr_peer) {
4043 mutex_unlock(&pHddCtx->tdls_lock);
4044 hdd_debug("peer doesn't exists");
4045 status = QDF_STATUS_SUCCESS;
4046 break;
4047 }
4048
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004049 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304050 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304051 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
4052 curr_peer->peerMac);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304053 mutex_unlock(&pHddCtx->tdls_lock);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304054 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004055 break;
4056 }
4057 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
4058 {
4059 /* 0 staIdx is assigned to AP we dont want to touch that */
4060 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
4061 staIdx++) {
4062 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
4063 pRoamInfo->sessionId)
4064 && pHddCtx->tdlsConnInfo[staIdx].staId) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004065 hdd_debug("hdd_tdlsStatusUpdate: staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004066 MAC_ADDRESS_STR,
4067 pHddCtx->tdlsConnInfo[staIdx].
4068 staId,
4069 MAC_ADDR_ARRAY(pHddCtx->
4070 tdlsConnInfo
4071 [staIdx].
4072 peerMac.
4073 bytes));
Nitesh Shah99dd9552017-03-20 19:27:47 +05304074 mutex_lock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004075 wlan_hdd_tdls_reset_peer(pAdapter,
4076 pHddCtx->
4077 tdlsConnInfo
4078 [staIdx].
4079 peerMac.bytes);
Nitesh Shah99dd9552017-03-20 19:27:47 +05304080 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004081 hdd_roam_deregister_tdlssta(pAdapter,
4082 pHddCtx->
4083 tdlsConnInfo
4084 [staIdx].
4085 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304086 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004087 sizeof
4088 (smeTdlsPeerStateParams));
4089 smeTdlsPeerStateParams.vdevId =
4090 pHddCtx->tdlsConnInfo[staIdx].
4091 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304092 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004093 peerMacAddr,
4094 &pHddCtx->
4095 tdlsConnInfo[staIdx].
4096 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304097 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004098 smeTdlsPeerStateParams.peerState =
4099 eSME_TDLS_PEER_STATE_TEARDOWN;
4100
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004101 hdd_debug("calling sme_update_tdls_peer_state for staIdx %d "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004102 MAC_ADDRESS_STR,
4103 pHddCtx->tdlsConnInfo[staIdx].
4104 staId,
4105 MAC_ADDR_ARRAY(pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004106 tdlsConnInfo
4107 [staIdx].
4108 peerMac.
4109 bytes));
4110 status =
4111 sme_update_tdls_peer_state(
4112 pHddCtx->hHal,
4113 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304114 if (QDF_STATUS_SUCCESS != status) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004115 hdd_err("sme_update_tdls_peer_state failed for "
4116 MAC_ADDRESS_STR,
4117 MAC_ADDR_ARRAY
4118 (pHddCtx->
4119 tdlsConnInfo[staIdx].
4120 peerMac.bytes));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 }
4122 wlan_hdd_tdls_decrement_peer_count
4123 (pAdapter);
4124
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304125 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004126 tdlsConnInfo[staIdx].
4127 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304128 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004129 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
4130 pHddCtx->tdlsConnInfo[staIdx].
4131 sessionId = 255;
4132
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304133 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004134 }
4135 }
4136 break;
4137 }
4138 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
4139 {
4140 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Kabilan Kannan163fd0b2016-06-08 15:21:51 -07004141 if (!cds_check_is_tdls_allowed(pAdapter->device_mode)) {
4142 hdd_err("TDLS not allowed, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304143 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004144 break;
4145 }
4146
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004147 if (pHddCtx->tdls_nss_switch_in_progress) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004148 hdd_debug("TDLS antenna switch is in progress, ignore SHOULD_DISCOVER");
Archana Ramachandran7ba24ff2016-04-26 12:29:04 -07004149 status = QDF_STATUS_SUCCESS;
4150 break;
4151 }
4152
Nitesh Shah8e866642017-01-31 15:43:31 +05304153 mutex_lock(&pHddCtx->tdls_lock);
4154 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4155 if (!pHddTdlsCtx) {
4156 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004157 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shah8e866642017-01-31 15:43:31 +05304158 roamResult);
4159 status = QDF_STATUS_E_FAILURE;
4160 break;
4161 }
4162
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004163 curr_peer =
4164 wlan_hdd_tdls_get_peer(pAdapter,
Nitesh Shah379449e2017-01-31 19:11:29 +05304165 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004166 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004167 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304168 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004169 } else {
4170 if (eTDLS_LINK_CONNECTED ==
4171 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004172 hdd_debug("TDLS link status is connected, ignore SHOULD_DISCOVER");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004173 } else {
4174 /*
4175 * If external control is enabled then initiate
4176 * TDLS only if forced peer is set otherwise
4177 * ignore should Discover trigger from fw.
4178 */
4179 if (pHddCtx->config->
4180 fTDLSExternalControl
4181 && (false ==
4182 curr_peer->isForcedPeer)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004183 hdd_debug("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304184 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004185 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004186 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004187 hdd_debug("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d",
Jeff Johnson68755312017-02-10 11:46:55 -08004188 pHddCtx->config->
4189 fTDLSExternalControl,
4190 curr_peer->isForcedPeer,
4191 pRoamInfo->reasonCode);
Nitesh Shah983e8f52016-11-25 12:36:29 +05304192 pHddTdlsCtx->curr_candidate = curr_peer;
4193 wlan_hdd_tdls_implicit_send_discovery_request(
4194 pHddTdlsCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004195 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304196 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004197 }
Nitesh Shah8e866642017-01-31 15:43:31 +05304198 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004199 break;
4200 }
4201
4202 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
4203 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304204 mutex_lock(&pHddCtx->tdls_lock);
4205 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4206 if (!pHddTdlsCtx) {
4207 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004208 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304209 roamResult);
4210 status = QDF_STATUS_E_FAILURE;
4211 break;
4212 }
4213
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004214 curr_peer =
4215 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304216 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004217 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004218 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304219 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004220 } else {
4221 if (eTDLS_LINK_CONNECTED ==
4222 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004223 hdd_debug("Received SHOULD_TEARDOWN for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004224 MAC_ADDRESS_STR
4225 " staId: %d, reason: %d",
4226 MAC_ADDR_ARRAY(pRoamInfo->
4227 peerMac.bytes),
4228 pRoamInfo->staId,
4229 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004230
4231 if (pRoamInfo->reasonCode ==
4232 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4233 pRoamInfo->reasonCode ==
4234 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4235 pRoamInfo->reasonCode ==
4236 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4237 pRoamInfo->reasonCode ==
4238 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4239 reason =
4240 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4241 } else
4242 reason =
4243 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4244
4245 wlan_hdd_tdls_indicate_teardown
4246 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304247 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304248 hdd_send_wlan_tdls_teardown_event(
4249 eTDLS_TEARDOWN_BSS_DISCONNECT,
4250 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004251 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004252 hdd_debug("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004253 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004254 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304255 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004256 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304257 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 break;
4259 }
4260
4261 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
4262 {
Nitesh Shahf1f38992017-01-31 16:40:16 +05304263 mutex_lock(&pHddCtx->tdls_lock);
4264 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4265 if (!pHddTdlsCtx) {
4266 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004267 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304268 roamResult);
4269 status = QDF_STATUS_E_FAILURE;
4270 break;
4271 }
4272
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004273 curr_peer =
4274 wlan_hdd_tdls_find_peer(pAdapter,
Nitesh Shah90a02e92017-02-01 15:28:03 +05304275 pRoamInfo->peerMac.bytes);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004276 if (!curr_peer) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004277 hdd_debug("curr_peer is null");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304278 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004279 } else {
4280 if (eTDLS_LINK_CONNECTED ==
4281 curr_peer->link_status) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004282 hdd_debug("Received SHOULD_PEER_DISCONNECTED for peer "
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004283 MAC_ADDRESS_STR
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004284 " staId: %d reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004285 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
4286 pRoamInfo->staId,
4287 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004288
4289 if (pRoamInfo->reasonCode ==
4290 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
4291 pRoamInfo->reasonCode ==
4292 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
4293 pRoamInfo->reasonCode ==
4294 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
4295 pRoamInfo->reasonCode ==
4296 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
4297 reason =
4298 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
4299 } else
4300 reason =
4301 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
4302
4303 wlan_hdd_tdls_indicate_teardown
4304 (pHddTdlsCtx->pAdapter, curr_peer,
Nitesh Shah8816f572017-01-31 17:56:28 +05304305 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05304306 hdd_send_wlan_tdls_teardown_event(
4307 eTDLS_TEARDOWN_BSS_DISCONNECT,
4308 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004309 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004310 hdd_debug("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004311 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004312 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304313 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004314 }
Nitesh Shahf1f38992017-01-31 16:40:16 +05304315 mutex_unlock(&pHddCtx->tdls_lock);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004316 break;
4317 }
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004318
4319 case eCSR_ROAM_RESULT_TDLS_CONNECTION_TRACKER_NOTIFICATION:
Nitesh Shahf1f38992017-01-31 16:40:16 +05304320 mutex_lock(&pHddCtx->tdls_lock);
4321 pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
4322 if (!pHddTdlsCtx) {
4323 mutex_unlock(&pHddCtx->tdls_lock);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004324 hdd_debug("TDLS ctx is null, ignore roamResult (%d)",
Nitesh Shahf1f38992017-01-31 16:40:16 +05304325 roamResult);
4326 status = QDF_STATUS_E_FAILURE;
4327 break;
4328 }
4329
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004330 status = hdd_tdls_connection_tracker_update(pAdapter,
4331 pRoamInfo,
4332 pHddTdlsCtx);
Nitesh Shahf1f38992017-01-31 16:40:16 +05304333 mutex_unlock(&pHddCtx->tdls_lock);
Kabilan Kannan14ec97f2016-05-16 23:48:25 -07004334 break;
4335
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004336 default:
4337 {
4338 break;
4339 }
4340 }
4341
4342 return status;
4343}
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004344#else
4345
Nitesh Shah99dd9552017-03-20 19:27:47 +05304346inline QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Kabilan Kannan32eb5022016-10-04 12:24:50 -07004347 uint8_t staId)
4348{
4349 return QDF_STATUS_SUCCESS;
4350}
4351
4352static inline QDF_STATUS
4353hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
4354 tCsrRoamInfo *pRoamInfo,
4355 uint32_t roamId,
4356 eRoamCmdStatus roamStatus,
4357 eCsrRoamResult roamResult)
4358{
4359 return QDF_STATUS_SUCCESS;
4360}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004361#endif
4362
4363#ifdef WLAN_FEATURE_11W
4364/**
4365 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
4366 * @pAdapter: pointer to the adapter
4367 * @nFrameLength: Length of the unprotected frame being passed
4368 * @pbFrames: Pointer to the frame buffer
4369 * @frameType: 802.11 frame type
4370 *
4371 * This function forwards the unprotected management frame to the supplicant.
4372 *
4373 * Return: nothing
4374 */
4375static void
4376hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
4377 uint8_t *pbFrames, uint8_t frameType)
4378{
4379 uint8_t type = 0;
4380 uint8_t subType = 0;
4381
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004382 hdd_debug("Frame Type = %d Frame Length = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004383 frameType, nFrameLength);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004384
4385 /* Sanity Checks */
4386 if (NULL == pAdapter) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004387 hdd_err("pAdapter is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004388 return;
4389 }
4390
4391 if (NULL == pAdapter->dev) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004392 hdd_err("pAdapter->dev is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004393 return;
4394 }
4395
4396 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004397 hdd_err("pAdapter has invalid magic");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004398 return;
4399 }
4400
4401 if (!nFrameLength) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004402 hdd_err("Frame Length is Invalid ZERO");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004403 return;
4404 }
4405
4406 if (NULL == pbFrames) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004407 hdd_err("pbFrames is NULL");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004408 return;
4409 }
4410
4411 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4412 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4413
4414 /* Get pAdapter from Destination mac address of the frame */
4415 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
4416#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4417 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4418 nFrameLength);
4419#else
4420 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
4421 nFrameLength);
4422#endif
4423 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4424 } else if (type == SIR_MAC_MGMT_FRAME &&
4425 subType == SIR_MAC_MGMT_DEAUTH) {
4426#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
4427 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
4428 nFrameLength);
4429#else
4430 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
4431 nFrameLength);
4432#endif
4433 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4434 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004435 hdd_warn("Frame type %d and subtype %d are not valid",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004436 type, subType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004437 return;
4438 }
4439}
4440#endif
4441
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004442#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004443/**
4444 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
4445 * @pAdapter: pointer to adapter
4446 * @tid: traffic identifier
4447 * @state: state
4448 * @measInterval: measurement interval
4449 *
4450 * This function sends traffic stream metrics IE information to
4451 * the supplicant via wireless event.
4452 *
4453 * Return: none
4454 */
4455static void
4456hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
4457 uint8_t state, uint16_t measInterval)
4458{
4459 union iwreq_data wrqu;
4460 char buf[IW_CUSTOM_MAX + 1];
4461 int nBytes = 0;
4462
4463 if (NULL == pAdapter)
4464 return;
4465
4466 /* create the event */
4467 memset(&wrqu, '\0', sizeof(wrqu));
4468 memset(buf, '\0', sizeof(buf));
4469
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004470 hdd_debug("TSM Ind tid(%d) state(%d) MeasInt(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004471 tid, state, measInterval);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004472
4473 nBytes =
4474 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
4475 measInterval);
4476
4477 wrqu.data.pointer = buf;
4478 wrqu.data.length = nBytes;
4479 /* send the event */
4480 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4481}
4482
4483/**
4484 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
4485 * @pAdapter: pointer to adapter
4486 * @pRoamInfo: pointer to roam info
4487 *
4488 * This function sends cckm preauth indication to the supplicant
4489 * via wireless custom event.
4490 *
4491 * Return: none
4492 */
4493static void
4494hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4495{
4496 union iwreq_data wrqu;
4497 char buf[IW_CUSTOM_MAX + 1];
4498 char *pos = buf;
4499 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4500
4501 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4502 return;
4503
4504 /* create the event */
4505 memset(&wrqu, '\0', sizeof(wrqu));
4506 memset(buf, '\0', sizeof(buf));
4507
4508 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004509 hdd_debug("CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004510 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
4511 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004512
4513 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4514 pos += nBytes;
4515 freeBytes -= nBytes;
4516
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304517 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05304518 pos += QDF_MAC_ADDR_SIZE;
4519 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004520
4521 nBytes = snprintf(pos, freeBytes, " %u:%u",
4522 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4523 freeBytes -= nBytes;
4524
4525 wrqu.data.pointer = buf;
4526 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
4527
4528 /* send the event */
4529 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4530}
4531
4532/**
4533 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
4534 * @pAdapter: pointer to adapter
4535 * @pRoamInfo: pointer to roam info
4536 *
4537 * Return: none
4538 */
4539static void
4540hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
4541 tCsrRoamInfo *pRoamInfo)
4542{
4543 union iwreq_data wrqu;
4544 char buf[IW_CUSTOM_MAX + 1];
4545 int nBytes = 0;
4546
4547 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4548 return;
4549
4550 /* create the event */
4551 memset(&wrqu, '\0', sizeof(wrqu));
4552 memset(buf, '\0', sizeof(buf));
4553
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004554 hdd_debug("CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004555
4556 nBytes =
4557 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
4558 pRoamInfo->tsmRoamDelay);
4559
4560 wrqu.data.pointer = buf;
4561 wrqu.data.length = nBytes;
4562
4563 /* send the event */
4564 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4565}
4566
4567/**
4568 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
4569 * @pAdapter: pointer to adapter
4570 * @measurementToken: measurement token
4571 * @flag: flag
4572 * @numBss: number of bss
4573 *
4574 * If the measurement is none and no scan results found,
4575 * indicate the supplicant about measurement done.
4576 *
4577 * Return: none
4578 */
4579void
4580hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
4581 const uint16_t measurementToken,
4582 const bool flag, const uint8_t numBss)
4583{
4584 union iwreq_data wrqu;
4585 char buf[IW_CUSTOM_MAX];
4586 char *pos = buf;
4587 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4588
4589 memset(&wrqu, '\0', sizeof(wrqu));
4590 memset(buf, '\0', sizeof(buf));
4591
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004592 hdd_debug("CCXBCNREP=%d %d %d", measurementToken,
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004593 flag, numBss);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004594
4595 nBytes =
4596 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4597 flag, numBss);
4598
4599 wrqu.data.pointer = buf;
4600 wrqu.data.length = nBytes;
4601 /* send the event */
4602 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4603}
4604
4605/**
4606 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
4607 * @pAdapter: pointer to adapter
4608 * @pRoamInfo: pointer to roam info
4609 *
4610 * If the measurement is none and no scan results found,
4611 * indicate the supplicant about measurement done.
4612 *
4613 * Return: none
4614 */
4615static void
4616hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
4617 const tCsrRoamInfo *pRoamInfo)
4618{
4619 union iwreq_data wrqu;
4620 char buf[IW_CUSTOM_MAX];
4621 char *pos = buf;
4622 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4623 uint8_t i = 0, len = 0;
4624 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
4625 uint8_t lastSent = 0, sendBss = 0;
4626 int bcnRepFieldSize =
4627 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
4628 bcnReportFields);
4629 uint8_t ieLenByte = 1;
4630 /*
4631 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4632 */
4633#define ESEBCNREPHEADER_LEN (18)
4634
4635 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4636 return;
4637
4638 /*
4639 * Custom event can pass maximum of 256 bytes of data,
4640 * based on the IE len we need to identify how many BSS info can
4641 * be filled in to custom event data.
4642 */
4643 /*
4644 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4645 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4646 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4647 */
4648
4649 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
4650 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004651 hdd_debug("Measurement Done but no scan results");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004652 /* If the measurement is none and no scan results found,
Jeff Johnson5a062372017-01-12 09:51:25 -08004653 * indicate the supplicant about measurement done
4654 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004655 hdd_indicate_ese_bcn_report_no_results(
4656 pAdapter,
4657 pRoamInfo->pEseBcnReportRsp->
4658 measurementToken,
4659 pRoamInfo->pEseBcnReportRsp->flag,
4660 pRoamInfo->pEseBcnReportRsp->numBss);
4661 } else {
4662 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
4663 memset(&wrqu, '\0', sizeof(wrqu));
4664 memset(buf, '\0', sizeof(buf));
4665 tot_bcn_ieLen = 0;
4666 sendBss = 0;
4667 pos = buf;
4668 freeBytes = IW_CUSTOM_MAX;
4669
4670 for (i = lastSent;
4671 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
4672 len =
4673 bcnRepFieldSize + ieLenByte +
4674 pRoamInfo->pEseBcnReportRsp->
4675 bcnRepBssInfo[i].ieLen;
4676 if ((len + tot_bcn_ieLen) >
4677 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
4678 break;
4679 }
4680 tot_bcn_ieLen += len;
4681 sendBss++;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004682 hdd_debug("i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004683 i, bcnRepFieldSize, 1,
4684 pRoamInfo->pEseBcnReportRsp->
4685 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004686 }
4687
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004688 hdd_debug("Sending %d BSS Info", sendBss);
4689 hdd_debug("CCXBCNREP=%d %d %d %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004690 pRoamInfo->pEseBcnReportRsp->measurementToken,
4691 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
4692 tot_bcn_ieLen);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004693
4694 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4695 pRoamInfo->pEseBcnReportRsp->
4696 measurementToken,
4697 pRoamInfo->pEseBcnReportRsp->flag,
4698 sendBss);
4699 pos += nBytes;
4700 freeBytes -= nBytes;
4701
4702 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304703 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004704 sizeof(tot_bcn_ieLen));
4705 pos += sizeof(tot_bcn_ieLen);
4706 freeBytes -= sizeof(tot_bcn_ieLen);
4707
4708 for (i = 0; i < sendBss; i++) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004709 hdd_debug("ChanNum(%d) Spare(%d) MeasDuration(%d)"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004710 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4711 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
4712 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4713 pRoamInfo->pEseBcnReportRsp->
4714 bcnRepBssInfo[i +
4715 lastSent].bcnReportFields.
4716 ChanNum,
4717 pRoamInfo->pEseBcnReportRsp->
4718 bcnRepBssInfo[i +
4719 lastSent].bcnReportFields.
4720 Spare,
4721 pRoamInfo->pEseBcnReportRsp->
4722 bcnRepBssInfo[i +
4723 lastSent].bcnReportFields.
4724 MeasDuration,
4725 pRoamInfo->pEseBcnReportRsp->
4726 bcnRepBssInfo[i +
4727 lastSent].bcnReportFields.
4728 PhyType,
4729 pRoamInfo->pEseBcnReportRsp->
4730 bcnRepBssInfo[i +
4731 lastSent].bcnReportFields.
4732 RecvSigPower,
4733 pRoamInfo->pEseBcnReportRsp->
4734 bcnRepBssInfo[i +
4735 lastSent].bcnReportFields.
4736 ParentTsf,
4737 pRoamInfo->pEseBcnReportRsp->
4738 bcnRepBssInfo[i +
4739 lastSent].bcnReportFields.
4740 TargetTsf[0],
4741 pRoamInfo->pEseBcnReportRsp->
4742 bcnRepBssInfo[i +
4743 lastSent].bcnReportFields.
4744 TargetTsf[1],
4745 pRoamInfo->pEseBcnReportRsp->
4746 bcnRepBssInfo[i +
4747 lastSent].bcnReportFields.
4748 BcnInterval,
4749 pRoamInfo->pEseBcnReportRsp->
4750 bcnRepBssInfo[i +
4751 lastSent].bcnReportFields.
4752 CapabilityInfo,
4753 pRoamInfo->pEseBcnReportRsp->
4754 bcnRepBssInfo[i +
4755 lastSent].bcnReportFields.
4756 Bssid[0],
4757 pRoamInfo->pEseBcnReportRsp->
4758 bcnRepBssInfo[i +
4759 lastSent].bcnReportFields.
4760 Bssid[1],
4761 pRoamInfo->pEseBcnReportRsp->
4762 bcnRepBssInfo[i +
4763 lastSent].bcnReportFields.
4764 Bssid[2],
4765 pRoamInfo->pEseBcnReportRsp->
4766 bcnRepBssInfo[i +
4767 lastSent].bcnReportFields.
4768 Bssid[3],
4769 pRoamInfo->pEseBcnReportRsp->
4770 bcnRepBssInfo[i +
4771 lastSent].bcnReportFields.
4772 Bssid[4],
4773 pRoamInfo->pEseBcnReportRsp->
4774 bcnRepBssInfo[i +
4775 lastSent].bcnReportFields.
4776 Bssid[5]);
4777
4778 /* bcn report fields are copied */
4779 len =
4780 sizeof(pRoamInfo->pEseBcnReportRsp->
4781 bcnRepBssInfo[i +
4782 lastSent].
4783 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304784 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004785 (char *)&pRoamInfo->
4786 pEseBcnReportRsp->bcnRepBssInfo[i +
4787 lastSent].
4788 bcnReportFields, len);
4789 pos += len;
4790 freeBytes -= len;
4791
4792 /* Add 1 byte of ie len */
4793 len =
4794 pRoamInfo->pEseBcnReportRsp->
4795 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304796 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004797 pos += sizeof(len);
4798 freeBytes -= sizeof(len);
4799
4800 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304801 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004802 (char *)pRoamInfo->
4803 pEseBcnReportRsp->bcnRepBssInfo[i +
4804 lastSent].
4805 pBuf, len);
4806 pos += len;
4807 freeBytes -= len;
4808 }
4809
4810 wrqu.data.pointer = buf;
4811 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
4812
4813 /* send the event */
4814 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
4815 buf);
4816 lastSent += sendBss;
4817 }
4818 }
4819}
4820
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004821#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004822
4823/**
Komal Seelam98760ba2015-12-15 11:05:18 +05304824 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
4825 * @pHddStaCtx: Station Context
4826 *
4827 * API to check if the connection authentication type is 8021x_sha256.
4828 *
4829 * Return: bool
4830 */
4831#ifdef WLAN_FEATURE_11W
4832static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4833{
4834 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
4835 pHddStaCtx->conn_info.authType;
4836}
4837#else
4838static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
4839{
4840 return false;
4841}
4842#endif
4843
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304844/*
4845 * hdd_roam_channel_switch_handler() - hdd channel switch handler
4846 * @adapter: Pointer to adapter context
4847 * @roam_info: Pointer to roam info
4848 *
4849 * Return: None
4850 */
4851static void hdd_roam_channel_switch_handler(hdd_adapter_t *adapter,
4852 tCsrRoamInfo *roam_info)
4853{
4854 struct hdd_chan_change_params chan_change;
4855 struct cfg80211_bss *bss;
4856 struct net_device *dev = adapter->dev;
4857 struct wireless_dev *wdev = dev->ieee80211_ptr;
4858 struct wiphy *wiphy = wdev->wiphy;
4859 QDF_STATUS status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004860 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304861
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004862 hdd_debug("channel switch for session:%d to channel:%d",
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304863 adapter->sessionId, roam_info->chan_info.chan_id);
4864
4865 chan_change.chan = roam_info->chan_info.chan_id;
4866 chan_change.chan_params.ch_width =
4867 roam_info->chan_info.ch_width;
4868 chan_change.chan_params.sec_ch_offset =
4869 roam_info->chan_info.sec_ch_offset;
4870 chan_change.chan_params.center_freq_seg0 =
4871 roam_info->chan_info.band_center_freq1;
4872 chan_change.chan_params.center_freq_seg1 =
4873 roam_info->chan_info.band_center_freq2;
4874
4875 bss = wlan_hdd_cfg80211_update_bss_db(adapter, roam_info);
4876 if (NULL == bss)
4877 hdd_err("%s: unable to create BSS entry", adapter->dev->name);
4878 else
4879 cfg80211_put_bss(wiphy, bss);
4880
bings58ce8622017-07-10 15:55:36 +08004881 status = hdd_chan_change_notify(adapter, adapter->dev, chan_change,
4882 roam_info->mode == SIR_SME_PHY_MODE_LEGACY);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304883 if (QDF_IS_STATUS_ERROR(status))
4884 hdd_err("channel change notification failed");
4885
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004886 status = policy_mgr_set_hw_mode_on_channel_switch(hdd_ctx->hdd_psoc,
4887 adapter->sessionId);
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304888 if (QDF_IS_STATUS_ERROR(status))
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004889 hdd_debug("set hw mode change not done");
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05304890}
4891
Komal Seelam98760ba2015-12-15 11:05:18 +05304892/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004893 * hdd_sme_roam_callback() - hdd sme roam callback
4894 * @pContext: pointer to adapter context
4895 * @pRoamInfo: pointer to roam info
4896 * @roamId: roam id
4897 * @roamStatus: roam status
4898 * @roamResult: roam result
4899 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304900 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004901 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304902QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004903hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
4904 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
4905{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304906 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
4908 hdd_wext_state_t *pWextState = NULL;
4909 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304910 QDF_STATUS status = QDF_STATUS_SUCCESS;
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05304911 struct cfg80211_bss *bss_status;
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004912 hdd_context_t *hdd_ctx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004913
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004914 hdd_debug("CSR Callback: status= %d result= %d roamID=%d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004915 roamStatus, roamResult, roamId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004916
4917 /* Sanity check */
4918 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004919 hdd_err("Invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304920 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004921 }
4922
4923 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4924 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08004925 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004926
Sreelakshmi Konamki075431a2017-03-16 15:23:30 +05304927 /* Omitting eCSR_ROAM_UPDATE_SCAN_RESULT as this is too frequent */
4928 if (eCSR_ROAM_UPDATE_SCAN_RESULT != roamStatus)
4929 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
4930 pAdapter->sessionId, roamStatus));
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05304931
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004932 switch (roamStatus) {
4933 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05304934 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
4935 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08004936 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004937 break;
4938
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004939 /*
4940 * We did pre-auth,then we attempted a 11r or ese reassoc.
4941 * reassoc failed due to failure, timeout, reject from ap
4942 * in any case tell the OS, our carrier is off and mark
4943 * interface down.
4944 */
4945 case eCSR_ROAM_FT_REASSOC_FAILED:
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004946 hdd_err("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d",
4947 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304948 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004949 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4950 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004951 pHddStaCtx->ft_carrier_on = false;
4952 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004953 hdd_debug("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004954 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004955 break;
4956
4957 case eCSR_ROAM_FT_START:
4958 /*
4959 * When we roam for ESE and 11r, we dont want the OS to be
4960 * informed that the link is down. So mark the link ready for
4961 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4962 * be received. Where in we will not mark the link down
4963 * Also we want to stop tx at this point when we will be
4964 * doing disassoc at this time. This saves 30-60 msec
4965 * after reassoc.
4966 */
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004967 hdd_info("Disabling queues");
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004968 hdd_debug("Roam Synch Ind: NAPI Serialize ON");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004969 hdd_napi_serialize(1);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004970 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304971 WLAN_STOP_ALL_NETIF_QUEUE,
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004972 WLAN_CONTROL_PATH);
4973 status = hdd_roam_deregister_sta(pAdapter,
4974 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304975 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304976 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004977 pHddStaCtx->ft_carrier_on = true;
4978 pHddStaCtx->hdd_ReassocScenario = true;
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07004979 hdd_info("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d",
4980 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004981 break;
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004982 case eCSR_ROAM_NAPI_OFF:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07004983 hdd_debug("After Roam Synch Comp: NAPI Serialize OFF");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004984 hdd_napi_serialize(0);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08004985 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05304986 if (roamResult == eCSR_ROAM_RESULT_FAILURE)
4987 pAdapter->roam_ho_fail = true;
4988 else
4989 pAdapter->roam_ho_fail = false;
4990 complete(&pAdapter->roaming_comp_var);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07004991 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004992 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004993 /* notify apps that we can't pass traffic anymore */
Srinivas Girigowda6598eea2017-07-06 19:26:19 -07004994 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004995 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05304996 WLAN_STOP_ALL_NETIF_QUEUE,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004997 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004998 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004999 wlan_hdd_netif_queue_control(pAdapter,
5000 WLAN_NETIF_CARRIER_OFF,
5001 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005002 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005003 break;
5004 case eCSR_ROAM_LOSTLINK:
5005 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005006 hdd_debug("Roaming started due to connection lost");
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005007 hdd_info("Disabling queues");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005008 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305009 WLAN_STOP_ALL_NETIF_QUEUE_N_CARRIER,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005010 WLAN_CONTROL_PATH);
5011 break;
5012 }
5013 case eCSR_ROAM_DISASSOCIATED:
5014 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005015 hdd_debug("****eCSR_ROAM_DISASSOCIATED****");
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305016 hdd_napi_serialize(0);
Archana Ramachandran62886ce2017-03-24 14:46:32 -07005017 hdd_set_connection_in_progress(false);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305018 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305019 pAdapter->roam_ho_fail = false;
5020 complete(&pAdapter->roaming_comp_var);
Padma, Santhosh Kumar5b220022017-03-20 19:40:27 +05305021
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005022 /* Call to clear any MC Addr List filter applied after
5023 * successful connection.
5024 */
Mukul Sharmaff2ac2e2017-01-16 15:51:29 +05305025 hdd_disable_and_flush_mc_addr_list(pAdapter,
5026 pmo_peer_disconnect);
5027 qdf_ret_status =
5028 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
5029 roamStatus, roamResult);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005030 }
5031 break;
5032 case eCSR_ROAM_IBSS_LEAVE:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005033 hdd_debug("****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305034 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005035 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
5036 roamStatus, roamResult);
5037 break;
5038 case eCSR_ROAM_ASSOCIATION_COMPLETION:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005039 hdd_debug("****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005040 /*
5041 * To Do - address probable memory leak with WEP encryption upon
5042 * successful association.
5043 */
5044 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
5045 /* Clear saved connection information in HDD */
5046 hdd_conn_remove_connect_info(
5047 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
5048 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305049 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005050 hdd_association_completion_handler(pAdapter, pRoamInfo,
5051 roamId, roamStatus,
5052 roamResult);
5053#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5054 if (pRoamInfo)
5055 pRoamInfo->roamSynchInProgress = false;
5056#endif
5057 break;
Sandeep Puligilla0241f012016-07-21 10:58:53 -07005058 case eCSR_ROAM_CANCELLED:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005059 hdd_debug("****eCSR_ROAM_CANCELLED****");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005060 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305061 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005062 pRoamInfo,
5063 roamId,
5064 roamStatus,
5065 roamResult);
5066 break;
5067 case eCSR_ROAM_IBSS_IND:
5068 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
5069 roamStatus, roamResult);
5070 break;
5071
5072 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305073 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074 roam_roam_connect_status_update_handler(pAdapter,
5075 pRoamInfo,
5076 roamId,
5077 roamStatus,
5078 roamResult);
5079 break;
5080
5081 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305082 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005083 hdd_roam_mic_error_indication_handler(pAdapter,
5084 pRoamInfo,
5085 roamId,
5086 roamStatus,
5087 roamResult);
5088 break;
5089
5090 case eCSR_ROAM_SET_KEY_COMPLETE:
5091 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305092 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005093 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
5094 roamId, roamStatus,
5095 roamResult);
5096 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
5097 pHddStaCtx->hdd_ReassocScenario = false;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005098 hdd_debug("hdd_ReassocScenario set to: %d, set key complete, session: %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005099 pHddStaCtx->hdd_ReassocScenario,
5100 pAdapter->sessionId);
5101 }
5102 }
5103#ifdef WLAN_FEATURE_ROAM_OFFLOAD
5104 if (pRoamInfo != NULL)
5105 pRoamInfo->roamSynchInProgress = false;
5106#endif
5107 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005108
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005109 case eCSR_ROAM_FT_RESPONSE:
5110 hdd_send_ft_event(pAdapter);
5111 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005112
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005113 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05305114 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
5115 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005116 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305117 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005118 wlan_hdd_cfg80211_pmksa_candidate_notify(
5119 pAdapter, pRoamInfo, 1, false);
5120 }
5121 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005122
5123#ifdef FEATURE_WLAN_LFR_METRICS
5124 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
5125 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305126 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005127 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
5128 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305129 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005130 }
5131 break;
5132 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
5133 /*
5134 * This event will notify pre-auth completion in case of success
5135 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305136 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005137 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5138 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305139 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005140 }
5141 break;
5142 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
5143 /*
5144 * This event will notify pre-auth completion incase of failure.
5145 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305146 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005147 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
5148 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305149 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005150 }
5151 break;
5152 case eCSR_ROAM_HANDOVER_SUCCESS:
5153 /* This event is to notify handover success.
Jeff Johnson5a062372017-01-12 09:51:25 -08005154 * It will be only invoked on success
5155 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305156 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005157 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
5158 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305159 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005160 }
5161 break;
5162#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005163 case eCSR_ROAM_REMAIN_CHAN_READY:
5164 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
5165 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005166#ifdef FEATURE_WLAN_TDLS
5167 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305168 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005169 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
5170 roamId,
5171 roamStatus,
5172 roamResult);
5173 break;
5174 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
5175 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
5176 pRoamInfo->reasonCode);
5177 break;
5178#endif
5179#ifdef WLAN_FEATURE_11W
5180 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
5181 hdd_indicate_unprot_mgmt_frame(pAdapter,
5182 pRoamInfo->nFrameLength,
5183 pRoamInfo->pbFrames,
5184 pRoamInfo->frameType);
5185 break;
5186#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005187#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005188 case eCSR_ROAM_TSM_IE_IND:
5189 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
5190 pRoamInfo->tsmIe.state,
5191 pRoamInfo->tsmIe.msmt_interval);
5192 break;
5193
5194 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
5195 {
5196 if (eCSR_AUTH_TYPE_CCKM_WPA ==
5197 pHddStaCtx->conn_info.authType
5198 || eCSR_AUTH_TYPE_CCKM_RSN ==
5199 pHddStaCtx->conn_info.authType) {
5200 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
5201 }
5202 break;
5203 }
5204
5205 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
5206 {
5207 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
5208 break;
5209 }
5210
5211 case eCSR_ROAM_ESE_BCN_REPORT_IND:
5212 {
5213 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
5214 break;
5215 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08005216#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305217 case eCSR_ROAM_STA_CHANNEL_SWITCH:
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305218 hdd_roam_channel_switch_handler(pAdapter, pRoamInfo);
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05305219 break;
Selvaraj, Sridhar9c47fef2016-12-09 12:49:53 +05305220
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305221 case eCSR_ROAM_UPDATE_SCAN_RESULT:
5222 if ((NULL != pRoamInfo) && (NULL != pRoamInfo->pBssDesc)) {
5223 bss_status = wlan_hdd_cfg80211_inform_bss_frame(
5224 pAdapter, pRoamInfo->pBssDesc);
5225 if (NULL == bss_status)
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005226 hdd_debug("UPDATE_SCAN_RESULT returned NULL");
Selvaraj, Sridharfe696d22016-08-03 21:34:51 +05305227 else
5228 cfg80211_put_bss(
5229#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
5230 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
5231#endif
5232 bss_status);
5233 }
5234 break;
Deepak Dhamdhere5cdce842016-05-31 10:39:12 -07005235 case eCSR_ROAM_NDP_STATUS_UPDATE:
5236 hdd_ndp_event_handler(pAdapter, pRoamInfo, roamId, roamStatus,
5237 roamResult);
5238 break;
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005239 case eCSR_ROAM_START:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005240 hdd_debug("Process ROAM_START from firmware");
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005241 wlan_hdd_netif_queue_control(pAdapter,
Himanshu Agarwal865201d2017-04-12 15:45:31 +05305242 WLAN_STOP_ALL_NETIF_QUEUE,
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005243 WLAN_CONTROL_PATH);
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005244 hdd_napi_serialize(1);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005245 hdd_set_connection_in_progress(true);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005246 hdd_set_roaming_in_progress(true);
Tushnim Bhattacharyya87161582017-03-09 13:03:31 -08005247 policy_mgr_restart_opportunistic_timer(hdd_ctx->hdd_psoc, true);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005248 break;
5249 case eCSR_ROAM_ABORT:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005250 hdd_debug("Firmware aborted roaming operation, previous connection is still valid");
Varun Reddy Yeturu04251862016-09-16 10:33:19 -07005251 hdd_napi_serialize(0);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005252 wlan_hdd_netif_queue_control(pAdapter,
5253 WLAN_WAKE_ALL_NETIF_QUEUE,
5254 WLAN_CONTROL_PATH);
Tushnim Bhattacharyya9e81b4c2017-02-15 17:11:14 -08005255 hdd_set_connection_in_progress(false);
Varun Reddy Yeturudce1c562016-11-18 10:00:45 -08005256 hdd_set_roaming_in_progress(false);
Abhishek Singh533c9da2017-05-04 10:23:34 +05305257 pAdapter->roam_ho_fail = false;
5258 complete(&pAdapter->roaming_comp_var);
Naveen Rawat8cc23b02016-07-14 12:22:56 -07005259 break;
5260
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005261 default:
5262 break;
5263 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05305264 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005265}
5266
5267/**
5268 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
5269 * @auth_suite: auth suite
5270 *
5271 * Return: eCsrAuthType enumeration
5272 */
5273eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
5274{
5275 eCsrAuthType auth_type;
5276 /* is the auth type supported? */
5277 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
5278 auth_type = eCSR_AUTH_TYPE_RSN;
5279 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
5280 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005281 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005282 /* Check for 11r FT Authentication with PSK */
5283 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
5284 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
5285 /* Check for 11R FT Authentication with 802.1X */
5286 auth_type = eCSR_AUTH_TYPE_FT_RSN;
5287 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005288#ifdef FEATURE_WLAN_ESE
5289 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
5290 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
5291 } else
5292#endif /* FEATURE_WLAN_ESE */
5293#ifdef WLAN_FEATURE_11W
5294 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
5295 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5296 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
5297 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5298 } else
5299#endif
5300 {
5301 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5302 }
5303 return auth_type;
5304}
5305
5306/**
5307 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
5308 * @auth_suite: auth suite
5309 *
5310 * Return: eCsrAuthType enumeration
5311 */
5312eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
5313{
5314 eCsrAuthType auth_type;
5315 /* is the auth type supported? */
5316 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
5317 auth_type = eCSR_AUTH_TYPE_WPA;
5318 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
5319 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
5320 } else
5321#ifdef FEATURE_WLAN_ESE
5322 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
5323 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
5324 } else
5325#endif /* FEATURE_WLAN_ESE */
5326 {
5327 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
5328 }
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005329 hdd_debug("auth_type: %d", auth_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005330 return auth_type;
5331}
5332
5333/**
5334 * hdd_translate_rsn_to_csr_encryption_type() -
5335 * Translate RSN to CSR encryption type
5336 * @cipher_suite: cipher suite
5337 *
5338 * Return: eCsrEncryptionType enumeration
5339 */
5340eCsrEncryptionType
5341hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
5342{
5343 eCsrEncryptionType cipher_type;
5344
5345 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
5346 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Mukul Sharma05504ac2017-06-08 12:35:53 +05305347 else if (memcmp(cipher_suite, ccp_rsn_oui09, 4) == 0)
5348 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP;
5349 else if (memcmp(cipher_suite, ccp_rsn_oui0a, 4) == 0)
5350 cipher_type = eCSR_ENCRYPT_TYPE_AES_GCMP_256;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005351 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
5352 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5353 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
5354 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5355 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
5356 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5357 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
5358 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5359 else
5360 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5361
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005362 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005363 return cipher_type;
5364}
5365
5366/**
5367 * hdd_translate_wpa_to_csr_encryption_type() -
5368 * Translate WPA to CSR encryption type
5369 * @cipher_suite: cipher suite
5370 *
5371 * Return: eCsrEncryptionType enumeration
5372 */
5373eCsrEncryptionType
5374hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
5375{
5376 eCsrEncryptionType cipher_type;
5377
5378 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
5379 cipher_type = eCSR_ENCRYPT_TYPE_AES;
5380 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
5381 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
5382 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
5383 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
5384 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
5385 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5386 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
5387 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5388 else
5389 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
5390
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005391 hdd_debug("cipher_type: %d", cipher_type);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005392 return cipher_type;
5393}
5394
5395/**
5396 * hdd_process_genie() - process gen ie
5397 * @pAdapter: pointer to adapter
5398 * @bssid: pointer to mac address
5399 * @pEncryptType: pointer to encryption type
5400 * @mcEncryptType: pointer to multicast encryption type
5401 * @pAuthType: pointer to auth type
5402 *
5403 * Return: 0 on success, error number otherwise
5404 */
5405static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
5406 u8 *bssid,
5407 eCsrEncryptionType *pEncryptType,
5408 eCsrEncryptionType *mcEncryptType,
5409 eCsrAuthType *pAuthType,
5410#ifdef WLAN_FEATURE_11W
5411 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
5412#endif
5413 uint16_t gen_ie_len, uint8_t *gen_ie)
5414{
5415 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305416 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005417 tDot11fIERSN dot11RSNIE;
5418 tDot11fIEWPA dot11WPAIE;
5419 uint32_t i;
5420 uint8_t *pRsnIe;
5421 uint16_t RSNIeLen;
5422 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
5423 bool updatePMKCache = false;
5424
5425 /*
5426 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
5427 * setting present flag to 0.
5428 */
5429 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
5430 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
5431
5432 /* Type check */
5433 if (gen_ie[0] == DOT11F_EID_RSN) {
5434 /* Validity checks */
5435 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
5436 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005437 hdd_err("Invalid DOT11F RSN IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005438 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005439 return -EINVAL;
5440 }
5441 /* Skip past the EID byte and length byte */
5442 pRsnIe = gen_ie + 2;
5443 RSNIeLen = gen_ie_len - 2;
5444 /* Unpack the RSN IE */
5445 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305446 pRsnIe, RSNIeLen, &dot11RSNIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005447 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005448 hdd_debug("pairwise cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005449 dot11RSNIE.pwise_cipher_suite_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005450 hdd_debug("authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005451 dot11RSNIE.akm_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005452 /* dot11RSNIE.akm_suite_count */
5453 /* Just translate the FIRST one */
5454 *pAuthType =
5455 hdd_translate_rsn_to_csr_auth_type(
5456 dot11RSNIE.akm_suites[0]);
5457 /* dot11RSNIE.pwise_cipher_suite_count */
5458 *pEncryptType =
5459 hdd_translate_rsn_to_csr_encryption_type(
5460 dot11RSNIE.pwise_cipher_suites[0]);
5461 /* dot11RSNIE.gp_cipher_suite_count */
5462 *mcEncryptType =
5463 hdd_translate_rsn_to_csr_encryption_type(
5464 dot11RSNIE.gp_cipher_suite);
5465#ifdef WLAN_FEATURE_11W
5466 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
Srinivas Girigowda6519b932017-08-03 14:10:57 -07005467 *pMfpCapable = csr_is_mfpc_capable(&dot11RSNIE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005468#endif
5469 /* Set the PMKSA ID Cache for this interface */
5470 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
5471 if (is_zero_ether_addr(bssid)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005472 hdd_warn("MAC address is all zeroes");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005473 break;
5474 }
5475 updatePMKCache = true;
5476 /*
5477 * For right now, I assume setASSOCIATE() has passed
5478 * in the bssid.
5479 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305480 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305481 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305482 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005483 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
5484 }
5485
5486 if (updatePMKCache) {
5487 /*
5488 * Calling csr_roam_set_pmkid_cache to configure the
5489 * PMKIDs into the cache.
5490 */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005491 hdd_debug("Calling sme_roam_set_pmkid_cache with cache entry %d.",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005492 i);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005493 /* Finally set the PMKSA ID Cache in CSR */
5494 result =
5495 sme_roam_set_pmkid_cache(halHandle,
5496 pAdapter->sessionId,
5497 PMKIDCache,
5498 dot11RSNIE.pmkid_count,
5499 false);
5500 }
5501 } else if (gen_ie[0] == DOT11F_EID_WPA) {
5502 /* Validity checks */
5503 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
5504 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005505 hdd_err("Invalid DOT11F WPA IE length: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005506 gen_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005507 return -EINVAL;
5508 }
5509 /* Skip past the EID and length byte - and four byte WiFi OUI */
5510 pRsnIe = gen_ie + 2 + 4;
5511 RSNIeLen = gen_ie_len - (2 + 4);
5512 /* Unpack the WPA IE */
5513 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
Selvaraj, Sridhar75afbeb2017-04-03 17:08:59 +05305514 pRsnIe, RSNIeLen, &dot11WPAIE, false);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005515 /* Copy out the encryption and authentication types */
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005516 hdd_debug("WPA unicast cipher suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005517 dot11WPAIE.unicast_cipher_count);
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005518 hdd_debug("WPA authentication suite count: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005519 dot11WPAIE.auth_suite_count);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005520 /* dot11WPAIE.auth_suite_count */
5521 /* Just translate the FIRST one */
5522 *pAuthType =
5523 hdd_translate_wpa_to_csr_auth_type(
5524 dot11WPAIE.auth_suites[0]);
5525 /* dot11WPAIE.unicast_cipher_count */
5526 *pEncryptType =
5527 hdd_translate_wpa_to_csr_encryption_type(
5528 dot11WPAIE.unicast_ciphers[0]);
5529 /* dot11WPAIE.unicast_cipher_count */
5530 *mcEncryptType =
5531 hdd_translate_wpa_to_csr_encryption_type(
5532 dot11WPAIE.multicast_cipher);
5533 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005534 hdd_warn("gen_ie[0]: %d", gen_ie[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005535 return -EINVAL;
5536 }
5537 return 0;
5538}
5539
5540/**
5541 * hdd_set_genie_to_csr() - set genie to csr
5542 * @pAdapter: pointer to adapter
5543 * @RSNAuthType: pointer to auth type
5544 *
5545 * Return: 0 on success, error number otherwise
5546 */
5547int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
5548{
5549 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5550 uint32_t status = 0;
5551 eCsrEncryptionType RSNEncryptType;
5552 eCsrEncryptionType mcRSNEncryptType;
5553#ifdef WLAN_FEATURE_11W
5554 uint8_t RSNMfpRequired = 0;
5555 uint8_t RSNMfpCapable = 0;
5556#endif
5557 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
5558 /* MAC address of assoc peer */
5559 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305560 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005561 pWextState->roamProfile.BSSIDs.bssid,
5562 sizeof(bssid));
5563 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
5564 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
5565 /* continue */
5566 } else {
5567 return 0;
5568 }
5569 /* The actual processing may eventually be more extensive than this. */
5570 /* Right now, just consume any PMKIDs that are sent in by the app. */
5571 status = hdd_process_genie(pAdapter, bssid,
5572 &RSNEncryptType,
5573 &mcRSNEncryptType, RSNAuthType,
5574#ifdef WLAN_FEATURE_11W
5575 &RSNMfpRequired, &RSNMfpCapable,
5576#endif
5577 pWextState->WPARSNIE[1] + 2,
5578 pWextState->WPARSNIE);
5579 if (status == 0) {
5580 /*
5581 * Now copy over all the security attributes
5582 * you have parsed out.
5583 */
5584 pWextState->roamProfile.EncryptionType.numEntries = 1;
5585 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5586
5587 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
5588 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
5589 mcRSNEncryptType;
5590
Krunal Sonibe766b02016-03-10 13:00:44 -08005591 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005592 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
Mukul Sharma05504ac2017-06-08 12:35:53 +05305593 (eCSR_ENCRYPT_TYPE_AES_GCMP == mcRSNEncryptType) ||
5594 (eCSR_ENCRYPT_TYPE_AES_GCMP_256 == mcRSNEncryptType) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005595 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
5596 /*
5597 * For wpa none supplicant sends the WPA IE with unicast
5598 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
5599 * multicast cipher as either AES/TKIP based on group
5600 * cipher configuration mentioned in the
5601 * wpa_supplicant.conf.
5602 */
5603
5604 /* Set the unicast cipher same as multicast cipher */
5605 pWextState->roamProfile.EncryptionType.encryptionType[0]
5606 = mcRSNEncryptType;
5607 }
5608#ifdef WLAN_FEATURE_11W
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005609 hdd_debug("RSNMfpRequired = %d, RSNMfpCapable = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005610 RSNMfpRequired, RSNMfpCapable);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005611 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
5612 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
5613#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005614 hdd_debug("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005615 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005616 }
5617 return 0;
5618}
5619
5620/**
5621 * hdd_set_csr_auth_type() - set csr auth type
5622 * @pAdapter: pointer to adapter
5623 * @RSNAuthType: auth type
5624 *
5625 * Return: 0 on success, error number otherwise
5626 */
5627int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
5628{
5629 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5630 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
5631 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005632
5633 pRoamProfile->AuthType.numEntries = 1;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005634 hdd_debug("pHddStaCtx->conn_info.authType = %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005635 pHddStaCtx->conn_info.authType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005636
5637 switch (pHddStaCtx->conn_info.authType) {
5638 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5639#ifdef FEATURE_WLAN_ESE
5640 case eCSR_AUTH_TYPE_CCKM_WPA:
5641 case eCSR_AUTH_TYPE_CCKM_RSN:
5642#endif
5643 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
5644
5645 pRoamProfile->AuthType.authType[0] =
5646 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5647 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
5648
5649#ifdef FEATURE_WLAN_ESE
5650 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
5651 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5652 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005653 hdd_debug("set authType to CCKM WPA. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005654 pRoamProfile->AuthType.authType[0] =
5655 eCSR_AUTH_TYPE_CCKM_WPA;
5656 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005657 hdd_debug("Last chance to set authType to CCKM WPA.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005658 pRoamProfile->AuthType.authType[0] =
5659 eCSR_AUTH_TYPE_CCKM_WPA;
5660 } else
5661#endif
5662 if ((pWextState->
5663 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5664 == IW_AUTH_KEY_MGMT_802_1X) {
5665 pRoamProfile->AuthType.authType[0] =
5666 eCSR_AUTH_TYPE_WPA;
5667 } else
5668 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5669 == IW_AUTH_KEY_MGMT_PSK) {
5670 pRoamProfile->AuthType.authType[0] =
5671 eCSR_AUTH_TYPE_WPA_PSK;
5672 } else {
5673 pRoamProfile->AuthType.authType[0] =
5674 eCSR_AUTH_TYPE_WPA_NONE;
5675 }
5676 }
5677 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
5678#ifdef FEATURE_WLAN_ESE
5679 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
5680 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5681 == IW_AUTH_KEY_MGMT_802_1X)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005682 hdd_debug("set authType to CCKM RSN. AKM also 802.1X.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005683 pRoamProfile->AuthType.authType[0] =
5684 eCSR_AUTH_TYPE_CCKM_RSN;
5685 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005686 hdd_debug("Last chance to set authType to CCKM RSN.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005687 pRoamProfile->AuthType.authType[0] =
5688 eCSR_AUTH_TYPE_CCKM_RSN;
5689 } else
5690#endif
5691
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005692 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
5693 ((pWextState->
5694 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5695 == IW_AUTH_KEY_MGMT_802_1X)) {
5696 pRoamProfile->AuthType.authType[0] =
5697 eCSR_AUTH_TYPE_FT_RSN;
5698 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
5699 &&
5700 ((pWextState->
5701 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5702 == IW_AUTH_KEY_MGMT_PSK)) {
5703 pRoamProfile->AuthType.authType[0] =
5704 eCSR_AUTH_TYPE_FT_RSN_PSK;
5705 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005706
5707#ifdef WLAN_FEATURE_11W
5708 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
5709 pRoamProfile->AuthType.authType[0] =
5710 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
5711 } else if (RSNAuthType ==
5712 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
5713 pRoamProfile->AuthType.authType[0] =
5714 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
5715 } else
5716#endif
5717
5718 if ((pWextState->
5719 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
5720 == IW_AUTH_KEY_MGMT_802_1X) {
5721 pRoamProfile->AuthType.authType[0] =
5722 eCSR_AUTH_TYPE_RSN;
5723 } else
5724 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
5725 == IW_AUTH_KEY_MGMT_PSK) {
5726 pRoamProfile->AuthType.authType[0] =
5727 eCSR_AUTH_TYPE_RSN_PSK;
5728 } else {
5729 pRoamProfile->AuthType.authType[0] =
5730 eCSR_AUTH_TYPE_UNKNOWN;
5731 }
5732 }
5733 break;
5734
5735 case eCSR_AUTH_TYPE_SHARED_KEY:
5736
5737 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
5738 break;
5739 default:
5740
5741#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005742 hdd_debug("In default, unknown auth type.");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005743#endif /* FEATURE_WLAN_ESE */
5744 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
5745 break;
5746 }
5747
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005748 hdd_debug("Set roam Authtype to %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005749 pWextState->roamProfile.AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005750
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005751 return 0;
5752}
5753
5754/**
5755 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
5756 * to the CSR roam profile.
5757 *
5758 * @dev: Pointer to the net device.
5759 * @info: Pointer to the iw_request_info.
5760 * @wrqu: Pointer to the iwreq_data.
5761 * @extra: Pointer to the data.
5762 *
5763 * Return: 0 for success, error number on failure
5764 */
5765static int __iw_set_essid(struct net_device *dev,
5766 struct iw_request_info *info,
5767 union iwreq_data *wrqu, char *extra)
5768{
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005769 uint32_t status = 0;
5770 hdd_wext_state_t *pWextState;
5771 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5772 hdd_context_t *hdd_ctx;
5773 uint32_t roamId;
5774 tCsrRoamProfile *pRoamProfile;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005775 eCsrAuthType RSNAuthType;
5776 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005777 int ret;
5778
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005779 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005780
5781 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5782 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305783 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005784 return ret;
5785
Jeff Johnson441e1f72017-02-07 08:50:49 -08005786 ret = hdd_check_standard_wext_control(hdd_ctx, info);
5787 if (0 != ret)
5788 return ret;
5789
Krunal Sonibe766b02016-03-10 13:00:44 -08005790 if (pAdapter->device_mode != QDF_STA_MODE &&
Jeff Johnsond6e4b632016-10-03 13:49:27 -07005791 pAdapter->device_mode != QDF_IBSS_MODE &&
5792 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005793 hdd_warn("device mode %s(%d) is not allowed",
5794 hdd_device_mode_to_string(pAdapter->device_mode),
5795 pAdapter->device_mode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005796 return -EINVAL;
5797 }
5798
5799 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5800
5801 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005802 hdd_warn("Counter measure is in progress");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005803 return -EBUSY;
5804 }
5805 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
5806 return -EINVAL;
5807
5808 pRoamProfile = &pWextState->roamProfile;
Agrawal Ashish3d000b42017-02-07 13:44:50 +05305809 /*Try disconnecting if already in connected state*/
5810 status = wlan_hdd_try_disconnect(pAdapter);
5811 if (0 > status) {
5812 hdd_err("Failed to disconnect the existing connection");
5813 return -EALREADY;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005814 }
5815
5816 /*
5817 * when cfg80211 defined, wpa_supplicant wext driver uses
5818 * zero-length, null-string ssid for force disconnection.
5819 * after disconnection (if previously connected) and cleaning ssid,
5820 * driver MUST return success.
5821 */
5822 if (0 == wrqu->essid.length)
5823 return 0;
5824
5825 status = hdd_wmm_get_uapsd_mask(pAdapter,
5826 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05305827 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005828 pWextState->roamProfile.uapsd_mask = 0;
5829
5830 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
5831
5832 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
5833 wrqu->essid.length;
5834
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305835 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005836 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305837 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005838 ssId), extra, wrqu->essid.length);
5839 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
5840 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
5841
5842 /* set gen ie */
5843 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
5844
5845 /* set auth */
5846 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5847 }
5848#ifdef FEATURE_WLAN_WAPI
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005849 hdd_debug("Setting WAPI AUTH Type and Encryption Mode values");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005850 if (pAdapter->wapi_info.nWapiMode) {
5851 switch (pAdapter->wapi_info.wapiAuthMode) {
5852 case WAPI_AUTH_MODE_PSK:
5853 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005854 hdd_debug("WAPI AUTH TYPE: PSK: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005855 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005856 pRoamProfile->AuthType.numEntries = 1;
5857 pRoamProfile->AuthType.authType[0] =
5858 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5859 break;
5860 }
5861 case WAPI_AUTH_MODE_CERT:
5862 {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005863 hdd_debug("WAPI AUTH TYPE: CERT: %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07005864 pAdapter->wapi_info.wapiAuthMode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005865 pRoamProfile->AuthType.numEntries = 1;
5866 pRoamProfile->AuthType.authType[0] =
5867 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5868 break;
5869 }
5870 } /* End of switch */
5871 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5872 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005873 hdd_debug("WAPI PAIRWISE/GROUP ENCRYPTION: WPI");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005874 pRoamProfile->EncryptionType.numEntries = 1;
5875 pRoamProfile->EncryptionType.encryptionType[0] =
5876 eCSR_ENCRYPT_TYPE_WPI;
5877 pRoamProfile->mcEncryptionType.numEntries = 1;
5878 pRoamProfile->mcEncryptionType.encryptionType[0] =
5879 eCSR_ENCRYPT_TYPE_WPI;
5880 }
5881 }
5882#endif /* FEATURE_WLAN_WAPI */
5883 /* if previous genIE is not NULL, update AssocIE */
5884 if (0 != pWextState->genIE.length) {
5885 memset(&pWextState->assocAddIE, 0,
5886 sizeof(pWextState->assocAddIE));
5887 memcpy(pWextState->assocAddIE.addIEdata,
5888 pWextState->genIE.addIEdata, pWextState->genIE.length);
5889 pWextState->assocAddIE.length = pWextState->genIE.length;
5890 pWextState->roamProfile.pAddIEAssoc =
5891 pWextState->assocAddIE.addIEdata;
5892 pWextState->roamProfile.nAddIEAssocLength =
5893 pWextState->assocAddIE.length;
5894
5895 /* clear previous genIE after use it */
5896 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
5897 }
5898
5899 /*
5900 * Assumes it is not WPS Association by default, except when
5901 * pAddIEAssoc has WPS IE.
5902 */
5903 pWextState->roamProfile.bWPSAssociation = false;
5904
5905 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5906 pWextState->roamProfile.
5907 nAddIEAssocLength))
5908 pWextState->roamProfile.bWPSAssociation = true;
5909
5910 /* Disable auto BMPS entry by PMC until DHCP is done */
5911 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
5912 true);
5913
5914 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
5915
5916 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005917 pRoamProfile->ch_params.ch_width = 0;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005918 hdd_select_cbmode(pAdapter,
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005919 (WLAN_HDD_GET_CTX(pAdapter))->config->AdHocChannel5G,
5920 &pRoamProfile->ch_params);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005921 }
Naveen Rawatc77e6e72016-08-05 15:19:03 -07005922
Agrawal Ashish6b015762016-05-05 11:22:18 +05305923 /*
5924 * Change conn_state to connecting before sme_roam_connect(),
5925 * because sme_roam_connect() has a direct path to call
5926 * hdd_sme_roam_callback(), which will change the conn_state
5927 * If direct path, conn_state will be accordingly changed to
5928 * NotConnected or Associated by either
5929 * hdd_association_completion_handler() or hdd_dis_connect_handler()
5930 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5931 * Connecting state will remain until it is completed.
5932 *
5933 * If connection state is not changed,
5934 * connection state will remain in eConnectionState_NotConnected state.
5935 * In hdd_association_completion_handler, "hddDisconInProgress" is
5936 * set to true if conn state is eConnectionState_NotConnected.
5937 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5938 * informed of connect result indication which is an issue.
5939 */
5940 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305941 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305942 hdd_conn_set_connection_state(pAdapter,
5943 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305944
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005945 status = sme_roam_connect(hHal, pAdapter->sessionId,
5946 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305947 if ((QDF_STATUS_SUCCESS != status) &&
5948 (QDF_STA_MODE == pAdapter->device_mode ||
5949 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07005950 hdd_err("sme_roam_connect failed session_id: %d status %d -> NotConnected",
Agrawal Ashish6b015762016-05-05 11:22:18 +05305951 pAdapter->sessionId, status);
5952 /* change back to NotAssociated */
5953 hdd_conn_set_connection_state(pAdapter,
5954 eConnectionState_NotConnected);
5955 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005956 pRoamProfile->ChannelInfo.ChannelList = NULL;
5957 pRoamProfile->ChannelInfo.numOfChannels = 0;
5958
5959 EXIT();
5960 return status;
5961}
5962
5963/**
5964 * iw_set_essid() - set essid handler function
5965 * @dev: Pointer to the net device.
5966 * @info: Pointer to the iw_request_info.
5967 * @wrqu: Pointer to the iwreq_data.
5968 * @extra: Pointer to the data.
5969 *
5970 * Return: 0 for success, error number on failure
5971 */
5972int iw_set_essid(struct net_device *dev,
5973 struct iw_request_info *info,
5974 union iwreq_data *wrqu, char *extra)
5975{
5976 int ret;
5977
5978 cds_ssr_protect(__func__);
5979 ret = __iw_set_essid(dev, info, wrqu, extra);
5980 cds_ssr_unprotect(__func__);
5981
5982 return ret;
5983}
5984
5985/**
5986 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5987 * @dev: pointer to the net device
5988 * @info: pointer to the iw request info
5989 * @dwrq: pointer to iw_point
5990 * @extra: pointer to the data
5991 *
5992 * Return: 0 on success, error number otherwise
5993 */
5994static int __iw_get_essid(struct net_device *dev,
5995 struct iw_request_info *info,
5996 struct iw_point *dwrq, char *extra)
5997{
5998 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5999 hdd_context_t *hdd_ctx;
6000 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6001 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6002 int ret;
6003
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006004 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006005
6006 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6007 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306008 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006009 return ret;
6010
Jeff Johnson441e1f72017-02-07 08:50:49 -08006011 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6012 if (0 != ret)
6013 return ret;
6014
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006015 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
6016 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
6017 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
6018 || pHddStaCtx->conn_info.connState ==
6019 eConnectionState_IbssDisconnected)
6020 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
6021 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
6022 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
6023 dwrq->length);
6024 dwrq->flags = 1;
6025 } else {
6026 memset(extra, 0, dwrq->length);
6027 dwrq->length = 0;
6028 dwrq->flags = 0;
6029 }
6030 EXIT();
6031 return 0;
6032}
6033
6034/**
6035 * iw_get_essid() - get essid handler function
6036 * @dev: Pointer to the net device.
6037 * @info: Pointer to the iw_request_info.
6038 * @wrqu: Pointer to the iwreq_data.
6039 * @extra: Pointer to the data.
6040 *
6041 * Return: 0 for success, error number on failure
6042 */
6043int iw_get_essid(struct net_device *dev,
6044 struct iw_request_info *info,
6045 struct iw_point *wrqu, char *extra)
6046{
6047 int ret;
6048
6049 cds_ssr_protect(__func__);
6050 ret = __iw_get_essid(dev, info, wrqu, extra);
6051 cds_ssr_unprotect(__func__);
6052
6053 return ret;
6054}
6055
6056/**
6057 * __iw_set_auth() -
6058 * This function sets the auth type received from the wpa_supplicant
6059 * @dev: pointer to the net device
6060 * @info: pointer to the iw request info
6061 * @wrqu: pointer to iwreq_data
6062 * @extra: pointer to the data
6063 *
6064 * Return: 0 on success, error number otherwise
6065 */
6066static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6067 union iwreq_data *wrqu, char *extra)
6068{
6069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6070 hdd_context_t *hdd_ctx;
6071 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6072 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6073 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6074 eCsrEncryptionType mcEncryptionType;
6075 eCsrEncryptionType ucEncryptionType;
6076 int ret;
6077
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006078 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006079
6080 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6081 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306082 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006083 return ret;
6084
Jeff Johnson441e1f72017-02-07 08:50:49 -08006085 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6086 if (0 != ret)
6087 return ret;
6088
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006089 switch (wrqu->param.flags & IW_AUTH_INDEX) {
6090 case IW_AUTH_WPA_VERSION:
6091 pWextState->wpaVersion = wrqu->param.value;
6092 break;
6093
6094 case IW_AUTH_CIPHER_PAIRWISE:
6095 {
6096 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6097 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6098 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6099 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6100 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6101 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6102 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6103 if ((IW_AUTH_KEY_MGMT_802_1X
6104 ==
6105 (pWextState->
6106 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6107 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6108 pHddStaCtx->conn_info.authType))
6109 /*Dynamic WEP key */
6110 ucEncryptionType =
6111 eCSR_ENCRYPT_TYPE_WEP40;
6112 else
6113 /*Static WEP key */
6114 ucEncryptionType =
6115 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6116 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6117 if ((IW_AUTH_KEY_MGMT_802_1X
6118 ==
6119 (pWextState->
6120 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6121 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6122 pHddStaCtx->conn_info.authType))
6123 /*Dynamic WEP key */
6124 ucEncryptionType =
6125 eCSR_ENCRYPT_TYPE_WEP104;
6126 else
6127 /*Static WEP key */
6128 ucEncryptionType =
6129 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6130 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006131 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
6132 wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006133 return -EINVAL;
6134 }
6135
6136 pRoamProfile->EncryptionType.numEntries = 1;
6137 pRoamProfile->EncryptionType.encryptionType[0] =
6138 ucEncryptionType;
6139 }
6140 break;
6141 case IW_AUTH_CIPHER_GROUP:
6142 {
6143 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
6144 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
6145 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
6146 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
6147 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
6148 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
6149 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
6150 if ((IW_AUTH_KEY_MGMT_802_1X
6151 ==
6152 (pWextState->
6153 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6154 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6155 pHddStaCtx->conn_info.authType))
6156 mcEncryptionType =
6157 eCSR_ENCRYPT_TYPE_WEP40;
6158 else
6159 mcEncryptionType =
6160 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6161 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
6162 /* Dynamic WEP keys won't work with shared keys */
6163 if ((IW_AUTH_KEY_MGMT_802_1X
6164 ==
6165 (pWextState->
6166 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
6167 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
6168 pHddStaCtx->conn_info.authType)) {
6169 mcEncryptionType =
6170 eCSR_ENCRYPT_TYPE_WEP104;
6171 } else {
6172 mcEncryptionType =
6173 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
6174 }
6175 } else {
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006176 hdd_warn("value %d UNKNOWN IW_AUTH_CIPHER",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006177 wrqu->param.value);
6178 return -EINVAL;
6179 }
6180
6181 pRoamProfile->mcEncryptionType.numEntries = 1;
6182 pRoamProfile->mcEncryptionType.encryptionType[0] =
6183 mcEncryptionType;
6184 }
6185 break;
6186
6187 case IW_AUTH_80211_AUTH_ALG:
6188 {
Jeff Johnson5a062372017-01-12 09:51:25 -08006189 /* Save the auth algo here and set auth type to SME
6190 * Roam profile in the iw_set_ap_address
6191 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006192 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
6193 pHddStaCtx->conn_info.authType =
6194 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6195
6196 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
6197 pHddStaCtx->conn_info.authType =
6198 eCSR_AUTH_TYPE_SHARED_KEY;
6199
6200 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
6201 /*Not supported */
6202 pHddStaCtx->conn_info.authType =
6203 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6204 pWextState->roamProfile.AuthType.authType[0] =
6205 pHddStaCtx->conn_info.authType;
6206 }
6207 break;
6208
6209 case IW_AUTH_KEY_MGMT:
6210 {
6211#ifdef FEATURE_WLAN_ESE
6212#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
6213 /*Check for CCKM AKM type */
6214 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006215 hdd_debug("CCKM AKM Set %d", wrqu->param.value);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006216 /* Set the CCKM bit in authKeyMgmt */
6217 /*
6218 * Right now, this breaks all ref to authKeyMgmt because
6219 * our code doesn't realize it is a "bitfield"
6220 */
Jeff Johnsond084adb2017-08-16 11:19:52 -07006221 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006222 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
6223 /* Save the key management */
6224 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
Jeff Johnson34746022017-02-07 16:32:57 -08006225 } else if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006226 /* Save the key management anyway */
6227 pWextState->authKeyMgmt = wrqu->param.value;
6228 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
6229 /* Save the key management */
6230 pWextState->authKeyMgmt |=
6231 IW_AUTH_KEY_MGMT_802_1X;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006232 }
6233#else
6234 /* Save the key management */
6235 pWextState->authKeyMgmt = wrqu->param.value;
6236#endif /* FEATURE_WLAN_ESE */
6237 }
6238 break;
6239
6240 case IW_AUTH_TKIP_COUNTERMEASURES:
6241 {
6242 if (wrqu->param.value) {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006243 hdd_debug("Counter Measure started %d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006244 wrqu->param.value);
6245 pWextState->mTKIPCounterMeasures =
6246 TKIP_COUNTER_MEASURE_STARTED;
6247 } else {
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006248 hdd_debug("Counter Measure stopped=%d",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006249 wrqu->param.value);
6250 pWextState->mTKIPCounterMeasures =
6251 TKIP_COUNTER_MEASURE_STOPED;
6252 }
6253 }
6254 break;
6255 case IW_AUTH_DROP_UNENCRYPTED:
6256 case IW_AUTH_WPA_ENABLED:
6257 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
6258 case IW_AUTH_ROAMING_CONTROL:
6259 case IW_AUTH_PRIVACY_INVOKED:
6260
6261 default:
6262
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006263 hdd_warn("called with unsupported auth type %d",
6264 wrqu->param.flags & IW_AUTH_INDEX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006265 break;
6266 }
6267
6268 EXIT();
6269 return 0;
6270}
6271
6272/**
6273 * iw_set_auth() - set auth callback function
6274 * @dev: Pointer to the net device.
6275 * @info: Pointer to the iw_request_info.
6276 * @wrqu: Pointer to the iwreq_data.
6277 * @extra: Pointer to the data.
6278 *
6279 * Return: 0 for success, error number on failure.
6280 */
6281int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
6282 union iwreq_data *wrqu, char *extra)
6283{
6284 int ret;
6285
6286 cds_ssr_protect(__func__);
6287 ret = __iw_set_auth(dev, info, wrqu, extra);
6288 cds_ssr_unprotect(__func__);
6289
6290 return ret;
6291}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006292/**
6293 * __iw_get_auth() -
6294 * This function returns the auth type to the wpa_supplicant
6295 * @dev: pointer to the net device
6296 * @info: pointer to the iw request info
6297 * @wrqu: pointer to iwreq_data
6298 * @extra: pointer to the data
6299 *
6300 * Return: 0 on success, error number otherwise
6301 */
6302static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6303 union iwreq_data *wrqu, char *extra)
6304{
6305 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
6306 hdd_context_t *hdd_ctx;
6307 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6308 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
6309 int ret;
6310
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006311 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006312
6313 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
6314 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306315 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006316 return ret;
6317
Jeff Johnson441e1f72017-02-07 08:50:49 -08006318 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6319 if (0 != ret)
6320 return ret;
6321
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006322 switch (pRoamProfile->negotiatedAuthType) {
6323 case eCSR_AUTH_TYPE_WPA_NONE:
6324 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6325 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
6326 break;
6327 case eCSR_AUTH_TYPE_WPA:
6328 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6329 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
6330 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006331
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006332 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006333 case eCSR_AUTH_TYPE_RSN:
6334 wrqu->param.flags = IW_AUTH_WPA_VERSION;
6335 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
6336 break;
6337 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
6338 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6339 break;
6340 case eCSR_AUTH_TYPE_SHARED_KEY:
6341 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
6342 break;
6343 case eCSR_AUTH_TYPE_UNKNOWN:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006344 hdd_debug("called with unknown auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006345 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6346 break;
6347 case eCSR_AUTH_TYPE_AUTOSWITCH:
6348 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6349 break;
6350 case eCSR_AUTH_TYPE_WPA_PSK:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006351 hdd_debug("called with WPA PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006352 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6353 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08006354
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006355 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006356 case eCSR_AUTH_TYPE_RSN_PSK:
6357#ifdef WLAN_FEATURE_11W
6358 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
6359 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
6360#endif
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006361 hdd_debug("called with RSN PSK auth type");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006362 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6363 return -EIO;
6364 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006365 hdd_warn("Unknown auth type: %d",
6366 pRoamProfile->negotiatedAuthType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006367 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
6368 return -EIO;
6369 }
6370 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
6371 switch (pRoamProfile->negotiatedUCEncryptionType) {
6372 case eCSR_ENCRYPT_TYPE_NONE:
6373 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6374 break;
6375 case eCSR_ENCRYPT_TYPE_WEP40:
6376 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6377 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6378 break;
6379 case eCSR_ENCRYPT_TYPE_TKIP:
6380 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6381 break;
6382 case eCSR_ENCRYPT_TYPE_WEP104:
6383 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6384 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6385 break;
6386 case eCSR_ENCRYPT_TYPE_AES:
6387 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6388 break;
6389 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006390 hdd_warn("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006391 pRoamProfile->negotiatedUCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006392 return -EIO;
6393 }
6394 }
6395
6396 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
6397 switch (pRoamProfile->negotiatedMCEncryptionType) {
6398 case eCSR_ENCRYPT_TYPE_NONE:
6399 wrqu->param.value = IW_AUTH_CIPHER_NONE;
6400 break;
6401 case eCSR_ENCRYPT_TYPE_WEP40:
6402 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
6403 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
6404 break;
6405 case eCSR_ENCRYPT_TYPE_TKIP:
6406 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
6407 break;
6408 case eCSR_ENCRYPT_TYPE_WEP104:
6409 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
6410 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
6411 break;
6412 case eCSR_ENCRYPT_TYPE_AES:
6413 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
6414 break;
6415 default:
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006416 hdd_err("called with unknown auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006417 pRoamProfile->negotiatedMCEncryptionType);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006418 return -EIO;
6419 }
6420 }
6421
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006422 hdd_debug("called with auth type %d",
Archana Ramachandran75c1ca72016-08-22 17:20:25 -07006423 pRoamProfile->AuthType.authType[0]);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006424 EXIT();
6425 return 0;
6426}
6427
6428/**
6429 * iw_get_auth() - get auth callback function
6430 * @dev: Pointer to the net device.
6431 * @info: Pointer to the iw_request_info.
6432 * @wrqu: Pointer to the iwreq_data.
6433 * @extra: Pointer to the data.
6434 *
6435 * Return: 0 for success, error number on failure.
6436 */
6437int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
6438 union iwreq_data *wrqu, char *extra)
6439{
6440 int ret;
6441
6442 cds_ssr_protect(__func__);
6443 ret = __iw_get_auth(dev, info, wrqu, extra);
6444 cds_ssr_unprotect(__func__);
6445
6446 return ret;
6447}
6448
6449/**
6450 * __iw_set_ap_address() - set ap address
6451 * @dev: pointer to the net device
6452 * @info: pointer to the iw request info
6453 * @wrqu: pointer to iwreq_data
6454 * @extra: pointer to the data
6455 *
6456 * This function updates the HDD global station context connection info
6457 * BSSID with the MAC address received from the wpa_supplicant.
6458 *
6459 * Return: 0 on success, error number otherwise
6460 */
6461static int __iw_set_ap_address(struct net_device *dev,
6462 struct iw_request_info *info,
6463 union iwreq_data *wrqu, char *extra)
6464{
6465
6466 hdd_adapter_t *adapter;
6467 hdd_context_t *hdd_ctx;
6468 hdd_station_ctx_t *pHddStaCtx =
6469 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
6470 uint8_t *pMacAddress = NULL;
6471 int ret;
6472
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006473 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006474
6475 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6476
6477 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6478 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306479 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006480 return ret;
6481
Jeff Johnson441e1f72017-02-07 08:50:49 -08006482 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6483 if (0 != ret)
6484 return ret;
6485
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006486 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
Srinivas Girigowda6c8769d2017-03-19 22:54:18 -07006487 hdd_debug(" " MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306488 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306489 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006490 EXIT();
6491
6492 return 0;
6493}
6494
6495/**
6496 * iw_set_ap_address() - set ap addresses callback function
6497 * @dev: Pointer to the net device.
6498 * @info: Pointer to the iw_request_info.
6499 * @wrqu: Pointer to the iwreq_data.
6500 * @extra: Pointer to the data.
6501 *
6502 * Return: 0 for success, error number on failure.
6503 */
6504int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
6505 union iwreq_data *wrqu, char *extra)
6506{
6507 int ret;
6508
6509 cds_ssr_protect(__func__);
6510 ret = __iw_set_ap_address(dev, info, wrqu, extra);
6511 cds_ssr_unprotect(__func__);
6512
6513 return ret;
6514}
6515
6516/**
6517 * __iw_get_ap_address() - get ap address
6518 * @dev: pointer to the net device
6519 * @info: pointer to the iw request info
6520 * @wrqu: pointer to iwreq_data
6521 * @extra: pointer to the data
6522 *
6523 * This function returns currently associated BSSID.
6524 *
6525 * Return: 0 on success, error number otherwise
6526 */
6527static int __iw_get_ap_address(struct net_device *dev,
6528 struct iw_request_info *info,
6529 union iwreq_data *wrqu, char *extra)
6530{
6531 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
6532 hdd_context_t *hdd_ctx;
6533 hdd_station_ctx_t *pHddStaCtx =
6534 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6535 int ret;
6536
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08006537 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006538
6539 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
6540 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05306541 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006542 return ret;
6543
Jeff Johnson441e1f72017-02-07 08:50:49 -08006544 ret = hdd_check_standard_wext_control(hdd_ctx, info);
6545 if (0 != ret)
6546 return ret;
6547
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006548 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
6549 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05306550 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006551 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05306552 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08006553 } else {
6554 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
6555 }
6556 EXIT();
6557 return 0;
6558}
6559
6560/**
6561 * iw_get_ap_address() - get ap addresses callback function
6562 * @dev: Pointer to the net device.
6563 * @info: Pointer to the iw_request_info.
6564 * @wrqu: Pointer to the iwreq_data.
6565 * @extra: Pointer to the data.
6566 *
6567 * Return: 0 for success, error number on failure.
6568 */
6569int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
6570 union iwreq_data *wrqu, char *extra)
6571{
6572 int ret;
6573
6574 cds_ssr_protect(__func__);
6575 ret = __iw_get_ap_address(dev, info, wrqu, extra);
6576 cds_ssr_unprotect(__func__);
6577
6578 return ret;
6579}