blob: 5b1a322404006cf42e3fc1bb4c7219faf462cecb [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002 * Copyright (c) 2012-2016 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"
47#ifdef FEATURE_WLAN_TDLS
48#include "wlan_hdd_tdls.h"
49#endif
50#include "sme_api.h"
51#include "wlan_hdd_hostapd.h"
52#include <wlan_hdd_ipa.h>
53#include <cds_sched.h>
54#include "cds_concurrency.h"
55#include "sme_power_save_api.h"
56#include "ol_txrx_ctrl_api.h"
57#include "ol_txrx_types.h"
Dhanashri Atre182b0272016-02-17 15:35:07 -080058#include "ol_txrx.h"
Dhanashri Atreb08959a2016-03-01 17:28:03 -080059#include "cdp_txrx_flow_ctrl_legacy.h"
60#include "cdp_txrx_peer_ops.h"
Prakash Dhavali7090c5f2015-11-02 17:55:19 -080061
62/* These are needed to recognize WPA and RSN suite types */
63#define HDD_WPA_OUI_SIZE 4
64#define HDD_RSN_OUI_SIZE 4
65uint8_t ccp_wpa_oui00[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x00 };
66uint8_t ccp_wpa_oui01[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x01 };
67uint8_t ccp_wpa_oui02[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x02 };
68uint8_t ccp_wpa_oui03[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x03 };
69uint8_t ccp_wpa_oui04[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x04 };
70uint8_t ccp_wpa_oui05[HDD_WPA_OUI_SIZE] = { 0x00, 0x50, 0xf2, 0x05 };
71
72#ifdef FEATURE_WLAN_ESE
73/* CCKM */
74uint8_t ccp_wpa_oui06[HDD_WPA_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
75/* CCKM */
76uint8_t ccp_rsn_oui06[HDD_RSN_OUI_SIZE] = { 0x00, 0x40, 0x96, 0x00 };
77#endif /* FEATURE_WLAN_ESE */
78
79/* group cipher */
80uint8_t ccp_rsn_oui00[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x00 };
81
82/* WEP-40 or RSN */
83uint8_t ccp_rsn_oui01[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x01 };
84
85/* TKIP or RSN-PSK */
86uint8_t ccp_rsn_oui02[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x02 };
87
88/* Reserved */
89uint8_t ccp_rsn_oui03[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x03 };
90
91/* AES-CCMP */
92uint8_t ccp_rsn_oui04[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x04 };
93
94/* WEP-104 */
95uint8_t ccp_rsn_oui05[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
96
97#ifdef WLAN_FEATURE_11W
98/* RSN-PSK-SHA256 */
99uint8_t ccp_rsn_oui07[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x06 };
100
101/* RSN-8021X-SHA256 */
102uint8_t ccp_rsn_oui08[HDD_RSN_OUI_SIZE] = { 0x00, 0x0F, 0xAC, 0x05 };
103#endif
104
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800105/* Offset where the EID-Len-IE, start. */
106#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2) */
107#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800108
109#define BEACON_FRAME_IES_OFFSET 12
110#define HDD_PEER_AUTHORIZE_WAIT 10
111
112/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700113 * beacon_filter_table - table of IEs used for beacon filtering
114 */
115static const int beacon_filter_table[] = {
116 SIR_MAC_DS_PARAM_SET_EID,
117 SIR_MAC_ERP_INFO_EID,
118 SIR_MAC_EDCA_PARAM_SET_EID,
119 SIR_MAC_QOS_CAPABILITY_EID,
120 SIR_MAC_HT_INFO_EID,
121 SIR_MAC_VHT_OPMODE_EID,
122 SIR_MAC_VHT_OPERATION_EID,
123};
124
125/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800126 * hdd_conn_set_authenticated() - set authentication state
127 * @pAdapter: pointer to the adapter
128 * @authState: authentication state
129 *
130 * This function updates the global HDD station context
131 * authentication state.
132 *
133 * Return: none
134 */
135static void
136hdd_conn_set_authenticated(hdd_adapter_t *pAdapter, uint8_t authState)
137{
138 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
139 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
140
141 /* save the new connection state */
142 hddLog(LOG1,
143 FL("Authenticated state Changed from oldState:%d to State:%d"),
144 pHddStaCtx->conn_info.uIsAuthenticated, authState);
145 pHddStaCtx->conn_info.uIsAuthenticated = authState;
146
147 /* Check is pending ROC request or not when auth state changed */
148 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
149}
150
151/**
152 * hdd_conn_set_connection_state() - set connection state
153 * @pAdapter: pointer to the adapter
154 * @connState: connection state
155 *
156 * This function updates the global HDD station context connection state.
157 *
158 * Return: none
159 */
160void hdd_conn_set_connection_state(hdd_adapter_t *pAdapter,
161 eConnectionState connState)
162{
163 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
164 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
165
166 /* save the new connection state */
Abhishek Singh23edd1c2016-05-05 11:56:06 +0530167 hdd_info("%pS Changed connectionState Changed from oldState:%d to State:%d",
168 (void *)_RET_IP_, pHddStaCtx->conn_info.connState,
169 connState);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800170 pHddStaCtx->conn_info.connState = connState;
171
172 /* Check is pending ROC request or not when connection state changed */
173 schedule_delayed_work(&pHddCtx->roc_req_work, 0);
174}
175
176/**
177 * hdd_conn_get_connection_state() - get connection state
178 * @pAdapter: pointer to the adapter
179 * @pConnState: pointer to connection state
180 *
181 * This function updates the global HDD station context connection state.
182 *
183 * Return: true if (Infra Associated or IBSS Connected)
184 * and sets output parameter pConnState;
185 * false otherwise
186 */
187static inline bool hdd_conn_get_connection_state(hdd_station_ctx_t *pHddStaCtx,
188 eConnectionState *pConnState)
189{
190 bool fConnected = false;
191 eConnectionState connState;
192
193 /* get the connection state. */
194 connState = pHddStaCtx->conn_info.connState;
195
196 if (eConnectionState_Associated == connState ||
197 eConnectionState_IbssConnected == connState ||
198 eConnectionState_IbssDisconnected == connState) {
199 fConnected = true;
200 }
201
202 if (pConnState)
203 *pConnState = connState;
204
205 return fConnected;
206}
207
208/**
209 * hdd_is_connecting() - Function to check connection progress
210 * @hdd_sta_ctx: pointer to global HDD Station context
211 *
212 * Return: true if connecting, false otherwise
213 */
214bool hdd_is_connecting(hdd_station_ctx_t *hdd_sta_ctx)
215{
216 return hdd_sta_ctx->conn_info.connState ==
217 eConnectionState_Connecting;
218}
219
220/**
221 * hdd_conn_is_connected() - Function to check connection status
222 * @pHddStaCtx: pointer to global HDD Station context
223 *
224 * Return: false if any errors encountered, true otherwise
225 */
226bool hdd_conn_is_connected(hdd_station_ctx_t *pHddStaCtx)
227{
228 return hdd_conn_get_connection_state(pHddStaCtx, NULL);
229}
230
231/**
232 * hdd_conn_get_connected_band() - get current connection radio band
233 * @pHddStaCtx: pointer to global HDD Station context
234 *
235 * Return: eCSR_BAND_24 or eCSR_BAND_5G based on current AP connection
236 * eCSR_BAND_ALL if not connected
237 */
238eCsrBand hdd_conn_get_connected_band(hdd_station_ctx_t *pHddStaCtx)
239{
240 uint8_t staChannel = 0;
241
242 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
243 staChannel = pHddStaCtx->conn_info.operationChannel;
244
245 if (staChannel > 0 && staChannel < 14)
246 return eCSR_BAND_24;
247 else if (staChannel >= 36 && staChannel <= 184)
248 return eCSR_BAND_5G;
249 else /* If station is not connected return as eCSR_BAND_ALL */
250 return eCSR_BAND_ALL;
251}
252
253/**
254 * hdd_conn_get_connected_cipher_algo() - get current connection cipher type
255 * @pHddStaCtx: pointer to global HDD Station context
256 * @pConnectedCipherAlgo: pointer to connected cipher algo
257 *
258 * Return: false if any errors encountered, true otherwise
259 */
260static inline bool
261hdd_conn_get_connected_cipher_algo(hdd_station_ctx_t *pHddStaCtx,
262 eCsrEncryptionType *pConnectedCipherAlgo)
263{
264 bool fConnected = false;
265
266 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
267
268 if (pConnectedCipherAlgo)
269 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
270
271 return fConnected;
272}
273
274/**
275 * hdd_conn_get_connected_bss_type() - get current bss type
276 * @pHddStaCtx: pointer to global HDD Station context
277 * @pConnectedBssType: pointer to connected bss type
278 *
279 * Return: false if any errors encountered, true otherwise
280 */
281inline bool
282hdd_conn_get_connected_bss_type(hdd_station_ctx_t *pHddStaCtx,
283 eMib_dot11DesiredBssType *pConnectedBssType)
284{
285 bool fConnected = false;
286
287 fConnected = hdd_conn_get_connection_state(pHddStaCtx, NULL);
288
289 if (pConnectedBssType) {
290 *pConnectedBssType =
291 pHddStaCtx->conn_info.connDot11DesiredBssType;
292 }
293
294 return fConnected;
295}
296
297/**
298 * hdd_conn_save_connected_bss_type() - set connected bss type
299 * @pHddStaCtx: pointer to global HDD Station context
300 * @csr_roamBssType: bss type
301 *
302 * Return: none
303 */
304static inline void
305hdd_conn_save_connected_bss_type(hdd_station_ctx_t *pHddStaCtx,
306 eCsrRoamBssType csr_roamBssType)
307{
308 switch (csr_roamBssType) {
309 case eCSR_BSS_TYPE_INFRASTRUCTURE:
310 pHddStaCtx->conn_info.connDot11DesiredBssType =
311 eMib_dot11DesiredBssType_infrastructure;
312 break;
313
314 case eCSR_BSS_TYPE_IBSS:
315 case eCSR_BSS_TYPE_START_IBSS:
316 pHddStaCtx->conn_info.connDot11DesiredBssType =
317 eMib_dot11DesiredBssType_independent;
318 break;
319
320 /** We will never set the BssType to 'any' when attempting a connection
321 so CSR should never send this back to us.*/
322 case eCSR_BSS_TYPE_ANY:
323 default:
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530324 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800325 break;
326 }
327}
328
329/**
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -0700330 * hdd_remove_beacon_filter() - remove beacon filter
331 * @adapter: Pointer to the hdd adapter
332 *
333 * Return: 0 on success and errno on failure
334 */
335static int hdd_remove_beacon_filter(hdd_adapter_t *adapter)
336{
337 QDF_STATUS status;
338 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
339
340 status = sme_remove_beacon_filter(hdd_ctx->hHal,
341 adapter->sessionId);
342 if (!QDF_IS_STATUS_SUCCESS(status)) {
343 hdd_err("sme_remove_beacon_filter() failed");
344 return -EFAULT;
345 }
346
347 return 0;
348}
349
350/**
351 * hdd_add_beacon_filter() - add beacon filter
352 * @adapter: Pointer to the hdd adapter
353 *
354 * Return: 0 on success and errno on failure
355 */
356static int hdd_add_beacon_filter(hdd_adapter_t *adapter)
357{
358 int i;
359 uint32_t ie_map[SIR_BCN_FLT_MAX_ELEMS_IE_LIST] = {0};
360 QDF_STATUS status;
361 hdd_context_t *hdd_ctx = WLAN_HDD_GET_CTX(adapter);
362
363 for (i = 0; i < ARRAY_SIZE(beacon_filter_table); i++)
364 qdf_set_bit((beacon_filter_table[i] - 1),
365 (unsigned long int *)ie_map);
366
367 status = sme_add_beacon_filter(hdd_ctx->hHal,
368 adapter->sessionId, ie_map);
369 if (!QDF_IS_STATUS_SUCCESS(status)) {
370 hdd_err("sme_add_beacon_filter() failed");
371 return -EFAULT;
372 }
373 return 0;
374}
375
376/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800377 * hdd_conn_save_connect_info() - save current connection information
378 * @pAdapter: pointer to adapter
379 * @pRoamInfo: pointer to roam info
380 * @eBssType: bss type
381 *
382 * Return: none
383 */
384static void
385hdd_conn_save_connect_info(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
386 eCsrRoamBssType eBssType)
387{
388 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
389 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
390
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530391 QDF_ASSERT(pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800392
393 if (pRoamInfo) {
394 /* Save the BSSID for the connection */
395 if (eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530396 QDF_ASSERT(pRoamInfo->pBssDesc);
Anurag Chouhanc5548422016-02-24 18:33:27 +0530397 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800398 &pRoamInfo->bssid);
399
400 /*
401 * Save the Station ID for this station from
402 * the 'Roam Info'. For IBSS mode, staId is
403 * assigned in NEW_PEER_IND. For reassoc,
404 * the staID doesn't change and it may be invalid
405 * in this structure so no change here.
406 */
407 if (!pRoamInfo->fReassocReq) {
408 pHddStaCtx->conn_info.staId[0] =
409 pRoamInfo->staId;
410 }
411 } else if (eCSR_BSS_TYPE_IBSS == eBssType) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530412 qdf_copy_macaddr(&pHddStaCtx->conn_info.bssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800413 &pRoamInfo->bssid);
414 } else {
415 /*
416 * can't happen. We need a valid IBSS or Infra setting
417 * in the BSSDescription or we can't function.
418 */
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530419 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800420 }
421
422 /* notify WMM */
423 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
424
425 if (!pRoamInfo->u.pConnectedProfile) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +0530426 QDF_ASSERT(pRoamInfo->u.pConnectedProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800427 } else {
428 /* Get Multicast Encryption Type */
429 encryptType =
430 pRoamInfo->u.pConnectedProfile->mcEncryptionType;
431 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
432 /* Get Unicast Encryption Type */
433 encryptType =
434 pRoamInfo->u.pConnectedProfile->EncryptionType;
435 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
436
437 pHddStaCtx->conn_info.authType =
438 pRoamInfo->u.pConnectedProfile->AuthType;
439
440 pHddStaCtx->conn_info.operationChannel =
441 pRoamInfo->u.pConnectedProfile->operationChannel;
442
443 /* Save the ssid for the connection */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530444 qdf_mem_copy(&pHddStaCtx->conn_info.SSID.SSID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800445 &pRoamInfo->u.pConnectedProfile->SSID,
446 sizeof(tSirMacSSid));
447
448 /* Save dot11mode in which STA associated to AP */
449 pHddStaCtx->conn_info.dot11Mode =
450 pRoamInfo->u.pConnectedProfile->dot11Mode;
451
452 pHddStaCtx->conn_info.proxyARPService =
453 pRoamInfo->u.pConnectedProfile->proxyARPService;
Kanchanapally, Vidyullathae3062812015-05-22 17:28:57 +0530454
455 pHddStaCtx->conn_info.nss = pRoamInfo->chan_info.nss;
456
457 pHddStaCtx->conn_info.rate_flags =
458 pRoamInfo->chan_info.rate_flags;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800459 }
460 }
461 /* save the connected BssType */
462 hdd_conn_save_connected_bss_type(pHddStaCtx, eBssType);
463}
464
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800465/**
466 * hdd_send_ft_assoc_response() - send fast transition assoc response
467 * @dev: pointer to net device
468 * @pAdapter: pointer to adapter
469 * @pCsrRoamInfo: pointer to roam info
470 *
471 * Send the 11R key information to the supplicant. Only then can the supplicant
472 * generate the PMK-R1. (BTW, the ESE supplicant also needs the Assoc Resp IEs
473 * for the same purpose.)
474 *
475 * Mainly the Assoc Rsp IEs are passed here. For the IMDA this contains the
476 * R1KHID, R0KHID and the MDID. For FT, this consists of the Reassoc Rsp FTIEs.
477 * This is the Assoc Response.
478 *
479 * Return: none
480 */
481static void
482hdd_send_ft_assoc_response(struct net_device *dev,
483 hdd_adapter_t *pAdapter,
484 tCsrRoamInfo *pCsrRoamInfo)
485{
486 union iwreq_data wrqu;
487 char *buff;
488 unsigned int len = 0;
489 u8 *pFTAssocRsp = NULL;
490
491 if (pCsrRoamInfo->nAssocRspLength == 0) {
492 hddLog(LOGE,
493 FL("pCsrRoamInfo->nAssocRspLength=%d"),
494 (int)pCsrRoamInfo->nAssocRspLength);
495 return;
496 }
497
498 pFTAssocRsp =
499 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
500 pCsrRoamInfo->nAssocReqLength);
501 if (pFTAssocRsp == NULL) {
502 hddLog(LOGE, FL("AssocReq or AssocRsp is NULL"));
503 return;
504 }
505 /* pFTAssocRsp needs to point to the IEs */
506 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
507 hddLog(LOG1, FL("AssocRsp is now at %02x%02x"),
508 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
509
510 /* We need to send the IEs to the supplicant. */
511 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
512 if (buff == NULL) {
513 hddLog(LOGE, FL("kmalloc unable to allocate memory"));
514 return;
515 }
516 /* Send the Assoc Resp, the supplicant needs this for initial Auth. */
517 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
518 wrqu.data.length = len;
519 memset(buff, 0, IW_GENERIC_IE_MAX);
520 memcpy(buff, pFTAssocRsp, len);
521 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
522
523 kfree(buff);
524}
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800525
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800526/**
527 * hdd_send_ft_event() - send fast transition event
528 * @pAdapter: pointer to adapter
529 *
530 * Send the FTIEs, RIC IEs during FT. This is eventually used to send the
531 * FT events to the supplicant. At the reception of Auth2 we send the RIC
532 * followed by the auth response IEs to the supplicant.
533 * Once both are received in the supplicant, an FT event is generated
534 * to the supplicant.
535 *
536 * Return: none
537 */
538static void hdd_send_ft_event(hdd_adapter_t *pAdapter)
539{
540 uint16_t auth_resp_len = 0;
541 uint32_t ric_ies_length = 0;
542 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
543
544#if defined(KERNEL_SUPPORT_11R_CFG80211)
545 struct cfg80211_ft_event_params ftEvent;
546 uint8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
547 uint8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
548 struct net_device *dev = pAdapter->dev;
549#else
550 char *buff;
551 union iwreq_data wrqu;
552 uint16_t str_len;
553#endif
554
555#if defined(KERNEL_SUPPORT_11R_CFG80211)
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530556 qdf_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
557 qdf_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800558
559 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId, (u8 *) ricIe,
560 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length);
561 if (ric_ies_length == 0) {
562 hddLog(LOGW,
563 FL("RIC IEs is of length 0 not sending RIC Information for now"));
564 }
565
566 ftEvent.ric_ies = ricIe;
567 ftEvent.ric_ies_len = ric_ies_length;
568 hddLog(LOG1, FL("RIC IEs is of length %d"), (int)ric_ies_length);
569
570 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
571 (u8 *) ftIe, DOT11F_IE_FTINFO_MAX_LEN,
572 &auth_resp_len);
573
574 if (auth_resp_len == 0) {
575 hddLog(LOGE, FL("AuthRsp FTIES is of length 0"));
576 return;
577 }
578
579 sme_set_ft_pre_auth_state(pHddCtx->hHal, pAdapter->sessionId, true);
580
581 ftEvent.target_ap = ftIe;
582
Anurag Chouhan6d760662016-02-20 16:05:43 +0530583 ftEvent.ies = (u8 *) (ftIe + QDF_MAC_ADDR_SIZE);
584 ftEvent.ies_len = auth_resp_len - QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800585
586 hddLog(LOG1, FL("ftEvent.ies_len %zu"), ftEvent.ies_len);
587 hddLog(LOG1, FL("ftEvent.ric_ies_len %zu"), ftEvent.ric_ies_len);
588 hddLog(LOG1, FL("ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x"),
589 ftEvent.target_ap[0], ftEvent.target_ap[1],
590 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
591 ftEvent.target_ap[5]);
592
593 (void)cfg80211_ft_event(dev, &ftEvent);
594
595#else
596 /* We need to send the IEs to the supplicant */
597 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
598 if (buff == NULL) {
599 hddLog(LOGE, FL("kmalloc unable to allocate memory"));
600 return;
601 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530602 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800603
604 /* Sme needs to send the RIC IEs first */
605 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
606 sme_get_rici_es(pHddCtx->hHal, pAdapter->sessionId,
607 (u8 *) &(buff[str_len]), (IW_CUSTOM_MAX - str_len),
608 &ric_ies_length);
609 if (ric_ies_length == 0) {
610 hddLog(LOGW,
611 FL("RIC IEs is of length 0 not sending RIC Information for now"));
612 } else {
613 wrqu.data.length = str_len + ric_ies_length;
614 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
615 }
616
617 /* Sme needs to provide the Auth Resp */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530618 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800619 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
620 sme_get_ft_pre_auth_response(pHddCtx->hHal, pAdapter->sessionId,
621 (u8 *) &buff[str_len],
622 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
623
624 if (auth_resp_len == 0) {
625 kfree(buff);
626 hddLog(LOGE, FL("AuthRsp FTIES is of length 0"));
627 return;
628 }
629
630 wrqu.data.length = str_len + auth_resp_len;
631 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
632
633 kfree(buff);
634#endif
635}
636
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800637#ifdef FEATURE_WLAN_ESE
638/**
639 * hdd_send_new_ap_channel_info() - send new ap channel info
640 * @dev: pointer to net device
641 * @pAdapter: pointer to adapter
642 * @pCsrRoamInfo: pointer to roam info
643 *
644 * Send the ESE required "new AP Channel info" to the supplicant.
645 * (This keeps the supplicant "up to date" on the current channel.)
646 *
647 * The current (new AP) channel information is passed in.
648 *
649 * Return: none
650 */
651static void
652hdd_send_new_ap_channel_info(struct net_device *dev, hdd_adapter_t *pAdapter,
653 tCsrRoamInfo *pCsrRoamInfo)
654{
655 union iwreq_data wrqu;
656 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
657
658 if (descriptor == NULL) {
659 hddLog(LOGE, FL("pCsrRoamInfo->pBssDesc(%p)"), descriptor);
660 return;
661 }
662 /*
663 * Send the Channel event, the supplicant needs this to generate
664 * the Adjacent AP report.
665 */
666 hddLog(LOGW, FL("Sending up an SIOCGIWFREQ, channelId(%d)"),
667 descriptor->channelId);
668 memset(&wrqu, '\0', sizeof(wrqu));
669 wrqu.freq.m = descriptor->channelId;
670 wrqu.freq.e = 0;
671 wrqu.freq.i = 0;
672 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
673}
674
675#endif /* FEATURE_WLAN_ESE */
676
677/**
678 * hdd_send_update_beacon_ies_event() - send update beacons ie event
679 * @pAdapter: pointer to adapter
680 * @pCsrRoamInfo: pointer to roam info
681 *
682 * Return: none
683 */
684static void
685hdd_send_update_beacon_ies_event(hdd_adapter_t *pAdapter,
686 tCsrRoamInfo *pCsrRoamInfo)
687{
688 union iwreq_data wrqu;
689 u8 *pBeaconIes;
690 u8 currentLen = 0;
691 char *buff;
692 int totalIeLen = 0, currentOffset = 0, strLen;
693
694 memset(&wrqu, '\0', sizeof(wrqu));
695
696 if (0 == pCsrRoamInfo->nBeaconLength) {
697 hddLog(LOGW, FL("pCsrRoamInfo->nBeaconFrameLength = 0"));
698 return;
699 }
700 pBeaconIes = (u8 *) (pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
701 if (pBeaconIes == NULL) {
702 hddLog(LOGW, FL("Beacon IEs is NULL"));
703 return;
704 }
705 /* pBeaconIes needs to point to the IEs */
706 hddLog(LOG1, FL("Beacon IEs is now at %02x%02x"),
707 (unsigned int)pBeaconIes[0], (unsigned int)pBeaconIes[1]);
708 hddLog(LOG1, FL("Beacon IEs length = %d"),
709 pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
710
711 /* We need to send the IEs to the supplicant. */
712 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
713 if (buff == NULL) {
714 hddLog(LOGE, FL("kmalloc unable to allocate memory"));
715 return;
716 }
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530717 qdf_mem_zero(buff, IW_CUSTOM_MAX);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800718
719 strLen = strlcpy(buff, "BEACONIEs=", IW_CUSTOM_MAX);
720 currentLen = strLen + 1;
721
722 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
723 do {
724 /*
725 * If the beacon size exceeds max CUSTOM event size, break it
726 * into chunks of CUSTOM event max size and send it to
727 * supplicant. Changes are done in supplicant to handle this.
728 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530729 qdf_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800730 currentLen =
Anurag Chouhan6d760662016-02-20 16:05:43 +0530731 QDF_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530732 qdf_mem_copy(&buff[strLen + 1], pBeaconIes + currentOffset,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800733 currentLen);
734 currentOffset += currentLen;
735 totalIeLen -= currentLen;
736 wrqu.data.length = strLen + 1 + currentLen;
737 if (totalIeLen)
738 buff[strLen] = 1; /* more chunks pending */
739 else
740 buff[strLen] = 0; /* last chunk */
741
742 hddLog(LOG1, FL("Beacon IEs length to supplicant = %d"),
743 currentLen);
744 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
745 } while (totalIeLen > 0);
746
747 kfree(buff);
748}
749
750/**
751 * hdd_send_association_event() - send association event
752 * @dev: pointer to net device
753 * @pCsrRoamInfo: pointer to roam info
754 *
755 * Return: none
756 */
757static void hdd_send_association_event(struct net_device *dev,
758 tCsrRoamInfo *pCsrRoamInfo)
759{
760 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
761 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
762 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
763 union iwreq_data wrqu;
764 int we_event;
765 char *msg;
Anurag Chouhan6d760662016-02-20 16:05:43 +0530766 struct qdf_mac_addr peerMacAddr;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800767
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800768 /* Added to find the auth type on the fly at run time */
769 /* rather than with cfg to see if FT is enabled */
770 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
771 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800772
773 memset(&wrqu, '\0', sizeof(wrqu));
774 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
775 we_event = SIOCGIWAP;
776#ifdef WLAN_FEATURE_ROAM_OFFLOAD
777 if (NULL != pCsrRoamInfo)
778 if (pCsrRoamInfo->roamSynchInProgress)
779 /* change logging before release */
780 hddLog(LOG4, "LFR3:hdd_send_association_event");
781#endif
782 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState) {
783 if (!pCsrRoamInfo) {
784 hddLog(LOGE, FL("STA in associated state but pCsrRoamInfo is null"));
785 return;
786 }
787
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -0800788 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
789 cds_incr_active_session(pAdapter->device_mode,
790 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800791 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId,
792 sizeof(pCsrRoamInfo->pBssDesc->bssId));
793
794#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -0800795 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800796 if (global_p2p_connection_status ==
797 P2P_CLIENT_CONNECTING_STATE_1) {
798 global_p2p_connection_status =
799 P2P_CLIENT_CONNECTED_STATE_1;
800 hddLog(LOGE,
801 "[P2P State] Changing state from Connecting state to Connected State for 8-way Handshake");
802 } else if (global_p2p_connection_status ==
803 P2P_CLIENT_CONNECTING_STATE_2) {
804 global_p2p_connection_status =
805 P2P_CLIENT_COMPLETED_STATE;
806 hddLog(LOGE,
807 "[P2P State] Changing state from Connecting state to P2P Client Connection Completed");
808 }
809 }
810#endif
811 pr_info("wlan: " MAC_ADDRESS_STR " connected to "
812 MAC_ADDRESS_STR "\n",
813 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
814 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
815 hdd_send_update_beacon_ies_event(pAdapter, pCsrRoamInfo);
816
817 /*
818 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS
819 * is Enabled Or Send IWEVASSOCRESPIE Event if
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -0800820 * fFTEnable is true.
821 * Send FT Keys to the supplicant when FT is enabled
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800822 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800823 if ((pRoamProfile->AuthType.authType[0] ==
824 eCSR_AUTH_TYPE_FT_RSN_PSK)
825 || (pRoamProfile->AuthType.authType[0] ==
826 eCSR_AUTH_TYPE_FT_RSN)
827#ifdef FEATURE_WLAN_ESE
828 || (pRoamProfile->AuthType.authType[0] ==
829 eCSR_AUTH_TYPE_CCKM_RSN)
830 || (pRoamProfile->AuthType.authType[0] ==
831 eCSR_AUTH_TYPE_CCKM_WPA)
832#endif
833 ) {
834 hdd_send_ft_assoc_response(dev, pAdapter, pCsrRoamInfo);
835 }
Krunal Sonibe766b02016-03-10 13:00:44 -0800836 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800837 tSirSmeChanInfo chan_info;
Anurag Chouhanc5548422016-02-24 18:33:27 +0530838 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800839 &pHddStaCtx->conn_info.bssId);
840 chan_info.chan_id = pCsrRoamInfo->chan_info.chan_id;
841 chan_info.mhz = pCsrRoamInfo->chan_info.mhz;
842 chan_info.info = pCsrRoamInfo->chan_info.info;
843 chan_info.band_center_freq1 =
844 pCsrRoamInfo->chan_info.band_center_freq1;
845 chan_info.band_center_freq2 =
846 pCsrRoamInfo->chan_info.band_center_freq2;
847 chan_info.reg_info_1 =
848 pCsrRoamInfo->chan_info.reg_info_1;
849 chan_info.reg_info_2 =
850 pCsrRoamInfo->chan_info.reg_info_2;
851
852 /* send peer status indication to oem app */
853 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
854 ePeerConnected,
855 pCsrRoamInfo->
856 timingMeasCap,
857 pAdapter->sessionId,
858 &chan_info);
859 }
860#ifdef MSM_PLATFORM
861#ifdef CONFIG_CNSS
862 /* start timer in sta/p2p_cli */
863 spin_lock_bh(&pHddCtx->bus_bw_lock);
864 pAdapter->prev_tx_packets = pAdapter->stats.tx_packets;
865 pAdapter->prev_rx_packets = pAdapter->stats.rx_packets;
866 spin_unlock_bh(&pHddCtx->bus_bw_lock);
867 hdd_start_bus_bw_compute_timer(pAdapter);
868#endif
869#endif
870 } else if (eConnectionState_IbssConnected == /* IBss Associated */
871 pHddStaCtx->conn_info.connState) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800872 cds_update_connection_info(pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800873 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId.bytes,
874 ETH_ALEN);
875 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR "\n",
876 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes));
877 } else { /* Not Associated */
878
879 pr_info("wlan: disconnected\n");
880 memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN);
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +0530881 cds_decr_session_set_pcl(pAdapter->device_mode,
882 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800883 wlan_hdd_enable_roaming(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800884
885#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
886 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
887#endif
888
Krunal Sonibe766b02016-03-10 13:00:44 -0800889 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Anurag Chouhanc5548422016-02-24 18:33:27 +0530890 qdf_copy_macaddr(&peerMacAddr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800891 &pHddStaCtx->conn_info.bssId);
892
893 /* send peer status indication to oem app */
894 hdd_send_peer_status_ind_to_oem_app(&peerMacAddr,
895 ePeerDisconnected, 0,
896 pAdapter->sessionId,
897 NULL);
898 }
899#ifdef WLAN_FEATURE_LPSS
900 pAdapter->rssi_send = false;
901 wlan_hdd_send_status_pkg(pAdapter, pHddStaCtx, 1, 0);
902#endif
903#ifdef FEATURE_WLAN_TDLS
Krunal Sonibe766b02016-03-10 13:00:44 -0800904 if ((pAdapter->device_mode == QDF_STA_MODE) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800905 (pCsrRoamInfo)) {
906 hddLog(LOG4,
907 FL("tdls_prohibited: %d, tdls_chan_swit_prohibited: %d"),
908 pCsrRoamInfo->tdls_prohibited,
909 pCsrRoamInfo->tdls_chan_swit_prohibited);
910
911 wlan_hdd_update_tdls_info(pAdapter,
912 pCsrRoamInfo->tdls_prohibited,
913 pCsrRoamInfo->tdls_chan_swit_prohibited);
914 }
915#endif
916#ifdef MSM_PLATFORM
917 /* stop timer in sta/p2p_cli */
918 spin_lock_bh(&pHddCtx->bus_bw_lock);
919 pAdapter->prev_tx_packets = 0;
920 pAdapter->prev_rx_packets = 0;
921 spin_unlock_bh(&pHddCtx->bus_bw_lock);
922 hdd_stop_bus_bw_compute_timer(pAdapter);
923#endif
924 }
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -0800925 cds_dump_concurrency_info();
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800926 /* Send SCC/MCC Switching event to IPA */
927 hdd_ipa_send_mcc_scc_msg(pHddCtx, pHddCtx->mcc_mode);
928
929 msg = NULL;
930 /*During the WLAN uninitialization,supplicant is stopped before the
931 driver so not sending the status of the connection to supplicant */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -0800932 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800933 wireless_send_event(dev, we_event, &wrqu, msg);
934#ifdef FEATURE_WLAN_ESE
935 if (eConnectionState_Associated ==
936 pHddStaCtx->conn_info.connState) {
937 if ((pRoamProfile->AuthType.authType[0] ==
938 eCSR_AUTH_TYPE_CCKM_RSN) ||
939 (pRoamProfile->AuthType.authType[0] ==
940 eCSR_AUTH_TYPE_CCKM_WPA))
941 hdd_send_new_ap_channel_info(dev, pAdapter,
942 pCsrRoamInfo);
943 }
944#endif
945 }
946}
947
948/**
949 * hdd_conn_remove_connect_info() - remove connection info
950 * @pHddStaCtx: pointer to global HDD station context
951 * @pCsrRoamInfo: pointer to roam info
952 *
953 * Return: none
954 */
955static void hdd_conn_remove_connect_info(hdd_station_ctx_t *pHddStaCtx)
956{
957 /* Remove staId, bssId and peerMacAddress */
958 pHddStaCtx->conn_info.staId[0] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530959 qdf_mem_zero(&pHddStaCtx->conn_info.bssId, QDF_MAC_ADDR_SIZE);
960 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[0],
Anurag Chouhan6d760662016-02-20 16:05:43 +0530961 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800962
963 /* Clear all security settings */
964 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
965 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
966 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
967
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530968 qdf_mem_zero(&pHddStaCtx->conn_info.Keys, sizeof(tCsrKeys));
969 qdf_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800970
971 /* Set not-connected state */
972 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
973 pHddStaCtx->conn_info.proxyARPService = 0;
974
Anurag Chouhan600c3a02016-03-01 10:33:54 +0530975 qdf_mem_zero(&pHddStaCtx->conn_info.SSID, sizeof(tCsrSSIDInfo));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800976}
977
978/**
979 * hdd_roam_deregister_sta() - deregister station
980 * @pAdapter: pointer to adapter
981 * @staId: station identifier
982 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530983 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800984 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530985static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800986hdd_roam_deregister_sta(hdd_adapter_t *pAdapter, uint8_t staId)
987{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530988 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -0800989 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
990
991 if (eConnectionState_IbssDisconnected ==
992 pHddStaCtx->conn_info.connState) {
993 /*
994 * Do not set the carrier off when the last peer leaves.
995 * We will set the carrier off while stopping the IBSS.
996 */
997 }
998
Anurag Chouhanfb54ab02016-02-18 18:00:46 +0530999 qdf_status = ol_txrx_clear_peer(staId);
1000 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001001 hddLog(LOGE,
1002 FL("ol_txrx_clear_peer() failed for staID %d. Status(%d) [0x%08X]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301003 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001004 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301005 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001006}
1007
1008/**
1009 * hdd_dis_connect_handler() - disconnect event handler
1010 * @pAdapter: pointer to adapter
1011 * @pRoamInfo: pointer to roam info
1012 * @roamId: roam identifier
1013 * @roamStatus: roam status
1014 * @roamResult: roam result
1015 *
1016 * This function handles disconnect event:
1017 * 1. Disable transmit queues;
1018 * 2. Clean up internal connection states and data structures;
1019 * 3. Send disconnect indication to supplicant.
1020 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301021 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001022 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301023static QDF_STATUS hdd_dis_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001024 tCsrRoamInfo *pRoamInfo,
1025 uint32_t roamId,
1026 eRoamCmdStatus roamStatus,
1027 eCsrRoamResult roamResult)
1028{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301029 QDF_STATUS status = QDF_STATUS_SUCCESS;
1030 QDF_STATUS vstatus;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001031 struct net_device *dev = pAdapter->dev;
1032 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1033 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1034 uint8_t sta_id;
1035 bool sendDisconInd = true;
1036
1037 if (dev == NULL) {
1038 hddLog(LOGE, FL("net_dev is released return"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301039 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001040 }
1041 /* notify apps that we can't pass traffic anymore */
1042 hddLog(LOG1, FL("Disabling queues"));
1043 wlan_hdd_netif_queue_control(pAdapter, WLAN_NETIF_TX_DISABLE_N_CARRIER,
1044 WLAN_CONTROL_PATH);
1045
1046 if (hdd_ipa_is_enabled(pHddCtx))
1047 hdd_ipa_wlan_evt(pAdapter, pHddStaCtx->conn_info.staId[0],
1048 WLAN_STA_DISCONNECT,
1049 pHddStaCtx->conn_info.bssId.bytes);
1050
1051#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1052 wlan_hdd_auto_shutdown_enable(pHddCtx, true);
1053#endif
1054
1055#ifdef QCA_PKT_PROTO_TRACE
1056 /* STA disconnected, update into trace buffer */
1057 if (pHddCtx->config->gEnableDebugLog)
1058 cds_pkt_trace_buf_update("ST:DISASC");
1059#endif /* QCA_PKT_PROTO_TRACE */
1060
1061 /* HDD has initiated disconnect, do not send disconnect indication
1062 * to kernel. Sending disconnected event to kernel for userspace
1063 * initiated disconnect will be handled by hdd_DisConnectHandler call
1064 * to cfg80211_disconnected.
1065 */
1066 if ((eConnectionState_Disconnecting ==
1067 pHddStaCtx->conn_info.connState) ||
1068 (eConnectionState_NotConnected ==
1069 pHddStaCtx->conn_info.connState)) {
1070 hddLog(LOG1,
1071 FL("HDD has initiated a disconnect, no need to send disconnect indication to kernel"));
1072 sendDisconInd = false;
1073 }
1074
1075 if (pHddStaCtx->conn_info.connState != eConnectionState_Disconnecting) {
1076 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001077 hdd_conn_set_connection_state(pAdapter,
1078 eConnectionState_Disconnecting);
1079 }
1080
1081 hdd_clear_roam_profile_ie(pAdapter);
1082 hdd_wmm_init(pAdapter);
1083
1084 /* indicate 'disconnect' status to wpa_supplicant... */
1085 hdd_send_association_event(dev, pRoamInfo);
1086 /* indicate disconnected event to nl80211 */
1087 if (roamStatus != eCSR_ROAM_IBSS_LEAVE) {
1088 /*
1089 * Only send indication to kernel if not initiated
1090 * by kernel
1091 */
1092 if (sendDisconInd) {
1093 /*
1094 * To avoid wpa_supplicant sending "HANGED" CMD
1095 * to ICS UI.
1096 */
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001097 if (eCSR_ROAM_LOSTLINK == roamStatus) {
1098 if (pRoamInfo->reasonCode ==
1099 eSIR_MAC_PEER_STA_REQ_LEAVING_BSS_REASON)
1100 pr_info("wlan: disconnected due to poor signal, rssi is %d dB\n", pRoamInfo->rxRssi);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001101 cfg80211_disconnected(dev, pRoamInfo->
Ryan Hsua335c162016-01-21 12:12:20 -08001102 reasonCode, NULL, 0,
1103#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || defined(WITH_BACKPORTS)
1104 true,
1105#endif
1106 GFP_KERNEL);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001107 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001108 cfg80211_disconnected(dev,
Ryan Hsua335c162016-01-21 12:12:20 -08001109 WLAN_REASON_UNSPECIFIED, NULL, 0,
1110#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) || defined(WITH_BACKPORTS)
1111 true,
1112#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001113 GFP_KERNEL);
Kiran Kumar Lokere37d3aa22015-11-03 14:58:26 -08001114 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001115
1116 hdd_info("sent disconnected event to nl80211, rssi: %d",
1117 pAdapter->rssi);
1118 }
1119 /*
1120 * During the WLAN uninitialization,supplicant is stopped
1121 * before the driver so not sending the status of the
1122 * connection to supplicant.
1123 */
Rajeev Kumarfec3dbe2016-01-19 15:23:52 -08001124 if (cds_is_load_or_unload_in_progress()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001125#ifdef WLAN_FEATURE_P2P_DEBUG
Krunal Sonibe766b02016-03-10 13:00:44 -08001126 if (pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001127 if (global_p2p_connection_status ==
1128 P2P_CLIENT_CONNECTED_STATE_1) {
1129 global_p2p_connection_status =
1130 P2P_CLIENT_DISCONNECTED_STATE;
1131 hddLog(LOGE,
1132 "[P2P State] 8 way Handshake completed and moved to disconnected state");
1133 } else if (global_p2p_connection_status ==
1134 P2P_CLIENT_COMPLETED_STATE) {
1135 global_p2p_connection_status =
1136 P2P_NOT_ACTIVE;
1137 hddLog(LOGE,
1138 "[P2P State] P2P Client is removed and moved to inactive state");
1139 }
1140 }
1141#endif
1142
1143 }
1144 }
1145
1146 hdd_wmm_adapter_clear(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001147 sme_ft_reset(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001148 if (hdd_remove_beacon_filter(pAdapter) != 0)
1149 hdd_err("hdd_remove_beacon_filter() failed");
1150
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001151 if (eCSR_ROAM_IBSS_LEAVE == roamStatus) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301152 uint8_t i;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301153 sta_id = pHddStaCtx->broadcast_ibss_staid;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001154 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301155 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05301156 hdd_err("hdd_roam_deregister_sta() failed for staID %d Status=%d [0x%x]",
1157 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301158 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001159 }
1160 pHddCtx->sta_to_adapter[sta_id] = NULL;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301161 /* Clear all the peer sta register with TL. */
1162 for (i = 0; i < MAX_IBSS_PEERS; i++) {
1163 if (0 == pHddStaCtx->conn_info.staId[i])
1164 continue;
1165 sta_id = pHddStaCtx->conn_info.staId[i];
1166 hddLog(LOG1, FL("Deregister StaID %d"), sta_id);
1167 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301168 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301169 hddLog(LOGE,
1170 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
1171 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301172 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301173 }
1174 /* set the staid and peer mac as 0, all other
1175 * reset are done in hdd_connRemoveConnectInfo.
1176 */
1177 pHddStaCtx->conn_info.staId[i] = 0;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301178 qdf_mem_zero(&pHddStaCtx->conn_info.peerMacAddress[i],
Anurag Chouhan6d760662016-02-20 16:05:43 +05301179 sizeof(struct qdf_mac_addr));
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301180 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1181 pHddCtx->sta_to_adapter[sta_id] = NULL;
1182 }
1183 } else {
1184 sta_id = pHddStaCtx->conn_info.staId[0];
1185 /* We should clear all sta register with TL,
1186 * for now, only one.
1187 */
1188 vstatus = hdd_roam_deregister_sta(pAdapter, sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301189 if (!QDF_IS_STATUS_SUCCESS(vstatus)) {
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301190 hddLog(LOGE,
1191 FL("hdd_roam_deregister_sta() failed to for staID %d. Status= %d [0x%x]"),
1192 sta_id, status, status);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301193 status = QDF_STATUS_E_FAILURE;
Sreelakshmi Konamki32eadb12015-09-02 15:18:32 +05301194 }
1195 pHddCtx->sta_to_adapter[sta_id] = NULL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001196 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001197 /* Clear saved connection information in HDD */
1198 hdd_conn_remove_connect_info(pHddStaCtx);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001199 hdd_conn_set_connection_state(pAdapter, eConnectionState_NotConnected);
1200#ifdef WLAN_FEATURE_GTK_OFFLOAD
Krunal Sonibe766b02016-03-10 13:00:44 -08001201 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1202 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001203 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1204 sizeof(tSirGtkOffloadParams));
1205 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
1206 }
1207#endif
1208
1209#ifdef FEATURE_WLAN_TDLS
1210 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1211 wlan_hdd_tdls_disconnection_callback(pAdapter);
1212#endif
1213
Krunal Sonibe766b02016-03-10 13:00:44 -08001214 if ((QDF_STA_MODE == pAdapter->device_mode) ||
1215 (QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001216 sme_ps_disable_auto_ps_timer(WLAN_HDD_GET_HAL_CTX
1217 (pAdapter),
1218 pAdapter->sessionId);
1219 }
1220 /* Unblock anyone waiting for disconnect to complete */
1221 complete(&pAdapter->disconnect_comp_var);
1222 return status;
1223}
1224
1225/**
1226 * hdd_set_peer_authorized_event() - set peer_authorized_event
1227 * @vdev_id: vdevid
1228 *
1229 * Return: None
1230 */
1231void hdd_set_peer_authorized_event(uint32_t vdev_id)
1232{
Anurag Chouhan6d760662016-02-20 16:05:43 +05301233 hdd_context_t *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001234 hdd_adapter_t *adapter = NULL;
1235
1236 adapter = hdd_get_adapter_by_vdev(hdd_ctx, vdev_id);
1237 if (adapter == NULL) {
1238 hddLog(LOGE,
1239 "%s: Invalid vdev_id", __func__);
1240 }
1241 complete(&adapter->sta_authorized_event);
1242}
1243
1244/**
1245 * hdd_change_peer_state() - change peer state
1246 * @pAdapter: HDD adapter
1247 * @sta_state: peer state
1248 * @roam_synch_in_progress: roam synch in progress
1249 *
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301250 * Return: QDF status
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001251 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301252QDF_STATUS hdd_change_peer_state(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001253 uint8_t sta_id,
1254 enum ol_txrx_peer_state sta_state,
1255 bool roam_synch_in_progress)
1256{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301257 QDF_STATUS err;
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001258 uint8_t *peer_mac_addr;
Manjunathappa Prakash2593a642016-04-01 08:53:35 -07001259 struct ol_txrx_pdev_t *pdev = cds_get_context(QDF_MODULE_ID_TXRX);
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001260 ol_txrx_peer_handle peer;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001261
1262 if (!pdev) {
1263 hdd_err("Failed to get txrx context");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301264 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001265 }
1266
1267 if (sta_id >= WLAN_MAX_STA_COUNT) {
1268 hddLog(LOGE, "Invalid sta id :%d", sta_id);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301269 return QDF_STATUS_E_INVAL;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001270 }
1271
1272 peer = ol_txrx_peer_find_by_local_id(pdev, sta_id);
1273 if (!peer)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301274 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001275
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001276 peer_mac_addr = ol_txrx_peer_get_peer_mac_addr(peer);
1277 if (peer_mac_addr == NULL) {
1278 hddLog(LOGE, "peer mac addr is NULL");
1279 return QDF_STATUS_E_FAULT;
1280 }
1281
1282 err = ol_txrx_peer_state_update(pdev, peer_mac_addr, sta_state);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301283 if (err != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001284 hddLog(LOGE, "peer state update failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301285 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001286 }
1287#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1288 if (roam_synch_in_progress)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301289 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001290#endif
1291
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001292 if (sta_state == OL_TXRX_PEER_STATE_AUTH) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001293#ifdef QCA_LL_LEGACY_TX_FLOW_CONTROL
1294 /* make sure event is reset */
1295 INIT_COMPLETION(pAdapter->sta_authorized_event);
1296#endif
1297
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001298 err = sme_set_peer_authorized(peer_mac_addr,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001299 hdd_set_peer_authorized_event,
1300 pAdapter->sessionId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301301 if (err != QDF_STATUS_SUCCESS) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001302 hddLog(LOGE, "Failed to set the peer state to authorized");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301303 return QDF_STATUS_E_FAULT;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001304 }
1305
Krunal Sonibe766b02016-03-10 13:00:44 -08001306 if (pAdapter->device_mode == QDF_STA_MODE ||
1307 pAdapter->device_mode == QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001308#if defined(QCA_LL_LEGACY_TX_FLOW_CONTROL) || defined(QCA_LL_TX_FLOW_CONTROL_V2)
Houston Hoffman52ec6692016-04-21 16:36:45 -07001309 ol_txrx_vdev_handle vdev;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001310 unsigned long rc;
1311
1312 /* wait for event from firmware to set the event */
1313 rc = wait_for_completion_timeout(
1314 &pAdapter->sta_authorized_event,
1315 msecs_to_jiffies(HDD_PEER_AUTHORIZE_WAIT));
1316 if (!rc) {
1317 hddLog(LOG1, "%s: timeout waiting for sta_authorized_event",
1318 __func__);
1319 }
Manjunathappa Prakash10d357a2016-03-31 19:20:49 -07001320 vdev = ol_txrx_get_vdev_for_peer(peer);
1321 ol_txrx_vdev_unpause(vdev,
1322 OL_TXQ_PAUSE_REASON_PEER_UNAUTHORIZED);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001323#endif
1324 }
1325 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301326 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001327}
1328
1329/**
1330 * hdd_roam_register_sta() - register station
1331 * @pAdapter: pointer to adapter
1332 * @pRoamInfo: pointer to roam info
1333 * @staId: station identifier
1334 * @pPeerMacAddress: peer MAC address
1335 * @pBssDesc: pointer to BSS description
1336 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301337 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001338 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301339static QDF_STATUS hdd_roam_register_sta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001340 tCsrRoamInfo *pRoamInfo,
1341 uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301342 struct qdf_mac_addr *pPeerMacAddress,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001343 tSirBssDescription *pBssDesc)
1344{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301345 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001346 struct ol_txrx_desc_type staDesc = { 0 };
1347 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Dhanashri Atre182b0272016-02-17 15:35:07 -08001348 struct ol_txrx_ops txrx_ops;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001349
1350 if (NULL == pBssDesc)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301351 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001352
1353 /* Get the Station ID from the one saved during the association */
1354 staDesc.sta_id = staId;
1355
1356 /* set the QoS field appropriately */
1357 if (hdd_wmm_is_active(pAdapter))
1358 staDesc.is_qos_enabled = 1;
1359 else
1360 staDesc.is_qos_enabled = 0;
1361
1362#ifdef FEATURE_WLAN_WAPI
1363 hddLog(LOG1, FL("WAPI STA Registered: %d"),
1364 pAdapter->wapi_info.fIsWapiSta);
1365 if (pAdapter->wapi_info.fIsWapiSta)
1366 staDesc.is_wapi_supported = 1;
1367 else
1368 staDesc.is_wapi_supported = 0;
1369#endif /* FEATURE_WLAN_WAPI */
1370
Dhanashri Atre50141c52016-04-07 13:15:29 -07001371 /* Register the vdev transmit and receive functions */
1372 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
1373 txrx_ops.rx.rx = hdd_rx_packet_cbk;
1374 ol_txrx_vdev_register(
1375 ol_txrx_get_vdev_from_vdev_id(pAdapter->sessionId),
1376 pAdapter, &txrx_ops);
1377 pAdapter->tx_fn = txrx_ops.tx.tx;
1378
Dhanashri Atre182b0272016-02-17 15:35:07 -08001379 qdf_status = ol_txrx_register_peer(&staDesc);
1380
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301381 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001382 hddLog(LOGW,
1383 "ol_txrx_register_peer() failed to register. Status=%d [0x%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301384 qdf_status, qdf_status);
1385 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001386 }
1387
1388 if (!pRoamInfo->fAuthRequired) {
1389 /*
1390 * Connections that do not need Upper layer auth, transition
1391 * TLSHIM directly to 'Authenticated' state
1392 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301393 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001394 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001395 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001396#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1397 pRoamInfo->roamSynchInProgress
1398#else
1399 false
1400#endif
1401 );
1402
1403 hdd_conn_set_authenticated(pAdapter, true);
1404 } else {
1405 hddLog(LOG3,
1406 "ULA auth StaId= %d. Changing TL state to CONNECTED at Join time",
1407 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301408 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001409 hdd_change_peer_state(pAdapter, staDesc.sta_id,
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001410 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001411#ifdef WLAN_FEATURE_ROAM_OFFLOAD
1412 pRoamInfo->roamSynchInProgress
1413#else
1414 false
1415#endif
1416 );
1417 hdd_conn_set_authenticated(pAdapter, false);
1418 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301419 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001420}
1421
1422/**
1423 * hdd_send_re_assoc_event() - send reassoc event
1424 * @dev: pointer to net device
1425 * @pAdapter: pointer to adapter
1426 * @pCsrRoamInfo: pointer to roam info
1427 * @reqRsnIe: pointer to RSN Information element
1428 * @reqRsnLength: length of RSN IE
1429 *
1430 * Return: none
1431 */
1432static void hdd_send_re_assoc_event(struct net_device *dev,
1433 hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo,
1434 uint8_t *reqRsnIe, uint32_t reqRsnLength)
1435{
1436 unsigned int len = 0;
1437 u8 *pFTAssocRsp = NULL;
1438 uint8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Naveen Rawat14298b92015-11-25 16:27:41 -08001439 uint8_t *assoc_req_ies = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001440 uint32_t rspRsnLength = 0;
1441 struct ieee80211_channel *chan;
1442 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1443 uint8_t buf_ssid_ie[2 + SIR_MAC_SSID_EID_MAX]; /* 2 bytes-EID and len */
1444 uint8_t *buf_ptr, ssid_ie_len;
1445 struct cfg80211_bss *bss = NULL;
1446 uint8_t *final_req_ie = NULL;
1447 tCsrRoamConnectedProfile roam_profile;
1448 tHalHandle hal_handle = WLAN_HDD_GET_HAL_CTX(pAdapter);
1449
1450 if (!rspRsnIe) {
1451 hddLog(LOGE, FL("Unable to allocate RSN IE"));
Naveen Rawatdafda292016-01-06 18:32:14 -08001452 goto done;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001453 }
1454
Naveen Rawat14298b92015-11-25 16:27:41 -08001455 if (!assoc_req_ies) {
1456 hdd_err("Unable to allocate Assoc Req IE");
Naveen Rawatdafda292016-01-06 18:32:14 -08001457 goto done;
Naveen Rawat14298b92015-11-25 16:27:41 -08001458 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001459 if (pCsrRoamInfo == NULL) {
1460 hddLog(LOGE, FL("Invalid CSR roam info"));
1461 goto done;
1462 }
1463
1464 if (pCsrRoamInfo->nAssocRspLength == 0) {
1465 hddLog(LOGE, FL("Invalid assoc response length"));
1466 goto done;
1467 }
1468
1469 pFTAssocRsp =
1470 (u8 *) (pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1471 pCsrRoamInfo->nAssocReqLength);
1472 if (pFTAssocRsp == NULL)
1473 goto done;
1474
1475 /* pFTAssocRsp needs to point to the IEs */
1476 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1477 hddLog(LOG1, FL("AssocRsp is now at %02x%02x"),
1478 (unsigned int)pFTAssocRsp[0], (unsigned int)pFTAssocRsp[1]);
1479
1480 /*
1481 * Active session count is decremented upon disconnection, but during
1482 * roaming, there is no disconnect indication and hence active session
1483 * count is not decremented.
1484 * After roaming is completed, active session count is incremented
1485 * as a part of connect indication but effectively after roaming the
1486 * active session count should still be the same and hence upon
1487 * successful reassoc decrement the active session count here.
1488 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001489 if (!hdd_is_roam_sync_in_progress(pCsrRoamInfo))
Chandrasekaran, Manishekar6e9aa1b2015-12-02 18:04:00 +05301490 cds_decr_session_set_pcl(pAdapter->device_mode,
1491 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001492
1493 /* Send the Assoc Resp, the supplicant needs this for initial Auth */
1494 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
1495 rspRsnLength = len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301496 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1497 qdf_mem_zero(rspRsnIe + len, IW_GENERIC_IE_MAX - len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001498
1499 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1500 (int)pCsrRoamInfo->pBssDesc->channelId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301501 qdf_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001502 sme_roam_get_connect_profile(hal_handle, pAdapter->sessionId,
1503 &roam_profile);
1504 bss = cfg80211_get_bss(pAdapter->wdev.wiphy, chan,
1505 pCsrRoamInfo->bssid.bytes,
1506 &roam_profile.SSID.ssId[0], roam_profile.SSID.length,
Ryan Hsu535d16a2016-01-18 16:45:12 -08001507#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)) && !defined(WITH_BACKPORTS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001508 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
Ryan Hsu535d16a2016-01-18 16:45:12 -08001509#else
1510 IEEE80211_BSS_TYPE_ESS, IEEE80211_PRIVACY_ANY);
1511#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001512
1513 if (bss == NULL)
1514 hddLog(LOGE, FL("Get BSS returned NULL"));
1515 buf_ptr = buf_ssid_ie;
1516 *buf_ptr = SIR_MAC_SSID_EID;
1517 buf_ptr++;
1518 *buf_ptr = roam_profile.SSID.length; /*len of ssid*/
1519 buf_ptr++;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301520 qdf_mem_copy(buf_ptr, &roam_profile.SSID.ssId[0],
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001521 roam_profile.SSID.length);
1522 ssid_ie_len = 2 + roam_profile.SSID.length;
Jeff Johnson9991f472016-01-06 16:02:31 -08001523 hdd_notice("SSIDIE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301524 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08001525 buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001526 final_req_ie = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
1527 if (final_req_ie == NULL)
1528 goto done;
1529 buf_ptr = final_req_ie;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301530 qdf_mem_copy(buf_ptr, buf_ssid_ie, ssid_ie_len);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001531 buf_ptr += ssid_ie_len;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301532 qdf_mem_copy(buf_ptr, reqRsnIe, reqRsnLength);
1533 qdf_mem_copy(rspRsnIe, pFTAssocRsp, len);
1534 qdf_mem_zero(final_req_ie + (ssid_ie_len + reqRsnLength),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001535 IW_GENERIC_IE_MAX - (ssid_ie_len + reqRsnLength));
Jeff Johnson9991f472016-01-06 16:02:31 -08001536 hdd_notice("Req RSN IE:");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301537 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Jeff Johnson9991f472016-01-06 16:02:31 -08001538 final_req_ie, (ssid_ie_len + reqRsnLength));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001539 cfg80211_roamed_bss(dev, bss,
1540 final_req_ie, (ssid_ie_len + reqRsnLength),
1541 rspRsnIe, rspRsnLength, GFP_KERNEL);
1542
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301543 qdf_mem_copy(assoc_req_ies,
Naveen Rawat14298b92015-11-25 16:27:41 -08001544 (u8 *)pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength,
1545 pCsrRoamInfo->nAssocReqLength);
1546
1547 hdd_notice("ReAssoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05301548 QDF_TRACE_HEX_DUMP(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08001549 assoc_req_ies, pCsrRoamInfo->nAssocReqLength);
1550
Prashanth Bhattabfc25292015-11-05 11:16:21 -08001551 wlan_hdd_send_roam_auth_event(pHddCtx, pCsrRoamInfo->bssid.bytes,
Naveen Rawat14298b92015-11-25 16:27:41 -08001552 assoc_req_ies, pCsrRoamInfo->nAssocReqLength,
1553 rspRsnIe, rspRsnLength,
Prashanth Bhattabfc25292015-11-05 11:16:21 -08001554 pCsrRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001555done:
Naveen Rawatdf0a7e72016-01-06 18:35:53 -08001556 sme_roam_free_connect_profile(&roam_profile);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001557 if (final_req_ie)
1558 kfree(final_req_ie);
1559 kfree(rspRsnIe);
Naveen Rawat14298b92015-11-25 16:27:41 -08001560 kfree(assoc_req_ies);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001561}
1562
1563/**
Govind Singhedc5cda2015-10-23 17:11:35 +05301564 * hdd_is_roam_sync_in_progress()- Check if roam offloaded
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001565 * @roaminfo - Roaming Information
Govind Singhedc5cda2015-10-23 17:11:35 +05301566 *
1567 * Return: roam sync status if roaming offloaded else false
1568 */
1569#ifdef WLAN_FEATURE_ROAM_OFFLOAD
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001570bool hdd_is_roam_sync_in_progress(tCsrRoamInfo *roaminfo)
Govind Singhedc5cda2015-10-23 17:11:35 +05301571{
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08001572 if (roaminfo)
1573 return roaminfo->roamSynchInProgress;
1574 else
1575 return false;
Govind Singhedc5cda2015-10-23 17:11:35 +05301576}
1577#endif
1578
1579
1580/**
1581 * hdd_change_sta_state_authenticated()-
1582 * This function changes STA state to authenticated
1583 * @adapter: pointer to the adapter structure.
1584 * @roaminfo: pointer to the RoamInfo structure.
1585 *
1586 * This is called from hdd_RoamSetKeyCompleteHandler
1587 * in context to eCSR_ROAM_SET_KEY_COMPLETE event from fw.
1588 *
1589 * Return: 0 on success and errno on failure
1590 */
1591static int hdd_change_sta_state_authenticated(hdd_adapter_t *adapter,
1592 tCsrRoamInfo *roaminfo)
1593{
1594 int ret;
1595 hdd_station_ctx_t *hddstactx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
1596
1597 hddLog(LOG1,
1598 "Changing TL state to AUTHENTICATED for StaId= %d",
1599 hddstactx->conn_info.staId[0]);
1600
1601 /* Connections that do not need Upper layer authentication,
1602 * transition TL to 'Authenticated' state after the keys are set
1603 */
1604 ret = hdd_change_peer_state(adapter,
1605 hddstactx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08001606 OL_TXRX_PEER_STATE_AUTH,
Govind Singhedc5cda2015-10-23 17:11:35 +05301607 hdd_is_roam_sync_in_progress(roaminfo));
1608 hdd_conn_set_authenticated(adapter, true);
Krunal Sonibe766b02016-03-10 13:00:44 -08001609 if ((QDF_STA_MODE == adapter->device_mode) ||
1610 (QDF_P2P_CLIENT_MODE == adapter->device_mode)) {
Govind Singhedc5cda2015-10-23 17:11:35 +05301611 sme_ps_enable_auto_ps_timer(
1612 WLAN_HDD_GET_HAL_CTX(adapter),
1613 adapter->sessionId,
1614 hddstactx->hdd_ReassocScenario);
1615 }
1616
1617 return ret;
1618}
1619
1620/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001621 * hdd_roam_set_key_complete_handler() - Update the security parameters
1622 * @pAdapter: pointer to adapter
1623 * @pRoamInfo: pointer to roam info
1624 * @roamId: roam id
1625 * @roamStatus: roam status
1626 * @roamResult: roam result
1627 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301628 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001629 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301630static QDF_STATUS hdd_roam_set_key_complete_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001631 tCsrRoamInfo *pRoamInfo,
1632 uint32_t roamId,
1633 eRoamCmdStatus roamStatus,
1634 eCsrRoamResult roamResult)
1635{
1636 eCsrEncryptionType connectedCipherAlgo;
1637 bool fConnected = false;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301638 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001639 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05301640 tHalHandle hal_ctx = WLAN_HDD_GET_HAL_CTX(pAdapter);
1641 tpAniSirGlobal mac_ctx = PMAC_STRUCT(hal_ctx);
1642
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001643 ENTER();
1644
1645 if (NULL == pRoamInfo) {
1646 hddLog(LOG2, FL("pRoamInfo is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301647 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001648 }
1649 /*
1650 * if (WPA), tell TL to go to 'authenticated' after the keys are set.
1651 * then go to 'authenticated'. For all other authentication types
1652 * (those that do not require upper layer authentication) we can put TL
1653 * directly into 'authenticated' state.
1654 */
1655 hddLog(LOG2, "Set Key completion roamStatus =%d roamResult=%d "
1656 MAC_ADDRESS_STR, roamStatus, roamResult,
1657 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
1658
1659 fConnected = hdd_conn_get_connected_cipher_algo(pHddStaCtx,
1660 &connectedCipherAlgo);
1661 if (fConnected) {
Krunal Sonibe766b02016-03-10 13:00:44 -08001662 if (QDF_IBSS_MODE == pAdapter->device_mode) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001663 uint8_t staId;
1664
Anurag Chouhanc5548422016-02-24 18:33:27 +05301665 if (qdf_is_macaddr_broadcast(&pRoamInfo->peerMac)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001666 pHddStaCtx->roam_info.roamingState =
1667 HDD_ROAM_STATE_NONE;
1668 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301669 qdf_status = hdd_ibss_get_sta_id(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001670 pHddStaCtx,
1671 &pRoamInfo->peerMac,
1672 &staId);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301673 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001674 hddLog(LOG2,
1675 "WLAN TL STA Ptk Installed for STAID=%d",
1676 staId);
1677 pHddStaCtx->roam_info.roamingState =
1678 HDD_ROAM_STATE_NONE;
1679 }
1680 }
1681 } else {
1682 /*
1683 * TODO: Considering getting a state machine in
Govind Singhedc5cda2015-10-23 17:11:35 +05301684 * HDD later.This routine is invoked twice.
1685 * 1)set PTK 2)set GTK.The following if
1686 * statement will be TRUE when setting GTK.
1687 * At this time we don't handle the state in detail.
1688 * Related CR: 174048 - TL not in authenticated state
1689 */
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05301690 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
Govind Singhedc5cda2015-10-23 17:11:35 +05301691 pHddStaCtx->conn_info.gtk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05301692 /*
1693 * PTK exchange happens in preauthentication
1694 * itself if key_mgmt is FT-PSK, ptk_installed
1695 * was false as there is no set PTK after
1696 * roaming. STA TL state moves to authenticated
1697 * only if ptk_installed is true. So, make
1698 * ptk_installed to true in case of 11R roaming.
1699 */
1700 if (csr_neighbor_roam_is11r_assoc(mac_ctx,
1701 pAdapter->sessionId))
1702 pHddStaCtx->conn_info.ptk_installed =
1703 true;
1704 } else {
Govind Singhedc5cda2015-10-23 17:11:35 +05301705 pHddStaCtx->conn_info.ptk_installed = true;
Sreelakshmi Konamki720f2b72016-02-26 16:44:04 +05301706 }
Govind Singhedc5cda2015-10-23 17:11:35 +05301707
1708 /* In WPA case move STA to authenticated when
1709 * ptk is installed.Earlier in WEP case STA
1710 * was moved to AUTHENTICATED prior to setting
1711 * the unicast key and it was resulting in sending
1712 * few un-encrypted packet. Now in WEP case
1713 * STA state will be moved to AUTHENTICATED
1714 * after we set the unicast and broadcast key.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001715 */
Govind Singhedc5cda2015-10-23 17:11:35 +05301716 if ((pHddStaCtx->conn_info.ucEncryptionType ==
1717 eCSR_ENCRYPT_TYPE_WEP40) ||
1718 (pHddStaCtx->conn_info.ucEncryptionType ==
1719 eCSR_ENCRYPT_TYPE_WEP104) ||
1720 (pHddStaCtx->conn_info.ucEncryptionType ==
1721 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
1722 (pHddStaCtx->conn_info.ucEncryptionType ==
1723 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)) {
1724 if (pHddStaCtx->conn_info.gtk_installed &&
1725 pHddStaCtx->conn_info.ptk_installed)
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301726 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05301727 hdd_change_sta_state_authenticated(pAdapter,
1728 pRoamInfo);
1729 } else if (pHddStaCtx->conn_info.ptk_installed) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301730 qdf_status =
Govind Singhedc5cda2015-10-23 17:11:35 +05301731 hdd_change_sta_state_authenticated(pAdapter,
1732 pRoamInfo);
1733 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001734
Govind Singhedc5cda2015-10-23 17:11:35 +05301735 if (pHddStaCtx->conn_info.gtk_installed &&
1736 pHddStaCtx->conn_info.ptk_installed) {
1737 pHddStaCtx->conn_info.gtk_installed = false;
1738 pHddStaCtx->conn_info.ptk_installed = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001739 }
1740
1741 pHddStaCtx->roam_info.roamingState =
Govind Singhedc5cda2015-10-23 17:11:35 +05301742 HDD_ROAM_STATE_NONE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001743 }
1744 } else {
1745 /*
1746 * possible disassoc after issuing set key and waiting
1747 * set key complete.
1748 */
1749 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1750 }
1751
1752 EXIT();
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301753 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001754}
1755
1756/**
1757 * hdd_perform_roam_set_key_complete() - perform set key complete
1758 * @pAdapter: pointer to adapter
1759 *
1760 * Return: none
1761 */
1762void hdd_perform_roam_set_key_complete(hdd_adapter_t *pAdapter)
1763{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301764 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001765 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1766 tCsrRoamInfo roamInfo;
1767 roamInfo.fAuthRequired = false;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301768 qdf_mem_copy(roamInfo.bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301769 pHddStaCtx->roam_info.bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05301770 qdf_mem_copy(roamInfo.peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05301771 pHddStaCtx->roam_info.peerMac, QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001772
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301773 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001774 hdd_roam_set_key_complete_handler(pAdapter,
1775 &roamInfo,
1776 pHddStaCtx->roam_info.roamId,
1777 pHddStaCtx->roam_info.roamStatus,
1778 eCSR_ROAM_RESULT_AUTHENTICATED);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05301779 if (qdf_ret_status != QDF_STATUS_SUCCESS)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001780 hddLog(LOGE, FL("Set Key complete failure"));
1781
1782 pHddStaCtx->roam_info.deferKeyComplete = false;
1783}
1784
1785/**
1786 * hdd_association_completion_handler() - association completion handler
1787 * @pAdapter: pointer to adapter
1788 * @pRoamInfo: pointer to roam info
1789 * @roamId: roam id
1790 * @roamStatus: roam status
1791 * @roamResult: roam result
1792 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301793 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001794 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301795static QDF_STATUS hdd_association_completion_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001796 tCsrRoamInfo *pRoamInfo,
1797 uint32_t roamId,
1798 eRoamCmdStatus roamStatus,
1799 eCsrRoamResult roamResult)
1800{
1801 struct net_device *dev = pAdapter->dev;
1802 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1803 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301804 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001805 uint8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1806 uint32_t reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001807 int ft_carrier_on = false;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001808 bool hddDisconInProgress = false;
1809 unsigned long rc;
1810
1811 if (!pHddCtx) {
1812 hdd_err("HDD context is NULL");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301813 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001814 }
1815
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001816 /* HDD has initiated disconnect, do not send connect result indication
1817 * to kernel as it will be handled by __cfg80211_disconnect.
1818 */
1819 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
1820 && ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
1821 || (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus))) {
1822 hddLog(LOG1, FL("Disconnect from HDD in progress"));
1823 hddDisconInProgress = true;
1824 }
1825
1826 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult) {
1827 if (NULL == pRoamInfo) {
1828 hddLog(LOGE, FL("pRoamInfo is NULL"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301829 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001830 }
1831 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001832 hdd_conn_set_connection_state(pAdapter,
1833 eConnectionState_Associated);
1834 }
1835 /* Save the connection info from CSR... */
1836 hdd_conn_save_connect_info(pAdapter, pRoamInfo,
1837 eCSR_BSS_TYPE_INFRASTRUCTURE);
Gupta, Kapil4cb1d7d2016-04-16 18:16:25 -07001838
1839 if (hdd_add_beacon_filter(pAdapter) != 0)
1840 hdd_err("hdd_add_beacon_filter() failed");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001841#ifdef FEATURE_WLAN_WAPI
1842 if (pRoamInfo->u.pConnectedProfile->AuthType ==
1843 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE
1844 || pRoamInfo->u.pConnectedProfile->AuthType ==
1845 eCSR_AUTH_TYPE_WAPI_WAI_PSK) {
1846 pAdapter->wapi_info.fIsWapiSta = 1;
1847 } else {
1848 pAdapter->wapi_info.fIsWapiSta = 0;
1849 }
1850#endif /* FEATURE_WLAN_WAPI */
1851
1852 /* Indicate 'connect' status to user space */
1853 hdd_send_association_event(dev, pRoamInfo);
1854
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08001855 if (cds_is_mcc_in_24G()) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001856 if (pHddCtx->miracast_value)
1857 cds_set_mas(pAdapter, pHddCtx->miracast_value);
1858 }
1859
1860 /* Initialize the Linkup event completion variable */
1861 INIT_COMPLETION(pAdapter->linkup_event_var);
1862
1863 /*
1864 * Sometimes Switching ON the Carrier is taking time to activate
1865 * the device properly. Before allowing any packet to go up to
1866 * the application, device activation has to be ensured for
1867 * proper queue mapping by the kernel. we have registered net
1868 * device notifier for device change notification. With this we
1869 * will come to know that the device is getting
1870 * activated properly.
1871 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001872 if (pHddStaCtx->ft_carrier_on == false) {
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07001873 /*
1874 * Enable Linkup Event Servicing which allows the net
1875 * device notifier to set the linkup event variable.
1876 */
1877 pAdapter->isLinkUpSvcNeeded = true;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001878
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07001879 /* Switch on the Carrier to activate the device */
1880 wlan_hdd_netif_queue_control(pAdapter,
1881 WLAN_NETIF_CARRIER_ON,
1882 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001883
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07001884 /*
1885 * Wait for the Link to up to ensure all the queues
1886 * are set properly by the kernel.
1887 */
1888 rc = wait_for_completion_timeout(
1889 &pAdapter->linkup_event_var,
1890 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT)
1891 );
1892 if (!rc)
1893 hdd_warn("Warning:ASSOC_LINKUP_TIMEOUT");
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001894
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07001895 /*
1896 * Disable Linkup Event Servicing - no more service
1897 * required from the net device notifier call.
1898 */
1899 pAdapter->isLinkUpSvcNeeded = false;
1900 } else {
1901 pHddStaCtx->ft_carrier_on = false;
1902 ft_carrier_on = true;
1903 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001904 if ((WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId)
1905 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1906 else
1907 hddLog(LOGE, "%s: Wrong Staid: %d", __func__,
1908 pRoamInfo->staId);
1909
1910 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1911
1912 if (hdd_ipa_is_enabled(pHddCtx))
1913 hdd_ipa_wlan_evt(pAdapter, pRoamInfo->staId,
1914 WLAN_STA_CONNECT,
1915 pRoamInfo->bssid.bytes);
1916
1917#ifdef FEATURE_WLAN_AUTO_SHUTDOWN
1918 wlan_hdd_auto_shutdown_enable(pHddCtx, false);
1919#endif
1920
Chandrasekaran Manishekar068e25e2016-03-07 11:51:07 +05301921 hdd_info("check for SAP restart");
Tushnim Bhattacharyya4adb3682016-01-07 15:07:12 -08001922 cds_check_concurrent_intf_and_restart_sap(pHddStaCtx,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001923 pAdapter);
1924
1925#ifdef FEATURE_WLAN_TDLS
1926 wlan_hdd_tdls_connection_callback(pAdapter);
1927#endif
1928
1929#ifdef QCA_PKT_PROTO_TRACE
1930 /* STA Associated, update into trace buffer */
1931 if (pHddCtx->config->gEnableDebugLog)
1932 cds_pkt_trace_buf_update("ST:ASSOC");
1933#endif /* QCA_PKT_PROTO_TRACE */
1934 /*
1935 * For reassoc, the station is already registered, all we need
1936 * is to change the state of the STA in TL.
1937 * If authentication is required (WPA/WPA2/DWEP), change TL to
1938 * CONNECTED instead of AUTHENTICATED.
1939 */
1940 if (!pRoamInfo->fReassocReq) {
1941 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001942 u8 *pFTAssocRsp = NULL;
1943 unsigned int assocRsplen = 0;
1944 u8 *pFTAssocReq = NULL;
1945 unsigned int assocReqlen = 0;
1946 struct ieee80211_channel *chan;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001947 uint8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
1948 uint32_t rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
1949
1950 /* add bss_id to cfg80211 data base */
1951 bss =
1952 wlan_hdd_cfg80211_update_bss_db(pAdapter,
1953 pRoamInfo);
1954 if (NULL == bss) {
1955 pr_err("wlan: Not able to create BSS entry\n");
1956 wlan_hdd_netif_queue_control(pAdapter,
1957 WLAN_NETIF_CARRIER_OFF,
1958 WLAN_CONTROL_PATH);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05301959 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001960 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001961 if (pRoamInfo->u.pConnectedProfile->AuthType ==
1962 eCSR_AUTH_TYPE_FT_RSN
1963 || pRoamInfo->u.pConnectedProfile->AuthType ==
1964 eCSR_AUTH_TYPE_FT_RSN_PSK) {
1965
1966 /* Association Response */
1967 pFTAssocRsp =
1968 (u8 *) (pRoamInfo->pbFrames +
1969 pRoamInfo->nBeaconLength +
1970 pRoamInfo->nAssocReqLength);
1971 if (pFTAssocRsp != NULL) {
1972 /*
1973 * pFTAssocRsp needs to point to the IEs
1974 */
1975 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1976 hddLog(LOG1,
1977 FL("AssocRsp is now at %02x%02x"),
1978 (unsigned int)pFTAssocRsp[0],
1979 (unsigned int)pFTAssocRsp[1]);
1980 assocRsplen =
1981 pRoamInfo->nAssocRspLength -
1982 FT_ASSOC_RSP_IES_OFFSET;
1983 } else {
1984 hddLog(LOGE, FL("AssocRsp is NULL"));
1985 assocRsplen = 0;
1986 }
1987
1988 /* Association Request */
1989 pFTAssocReq = (u8 *) (pRoamInfo->pbFrames +
1990 pRoamInfo->nBeaconLength);
1991 if (pFTAssocReq != NULL) {
1992 if (!ft_carrier_on) {
1993 /*
1994 * pFTAssocReq needs to point to
1995 * the IEs
1996 */
1997 pFTAssocReq +=
1998 FT_ASSOC_REQ_IES_OFFSET;
1999 hddLog(LOG1,
2000 FL("pFTAssocReq is now at %02x%02x"),
2001 (unsigned int)
2002 pFTAssocReq[0],
2003 (unsigned int)
2004 pFTAssocReq[1]);
2005 assocReqlen =
2006 pRoamInfo->nAssocReqLength -
2007 FT_ASSOC_REQ_IES_OFFSET;
2008 } else {
2009 /*
2010 * This should contain only the
2011 * FTIEs
2012 */
2013 assocReqlen =
2014 pRoamInfo->nAssocReqLength;
2015 }
2016 } else {
2017 hddLog(LOGE, FL("AssocReq is NULL"));
2018 assocReqlen = 0;
2019 }
2020
2021 if (ft_carrier_on) {
2022 if (!hddDisconInProgress) {
2023 /*
2024 * After roaming is completed,
2025 * active session count is
2026 * incremented as a part of
2027 * connect indication but
2028 * effectively the active
2029 * session count should still
2030 * be the same and hence upon
2031 * successful reassoc
2032 * decrement the active session
2033 * count here.
2034 */
Varun Reddy Yeturud5939f82015-12-24 18:14:02 -08002035 if (!hdd_is_roam_sync_in_progress
2036 (pRoamInfo))
2037 cds_decr_session_set_pcl
2038 (pAdapter->device_mode,
2039 pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002040 hddLog(LOG1,
2041 FL("ft_carrier_on is %d, sending roamed indication"),
2042 ft_carrier_on);
2043 chan =
2044 ieee80211_get_channel
2045 (pAdapter->wdev.wiphy,
2046 (int)pRoamInfo->pBssDesc->
2047 channelId);
2048 hddLog(LOG1,
2049 "assocReqlen %d assocRsplen %d",
2050 assocReqlen,
2051 assocRsplen);
Naveen Rawat14298b92015-11-25 16:27:41 -08002052
2053 hdd_notice(
2054 "Reassoc Req IE dump");
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302055 QDF_TRACE_HEX_DUMP(
Anurag Chouhan6d760662016-02-20 16:05:43 +05302056 QDF_MODULE_ID_HDD,
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302057 QDF_TRACE_LEVEL_DEBUG,
Naveen Rawat14298b92015-11-25 16:27:41 -08002058 pFTAssocReq,
2059 assocReqlen);
2060
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002061 cfg80211_roamed(dev, chan,
2062 pRoamInfo->
2063 bssid.bytes,
2064 pFTAssocReq,
2065 assocReqlen,
2066 pFTAssocRsp,
2067 assocRsplen,
2068 GFP_KERNEL);
Prashanth Bhattabfc25292015-11-05 11:16:21 -08002069 wlan_hdd_send_roam_auth_event(
2070 pHddCtx,
2071 pRoamInfo->bssid.bytes,
2072 pFTAssocReq,
2073 assocReqlen,
2074 pFTAssocRsp,
2075 assocRsplen,
2076 pRoamInfo);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002077 }
2078 if (sme_get_ftptk_state
2079 (WLAN_HDD_GET_HAL_CTX(pAdapter),
2080 pAdapter->sessionId)) {
2081 sme_set_ftptk_state
2082 (WLAN_HDD_GET_HAL_CTX
2083 (pAdapter),
2084 pAdapter->sessionId,
2085 false);
2086 pRoamInfo->fAuthRequired =
2087 false;
2088
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302089 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002090 roam_info.bssid,
2091 pRoamInfo->bssid.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302092 QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302093 qdf_mem_copy(pHddStaCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002094 roam_info.peerMac,
2095 pRoamInfo->peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302096 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002097 pHddStaCtx->roam_info.roamId =
2098 roamId;
2099 pHddStaCtx->roam_info.
2100 roamStatus = roamStatus;
2101 pHddStaCtx->roam_info.
2102 deferKeyComplete = true;
2103 }
2104 } else if (!hddDisconInProgress) {
2105 hddLog(LOG1,
2106 FL("ft_carrier_on is %d, sending connect indication"),
2107 ft_carrier_on);
2108 cfg80211_connect_result(dev,
2109 pRoamInfo->
2110 bssid.bytes,
2111 pFTAssocReq,
2112 assocReqlen,
2113 pFTAssocRsp,
2114 assocRsplen,
2115 WLAN_STATUS_SUCCESS,
2116 GFP_KERNEL);
2117 }
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08002118 } else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002119 /*
2120 * wpa supplicant expecting WPA/RSN IE in
2121 * connect result.
2122 */
2123 csr_roam_get_wpa_rsn_req_ie(WLAN_HDD_GET_HAL_CTX
2124 (pAdapter),
2125 pAdapter->sessionId,
2126 &reqRsnLength,
2127 reqRsnIe);
2128
2129 csr_roam_get_wpa_rsn_rsp_ie(WLAN_HDD_GET_HAL_CTX
2130 (pAdapter),
2131 pAdapter->sessionId,
2132 &rspRsnLength,
2133 rspRsnIe);
2134 if (!hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002135 if (ft_carrier_on)
2136 hdd_send_re_assoc_event(dev,
2137 pAdapter,
2138 pRoamInfo,
2139 reqRsnIe,
2140 reqRsnLength);
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07002141 else {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002142 hddLog(LOG1,
2143 FL("sending connect indication to nl80211:for bssid "
2144 MAC_ADDRESS_STR
Abhishek Singhac2be142015-12-03 16:16:25 +05302145 " result:%d and Status:%d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002146 MAC_ADDR_ARRAY
2147 (pRoamInfo->bssid.bytes),
2148 roamResult, roamStatus);
2149
2150 /* inform connect result to nl80211 */
2151 cfg80211_connect_result(dev,
2152 pRoamInfo->
2153 bssid.bytes,
2154 reqRsnIe,
2155 reqRsnLength,
2156 rspRsnIe,
2157 rspRsnLength,
2158 WLAN_STATUS_SUCCESS,
2159 GFP_KERNEL);
2160 }
2161 }
2162 }
2163 if (!hddDisconInProgress) {
2164 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002165 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002166 bss);
2167
2168 /*
2169 * Perform any WMM-related association
2170 * processing.
2171 */
2172 hdd_wmm_assoc(pAdapter, pRoamInfo,
2173 eCSR_BSS_TYPE_INFRASTRUCTURE);
2174
2175 /*
2176 * Start the Queue - Start tx queues before
2177 * hdd_roam_register_sta, since
2178 * hdd_roam_register_sta will flush any cached
2179 * data frames immediately.
2180 */
2181 hddLog(LOG1, FL("Enabling queues"));
2182 wlan_hdd_netif_queue_control(pAdapter,
2183 WLAN_WAKE_ALL_NETIF_QUEUE,
2184 WLAN_CONTROL_PATH);
2185
2186 /*
2187 * Register the Station with TL after associated
2188 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302189 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002190 pRoamInfo,
2191 pHddStaCtx->
2192 conn_info.
2193 staId[0],
2194 NULL,
2195 pRoamInfo->
2196 pBssDesc);
2197 }
2198 } else {
2199 /*
2200 * wpa supplicant expecting WPA/RSN IE in connect result
2201 * in case of reassociation also need to indicate it to
2202 * supplicant.
2203 */
2204 csr_roam_get_wpa_rsn_req_ie(
2205 WLAN_HDD_GET_HAL_CTX(pAdapter),
2206 pAdapter->sessionId,
2207 &reqRsnLength, reqRsnIe);
2208
2209 hdd_send_re_assoc_event(dev, pAdapter, pRoamInfo,
2210 reqRsnIe, reqRsnLength);
2211 /* Reassoc successfully */
2212 if (pRoamInfo->fAuthRequired) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302213 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002214 hdd_change_peer_state(pAdapter,
2215 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002216 OL_TXRX_PEER_STATE_CONN,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002217#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2218 pRoamInfo->roamSynchInProgress
2219#else
2220 false
2221#endif
2222 );
2223 hdd_conn_set_authenticated(pAdapter, false);
2224 } else {
2225 hddLog(LOG2,
2226 FL("staId: %d Changing TL state to AUTHENTICATED"),
2227 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302228 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002229 hdd_change_peer_state(pAdapter,
2230 pHddStaCtx->conn_info.staId[0],
Dhanashri Atreb08959a2016-03-01 17:28:03 -08002231 OL_TXRX_PEER_STATE_AUTH,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002232#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2233 pRoamInfo->roamSynchInProgress
2234#else
2235 false
2236#endif
2237 );
2238 hdd_conn_set_authenticated(pAdapter, true);
2239 }
2240
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302241 if (QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002242 /*
2243 * Perform any WMM-related association
2244 * processing
2245 */
2246 hdd_wmm_assoc(pAdapter, pRoamInfo,
2247 eCSR_BSS_TYPE_INFRASTRUCTURE);
2248 }
2249
2250 /* Start the tx queues */
2251#ifdef WLAN_FEATURE_ROAM_OFFLOAD
2252 if (pRoamInfo->roamSynchInProgress)
2253 hddLog(LOG3, "LFR3:netif_tx_wake_all_queues");
2254#endif
2255 hddLog(LOG1, FL("Enabling queues"));
2256 wlan_hdd_netif_queue_control(pAdapter,
2257 WLAN_WAKE_ALL_NETIF_QUEUE,
2258 WLAN_CONTROL_PATH);
2259 }
2260
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302261 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002262 hddLog(LOGE,
2263 "STA register with TL failed. status(=%d) [%08X]",
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302264 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002265 }
2266#ifdef WLAN_FEATURE_11W
Anurag Chouhan600c3a02016-03-01 10:33:54 +05302267 qdf_mem_zero(&pAdapter->hdd_stats.hddPmfStats,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002268 sizeof(pAdapter->hdd_stats.hddPmfStats));
2269#endif
2270 } else {
2271 hdd_wext_state_t *pWextState =
2272 WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2273 if (pRoamInfo)
2274 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
Abhishek Singhac2be142015-12-03 16:16:25 +05302275 " result:%d and Status:%d\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002276 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
2277 roamResult, roamStatus);
2278 else
2279 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
Abhishek Singhac2be142015-12-03 16:16:25 +05302280 " result:%d and Status:%d\n",
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002281 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2282 roamResult, roamStatus);
2283
2284 /*
2285 * CR465478: Only send up a connection failure result when CSR
2286 * has completed operation - with a ASSOCIATION_FAILURE status.
2287 */
2288 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2289 && !hddDisconInProgress) {
2290 if (pRoamInfo)
2291 hddLog(LOGE,
2292 FL("send connect failure to nl80211: for bssid "
2293 MAC_ADDRESS_STR
Abhishek Singhac2be142015-12-03 16:16:25 +05302294 " result:%d and Status:%d reasoncode %d"),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002295 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
Abhishek Singhac2be142015-12-03 16:16:25 +05302296 roamResult, roamStatus,
2297 pRoamInfo->reasonCode);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002298 else
2299 hddLog(LOGE,
2300 FL("connect failed: for bssid "
2301 MAC_ADDRESS_STR
Abhishek Singhac2be142015-12-03 16:16:25 +05302302 " result:%d and Status:%d "),
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002303 MAC_ADDR_ARRAY(pWextState->req_bssId.bytes),
2304 roamResult, roamStatus);
2305
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002306 /* inform association failure event to nl80211 */
2307 if (eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL ==
2308 roamResult) {
2309 if (pRoamInfo)
2310 cfg80211_connect_result(dev,
2311 pRoamInfo->bssid.bytes,
2312 NULL, 0, NULL, 0,
2313 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2314 GFP_KERNEL);
2315 else
2316 cfg80211_connect_result(dev,
2317 pWextState->req_bssId.bytes,
2318 NULL, 0, NULL, 0,
2319 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2320 GFP_KERNEL);
2321 } else {
2322 if (pRoamInfo) {
2323 eCsrAuthType authType =
2324 pWextState->roamProfile.AuthType.
2325 authType[0];
Abhishek Singhac2be142015-12-03 16:16:25 +05302326 eCsrEncryptionType encryption_type =
2327 pWextState->roamProfile.
2328 EncryptionType.encryptionType[0];
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002329 bool isWep =
Abhishek Singhac2be142015-12-03 16:16:25 +05302330 (((authType ==
2331 eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002332 (authType ==
Abhishek Singhac2be142015-12-03 16:16:25 +05302333 eCSR_AUTH_TYPE_SHARED_KEY)) &&
2334 ((encryption_type ==
2335 eCSR_ENCRYPT_TYPE_WEP40) ||
2336 (encryption_type ==
2337 eCSR_ENCRYPT_TYPE_WEP104) ||
2338 (encryption_type ==
2339 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2340 (encryption_type ==
2341 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002342 /*
2343 * In case of OPEN-WEP or SHARED-WEP
2344 * authentication, send exact protocol
2345 * reason code. This enables user
2346 * applications to reconnect the station
2347 * with correct configuration.
2348 */
2349 cfg80211_connect_result(dev,
2350 pRoamInfo->bssid.bytes, NULL, 0,
2351 NULL, 0,
Abhishek Singhac2be142015-12-03 16:16:25 +05302352 (isWep &&
2353 pRoamInfo->reasonCode) ?
2354 pRoamInfo->reasonCode :
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002355 WLAN_STATUS_UNSPECIFIED_FAILURE,
2356 GFP_KERNEL);
2357 } else
2358 cfg80211_connect_result(dev,
2359 pWextState->req_bssId.bytes,
2360 NULL, 0, NULL, 0,
2361 WLAN_STATUS_UNSPECIFIED_FAILURE,
2362 GFP_KERNEL);
2363 }
Abhishek Singhac2be142015-12-03 16:16:25 +05302364 hdd_clear_roam_profile_ie(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002365 }
2366
2367 if (pRoamInfo) {
2368 if ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE ==
2369 pRoamInfo->statusCode)
2370 || (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE ==
2371 pRoamInfo->statusCode)
2372 || (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE ==
2373 pRoamInfo->statusCode)) {
2374 wlan_hdd_cfg80211_update_bss_list(pAdapter,
2375 pRoamInfo);
2376 }
2377 }
2378
2379 /*
2380 * Set connection state to eConnectionState_NotConnected only
2381 * when CSR has completed operation - with a
2382 * ASSOCIATION_FAILURE status.
2383 */
2384 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus
2385 && !hddDisconInProgress) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002386 hdd_conn_set_connection_state(pAdapter,
2387 eConnectionState_NotConnected);
2388 }
2389 hdd_wmm_init(pAdapter);
2390
2391 hddLog(LOG1, FL("Disabling queues"));
2392 wlan_hdd_netif_queue_control(pAdapter,
2393 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2394 WLAN_CONTROL_PATH);
2395 }
2396
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302397 if (QDF_STATUS_SUCCESS != cds_check_and_restart_sap(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002398 roamResult, pHddStaCtx))
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302399 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002400
Govind Singh24db1ed2015-12-18 15:54:59 +05302401 if (NULL != pRoamInfo && NULL != pRoamInfo->pBssDesc) {
2402 cds_force_sap_on_scc(roamResult,
2403 pRoamInfo->pBssDesc->channelId);
2404 } else {
2405 hdd_err("pRoamInfo profile is not set properly");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302406 return QDF_STATUS_E_FAILURE;
Govind Singh24db1ed2015-12-18 15:54:59 +05302407 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002408
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302409 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002410}
2411
2412/**
2413 * hdd_roam_ibss_indication_handler() - update the status of the IBSS
2414 * @pAdapter: pointer to adapter
2415 * @pRoamInfo: pointer to roam info
2416 * @roamId: roam id
2417 * @roamStatus: roam status
2418 * @roamResult: roam result
2419 *
2420 * Here we update the status of the Ibss when we receive information that we
2421 * have started/joined an ibss session.
2422 *
2423 * Return: none
2424 */
2425static void hdd_roam_ibss_indication_handler(hdd_adapter_t *pAdapter,
2426 tCsrRoamInfo *pRoamInfo,
2427 uint32_t roamId,
2428 eRoamCmdStatus roamStatus,
2429 eCsrRoamResult roamResult)
2430{
2431 hddLog(LOG1, "%s: id %d, status %d, result %d",
2432 pAdapter->dev->name, roamId, roamStatus, roamResult);
2433
2434 switch (roamResult) {
2435 /* both IBSS Started and IBSS Join should come in here. */
2436 case eCSR_ROAM_RESULT_IBSS_STARTED:
2437 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
2438 case eCSR_ROAM_RESULT_IBSS_COALESCED:
2439 {
2440 hdd_context_t *pHddCtx =
2441 (hdd_context_t *) pAdapter->pHddCtx;
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302442 hdd_station_ctx_t *hdd_sta_ctx =
2443 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Anurag Chouhan6d760662016-02-20 16:05:43 +05302444 struct qdf_mac_addr broadcastMacAddr =
2445 QDF_MAC_ADDR_BROADCAST_INITIALIZER;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002446
2447 if (NULL == pRoamInfo) {
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05302448 QDF_ASSERT(0);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002449 return;
2450 }
2451
2452 /* When IBSS Started comes from CSR, we need to move
2453 * connection state to IBSS Disconnected (meaning no peers
2454 * are in the IBSS).
2455 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002456 hdd_conn_set_connection_state(pAdapter,
2457 eConnectionState_IbssDisconnected);
2458 /* notify wmm */
2459 hdd_wmm_connect(pAdapter, pRoamInfo,
2460 eCSR_BSS_TYPE_IBSS);
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302461
2462 hdd_sta_ctx->broadcast_ibss_staid = pRoamInfo->staId;
2463
2464 pHddCtx->sta_to_adapter[pRoamInfo->staId] =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002465 pAdapter;
2466 hdd_roam_register_sta(pAdapter, pRoamInfo,
Chandrasekaran, Manishekar34e325a2015-12-18 12:07:22 +05302467 pRoamInfo->staId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002468 &broadcastMacAddr,
2469 pRoamInfo->pBssDesc);
2470
2471 if (pRoamInfo->pBssDesc) {
2472 struct cfg80211_bss *bss;
2473#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
2474 struct ieee80211_channel *chan;
2475 int chan_no;
2476 unsigned int freq;
2477#endif
2478 /* we created the IBSS, notify supplicant */
2479 hddLog(LOG1,
2480 FL("%s: created ibss " MAC_ADDRESS_STR),
2481 pAdapter->dev->name,
2482 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2483
2484 /* we must first give cfg80211 the BSS information */
2485 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter,
2486 pRoamInfo);
2487 if (NULL == bss) {
2488 hddLog(LOGE,
2489 FL("%s: unable to create IBSS entry"),
2490 pAdapter->dev->name);
2491 return;
2492 }
2493 hddLog(LOG1, FL("Enabling queues"));
2494 wlan_hdd_netif_queue_control(pAdapter,
2495 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
2496 WLAN_CONTROL_PATH);
2497
2498#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 15, 0))
2499 chan_no = pRoamInfo->pBssDesc->channelId;
2500
2501 if (chan_no <= 14)
2502 freq = ieee80211_channel_to_frequency(chan_no,
2503 IEEE80211_BAND_2GHZ);
2504 else
2505 freq = ieee80211_channel_to_frequency(chan_no,
2506 IEEE80211_BAND_5GHZ);
2507
2508 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2509
2510 if (chan)
2511 cfg80211_ibss_joined(pAdapter->dev,
2512 bss->bssid, chan,
2513 GFP_KERNEL);
2514 else
2515 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2516 pAdapter->dev->name,
2517 (int)pRoamInfo->pBssDesc->channelId);
2518#else
2519 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2520 GFP_KERNEL);
2521#endif
2522 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002523 pHddCtx->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002524 bss);
2525 }
Krunal Soni2c68f232015-10-26 20:52:51 -07002526 if (eCSR_ROAM_RESULT_IBSS_STARTED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002527 cds_incr_active_session(pAdapter->device_mode,
Krunal Soni2c68f232015-10-26 20:52:51 -07002528 pAdapter->sessionId);
2529 } else if (eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS == roamResult ||
2530 eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) {
Tushnim Bhattacharyyaca50b322015-12-28 17:14:36 -08002531 cds_update_connection_info(pAdapter->sessionId);
Krunal Soni2c68f232015-10-26 20:52:51 -07002532 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002533 break;
2534 }
2535
2536 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2537 {
2538 hddLog(LOGE,
2539 FL("%s: unable to create IBSS"), pAdapter->dev->name);
2540 break;
2541 }
2542
2543 default:
2544 hddLog(LOGE, FL("%s: unexpected result %d"),
2545 pAdapter->dev->name, (int)roamResult);
2546 break;
2547 }
2548
2549 return;
2550}
2551
2552/**
2553 * roam_save_ibss_station() - Save the IBSS peer MAC address in the adapter
2554 * @pHddStaCtx: pointer to global HDD station context
2555 * @staId: station id
2556 * @peerMacAddress: pointer to peer MAC address
2557 *
2558 * This information is passed to iwconfig later. The peer that joined
2559 * last is passed as information to iwconfig.
2560 *
2561 * Return:
2562 * true if we add MAX_IBSS_PEERS or less STA
2563 * false otherwise.
2564 */
2565static bool roam_save_ibss_station(hdd_station_ctx_t *pHddStaCtx, uint8_t staId,
Anurag Chouhan6d760662016-02-20 16:05:43 +05302566 struct qdf_mac_addr *peerMacAddress)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002567{
2568 bool fSuccess = false;
2569 int idx = 0;
2570
2571 for (idx = 0; idx < MAX_IBSS_PEERS; idx++) {
2572 if (0 == pHddStaCtx->conn_info.staId[idx]) {
2573 pHddStaCtx->conn_info.staId[idx] = staId;
2574
Anurag Chouhanc5548422016-02-24 18:33:27 +05302575 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002576 peerMacAddress[idx], peerMacAddress);
2577
2578 fSuccess = true;
2579 break;
2580 }
2581 }
2582
2583 return fSuccess;
2584}
2585
2586/**
2587 * roam_remove_ibss_station() - Remove the IBSS peer MAC address in the adapter
2588 * @pAdapter: pointer to adapter
2589 * @staId: station id
2590 *
2591 * Return:
2592 * true if we remove MAX_IBSS_PEERS or less STA
2593 * false otherwise.
2594 */
2595static bool roam_remove_ibss_station(hdd_adapter_t *pAdapter, uint8_t staId)
2596{
2597 bool fSuccess = false;
2598 int idx = 0;
2599 uint8_t valid_idx = 0;
2600 uint8_t del_idx = 0;
2601 uint8_t empty_slots = 0;
2602 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2603
2604 for (idx = 0; idx < MAX_IBSS_PEERS; idx++) {
2605 if (staId == pHddStaCtx->conn_info.staId[idx]) {
2606 pHddStaCtx->conn_info.staId[idx] = 0;
2607
Anurag Chouhanc5548422016-02-24 18:33:27 +05302608 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002609 peerMacAddress[idx]);
2610
2611 fSuccess = true;
2612
2613 /*
2614 * Note the deleted Index, if its 0 we need special
2615 * handling.
2616 */
2617 del_idx = idx;
2618
2619 empty_slots++;
2620 } else {
2621 if (pHddStaCtx->conn_info.staId[idx] != 0) {
2622 valid_idx = idx;
2623 } else {
2624 /* Found an empty slot */
2625 empty_slots++;
2626 }
2627 }
2628 }
2629
2630 if (MAX_IBSS_PEERS == empty_slots) {
2631 /* Last peer departed, set the IBSS state appropriately */
2632 pHddStaCtx->conn_info.connState =
2633 eConnectionState_IbssDisconnected;
2634 hddLog(LOGE, "Last IBSS Peer Departed!!!");
2635 }
2636 /* Find next active staId, to have a valid sta trigger for TL. */
2637 if (fSuccess == true) {
2638 if (del_idx == 0) {
2639 if (pHddStaCtx->conn_info.staId[valid_idx] != 0) {
2640 pHddStaCtx->conn_info.staId[0] =
2641 pHddStaCtx->conn_info.staId[valid_idx];
Anurag Chouhanc5548422016-02-24 18:33:27 +05302642 qdf_copy_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002643 peerMacAddress[0],
2644 &pHddStaCtx->conn_info.
2645 peerMacAddress[valid_idx]);
2646
2647 pHddStaCtx->conn_info.staId[valid_idx] = 0;
Anurag Chouhanc5548422016-02-24 18:33:27 +05302648 qdf_zero_macaddr(&pHddStaCtx->conn_info.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002649 peerMacAddress[valid_idx]);
2650 }
2651 }
2652 }
2653 return fSuccess;
2654}
2655
2656/**
2657 * roam_ibss_connect_handler() - IBSS connection handler
2658 * @pAdapter: pointer to adapter
2659 * @pRoamInfo: pointer to roam info
2660 *
2661 * We update the status of the IBSS to connected in this function.
2662 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302663 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002664 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302665static QDF_STATUS roam_ibss_connect_handler(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002666 tCsrRoamInfo *pRoamInfo)
2667{
2668 struct cfg80211_bss *bss;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002669 /*
2670 * Set the internal connection state to show 'IBSS Connected' (IBSS with
2671 * a partner stations).
2672 */
2673 hdd_conn_set_connection_state(pAdapter, eConnectionState_IbssConnected);
2674
2675 /* Save the connection info from CSR... */
2676 hdd_conn_save_connect_info(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
2677
2678 /* Send the bssid address to the wext. */
2679 hdd_send_association_event(pAdapter->dev, pRoamInfo);
2680 /* add bss_id to cfg80211 data base */
2681 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2682 if (NULL == bss) {
2683 hddLog(LOGE,
2684 FL("%s: unable to create IBSS entry"),
2685 pAdapter->dev->name);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302686 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002687 }
2688 cfg80211_put_bss(
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002689 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002690 bss);
2691
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302692 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002693}
2694
2695/**
2696 * hdd_roam_mic_error_indication_handler() - MIC error indication handler
2697 * @pAdapter: pointer to adapter
2698 * @pRoamInfo: pointer to roam info
2699 * @roamId: roam id
2700 * @roamStatus: roam status
2701 * @roamResult: roam result
2702 *
2703 * This function indicates the Mic failure to the supplicant
2704 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302705 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002706 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302707static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002708hdd_roam_mic_error_indication_handler(hdd_adapter_t *pAdapter,
2709 tCsrRoamInfo *pRoamInfo,
2710 uint32_t roamId,
2711 eRoamCmdStatus roamStatus,
2712 eCsrRoamResult roamResult)
2713{
2714 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2715
2716 if (eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2717 TKIP_COUNTER_MEASURE_STOPED ==
2718 pHddStaCtx->WextState.mTKIPCounterMeasures) {
2719 struct iw_michaelmicfailure msg;
2720 union iwreq_data wreq;
2721 memset(&msg, '\0', sizeof(msg));
2722 msg.src_addr.sa_family = ARPHRD_ETHER;
2723 memcpy(msg.src_addr.sa_data,
2724 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2725 sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
2726 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2727 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
2728
2729 if (pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2730 msg.flags = IW_MICFAILURE_GROUP;
2731 else
2732 msg.flags = IW_MICFAILURE_PAIRWISE;
2733 memset(&wreq, 0, sizeof(wreq));
2734 wreq.data.length = sizeof(msg);
2735 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq,
2736 (char *)&msg);
2737 /* inform mic failure to nl80211 */
2738 cfg80211_michael_mic_failure(pAdapter->dev,
2739 pRoamInfo->u.pMICFailureInfo->
2740 taMacAddr,
2741 ((pRoamInfo->u.pMICFailureInfo->
2742 multicast ==
2743 eSIR_TRUE) ?
2744 NL80211_KEYTYPE_GROUP :
2745 NL80211_KEYTYPE_PAIRWISE),
2746 pRoamInfo->u.pMICFailureInfo->
2747 keyId,
2748 pRoamInfo->u.pMICFailureInfo->TSC,
2749 GFP_KERNEL);
2750
2751 }
2752
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302753 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002754}
2755
2756/**
2757 * roam_roam_connect_status_update_handler() - IBSS connect status update
2758 * @pAdapter: pointer to adapter
2759 * @pRoamInfo: pointer to roam info
2760 * @roamId: roam id
2761 * @roamStatus: roam status
2762 * @roamResult: roam result
2763 *
2764 * The Ibss connection status is updated regularly here in this function.
2765 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302766 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002767 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302768static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002769roam_roam_connect_status_update_handler(hdd_adapter_t *pAdapter,
2770 tCsrRoamInfo *pRoamInfo,
2771 uint32_t roamId,
2772 eRoamCmdStatus roamStatus,
2773 eCsrRoamResult roamResult)
2774{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302775 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002776
2777 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2778 switch (roamResult) {
2779 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2780 {
2781 hdd_station_ctx_t *pHddStaCtx =
2782 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2783 struct station_info staInfo;
2784
2785 pr_info("IBSS New Peer indication from SME "
2786 "with peerMac " MAC_ADDRESS_STR " BSSID: "
2787 MAC_ADDRESS_STR " and stationID= %d",
2788 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
2789 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
2790 pRoamInfo->staId);
2791
2792 if (!roam_save_ibss_station
2793 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2794 pRoamInfo->staId,
2795 &pRoamInfo->peerMac)) {
2796 hddLog(LOGW, "Max reached: Can't register new IBSS peer");
2797 break;
2798 }
2799
2800 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2801
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002802 /* Register the Station with TL for the new peer. */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302803 qdf_status = hdd_roam_register_sta(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002804 pRoamInfo,
2805 pRoamInfo->staId,
2806 &pRoamInfo->peerMac,
2807 pRoamInfo->pBssDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302808 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002809 hddLog(LOGE,
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302810 "Cannot register STA with TL for IBSS. Failed with qdf_status = %d [%08X]",
2811 qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002812 }
2813 pHddStaCtx->ibss_sta_generation++;
2814 memset(&staInfo, 0, sizeof(staInfo));
2815 staInfo.filled = 0;
2816 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2817
2818 cfg80211_new_sta(pAdapter->dev,
2819 (const u8 *)pRoamInfo->peerMac.bytes,
2820 &staInfo, GFP_KERNEL);
2821
2822 if (eCSR_ENCRYPT_TYPE_WEP40_STATICKEY ==
2823 pHddStaCtx->ibss_enc_key.encType
2824 || eCSR_ENCRYPT_TYPE_WEP104_STATICKEY ==
2825 pHddStaCtx->ibss_enc_key.encType
2826 || eCSR_ENCRYPT_TYPE_TKIP ==
2827 pHddStaCtx->ibss_enc_key.encType
2828 || eCSR_ENCRYPT_TYPE_AES ==
2829 pHddStaCtx->ibss_enc_key.encType) {
2830 pHddStaCtx->ibss_enc_key.keyDirection =
2831 eSIR_TX_RX;
Anurag Chouhanc5548422016-02-24 18:33:27 +05302832 qdf_copy_macaddr(&pHddStaCtx->ibss_enc_key.peerMac,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002833 &pRoamInfo->peerMac);
2834
2835 hddLog(LOG2, "New peer joined set PTK encType=%d",
2836 pHddStaCtx->ibss_enc_key.encType);
2837
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302838 qdf_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002839 sme_roam_set_key(WLAN_HDD_GET_HAL_CTX
2840 (pAdapter),
2841 pAdapter->sessionId,
2842 &pHddStaCtx->ibss_enc_key,
2843 &roamId);
2844
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302845 if (QDF_STATUS_SUCCESS != qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002846 hddLog(LOGE,
2847 FL("sme_roam_set_key failed, status=%d"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302848 qdf_status);
2849 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002850 }
2851 }
2852 hddLog(LOG1, FL("Enabling queues"));
2853 wlan_hdd_netif_queue_control(pAdapter,
2854 WLAN_START_ALL_NETIF_QUEUE_N_CARRIER,
2855 WLAN_CONTROL_PATH);
2856 break;
2857 }
2858
2859 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2860 {
2861
2862 roam_ibss_connect_handler(pAdapter, pRoamInfo);
2863
2864 break;
2865 }
2866 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2867 {
2868 hdd_station_ctx_t *pHddStaCtx =
2869 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2870
2871 if (!roam_remove_ibss_station(pAdapter, pRoamInfo->staId))
2872 hddLog(LOGW,
2873 "IBSS peer departed by cannot find peer in our registration table with TL");
2874
2875 pr_info("IBSS Peer Departed from SME "
2876 "with peerMac " MAC_ADDRESS_STR " BSSID: "
2877 MAC_ADDRESS_STR " and stationID= %d",
2878 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
2879 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId.bytes),
2880 pRoamInfo->staId);
2881
2882 hdd_roam_deregister_sta(pAdapter, pRoamInfo->staId);
2883
2884 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
2885 pHddStaCtx->ibss_sta_generation++;
2886
2887 cfg80211_del_sta(pAdapter->dev,
2888 (const u8 *)&pRoamInfo->peerMac.bytes,
2889 GFP_KERNEL);
2890 break;
2891 }
2892 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2893 {
2894 hddLog(LOG3,
2895 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
2896 /* Stop only when we are inactive */
2897 hddLog(LOG1, FL("Disabling queues"));
2898 wlan_hdd_netif_queue_control(pAdapter,
2899 WLAN_NETIF_TX_DISABLE_N_CARRIER,
2900 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002901 hdd_conn_set_connection_state(pAdapter,
2902 eConnectionState_NotConnected);
2903
2904 /* Send the bssid address to the wext. */
2905 hdd_send_association_event(pAdapter->dev, pRoamInfo);
2906 break;
2907 }
2908 default:
2909 break;
2910
2911 }
2912
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302913 return QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002914}
2915
2916#ifdef FEATURE_WLAN_TDLS
2917/**
2918 * hdd_roam_register_tdlssta() - register new TDLS station
2919 * @pAdapter: pointer to adapter
2920 * @peerMac: pointer to peer MAC address
2921 * @staId: station identifier
2922 * @ucastSig: unicast signature
2923 *
2924 * Construct the staDesc and register with TL the new STA.
2925 * This is called as part of ADD_STA in the TDLS setup.
2926 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302927 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002928 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302929QDF_STATUS hdd_roam_register_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002930 const uint8_t *peerMac, uint16_t staId,
2931 uint8_t ucastSig)
2932{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302933 QDF_STATUS qdf_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002934 struct ol_txrx_desc_type staDesc = { 0 };
Dhanashri Atre182b0272016-02-17 15:35:07 -08002935 struct ol_txrx_ops txrx_ops;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002936
2937 /*
2938 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2939 * be peer MAC, here we are working on direct Link
2940 */
2941 staDesc.sta_id = staId;
2942
2943 /* set the QoS field appropriately .. */
2944 (hdd_wmm_is_active(pAdapter)) ? (staDesc.is_qos_enabled = 1)
2945 : (staDesc.is_qos_enabled = 0);
2946
Dhanashri Atre50141c52016-04-07 13:15:29 -07002947 /* Register the vdev transmit and receive functions */
2948 qdf_mem_zero(&txrx_ops, sizeof(txrx_ops));
2949 txrx_ops.rx.rx = hdd_rx_packet_cbk;
2950 ol_txrx_vdev_register(
2951 ol_txrx_get_vdev_from_vdev_id(pAdapter->sessionId),
2952 pAdapter, &txrx_ops);
2953 pAdapter->tx_fn = txrx_ops.tx.tx;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002954
2955 /* Register the Station with TL... */
Dhanashri Atre182b0272016-02-17 15:35:07 -08002956 qdf_status = ol_txrx_register_peer(&staDesc);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302957 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002958 hddLog(LOGE, FL("ol_txrx_register_peer() failed to register. Status=%d [0x%08X]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302959 qdf_status, qdf_status);
2960 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002961 }
2962
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302963 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002964}
2965
2966/**
2967 * hdd_roam_deregister_tdlssta() - deregister new TDLS station
2968 * @pAdapter: pointer to adapter
2969 * @staId: station identifier
2970 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302971 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002972 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302973static QDF_STATUS hdd_roam_deregister_tdlssta(hdd_adapter_t *pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002974 uint8_t staId)
2975{
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302976 QDF_STATUS qdf_status;
2977 qdf_status = ol_txrx_clear_peer(staId);
2978 if (!QDF_IS_STATUS_SUCCESS(qdf_status)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002979 hddLog(LOGW, FL("ol_txrx_clear_peer() failed for staID %d. Status=%d [0x%08X]"),
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302980 staId, qdf_status, qdf_status);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002981 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302982 return qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002983}
2984
2985/**
2986 * hdd_roam_tdls_status_update_handler() - TDLS status update handler
2987 * @pAdapter: pointer to adapter
2988 * @pRoamInfo: pointer to roam info
2989 * @roamId: roam id
2990 * @roamStatus: roam status
2991 * @roamResult: roam result
2992 *
2993 * HDD interface between SME and TL to ensure TDLS client registration with
2994 * TL in case of new TDLS client is added and deregistration at the time
2995 * TDLS client is deleted.
2996 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302997 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08002998 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05302999static QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003000hdd_roam_tdls_status_update_handler(hdd_adapter_t *pAdapter,
3001 tCsrRoamInfo *pRoamInfo,
3002 uint32_t roamId,
3003 eRoamCmdStatus roamStatus,
3004 eCsrRoamResult roamResult)
3005{
3006 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3007 tdlsCtx_t *pHddTdlsCtx = WLAN_HDD_GET_TDLS_CTX_PTR(pAdapter);
3008 tSmeTdlsPeerStateParams smeTdlsPeerStateParams;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303009 QDF_STATUS status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003010 uint8_t staIdx;
3011 hddTdlsPeer_t *curr_peer;
3012 uint32_t reason;
3013
3014 hddLog(LOG2,
3015 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3016 roamResult ==
3017 eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" : roamResult
3018 ==
3019 eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
3020 roamResult ==
3021 eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND"
3022 : roamResult ==
3023 eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3024 "DEL_ALL_TDLS_PEER_IND" : roamResult ==
3025 eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ? "UPDATE_TDLS_PEER" :
3026 roamResult ==
3027 eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
3028 "LINK_ESTABLISH_REQ_RSP" : roamResult ==
3029 eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER ? "TDLS_SHOULD_DISCOVER"
3030 : roamResult ==
3031 eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN ? "TDLS_SHOULD_TEARDOWN"
3032 : roamResult ==
3033 eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED ?
3034 "TDLS_SHOULD_PEER_DISCONNECTED" : "UNKNOWN", pRoamInfo->staId,
3035 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes));
3036
3037 if (!pHddTdlsCtx) {
3038 hddLog(LOG1,
3039 FL("TDLS ctx is null, ignore roamResult (%d)"),
3040 roamResult);
3041 return status;
3042 }
3043
3044 switch (roamResult) {
3045 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3046 {
3047 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
3048 hddLog(LOGE, FL("Add Sta failed. status code(=%d)"),
3049 pRoamInfo->statusCode);
3050 } else {
3051 /*
3052 * Check if there is available index for this new TDLS
3053 * STA.
3054 */
3055 for (staIdx = 0;
3056 staIdx < pHddCtx->max_num_tdls_sta;
3057 staIdx++) {
3058 if (0 ==
3059 pHddCtx->tdlsConnInfo[staIdx].
3060 staId) {
3061 pHddCtx->tdlsConnInfo[staIdx].
3062 sessionId =
3063 pRoamInfo->sessionId;
3064 pHddCtx->tdlsConnInfo[staIdx].
3065 staId = pRoamInfo->staId;
3066
3067 hddLog(LOGW,
3068 ("TDLS: STA IDX at %d is %d "
3069 "of mac "
3070 MAC_ADDRESS_STR),
3071 staIdx,
3072 pHddCtx->
3073 tdlsConnInfo[staIdx].
3074 staId,
3075 MAC_ADDR_ARRAY
3076 (pRoamInfo->peerMac.bytes));
3077
Anurag Chouhanc5548422016-02-24 18:33:27 +05303078 qdf_copy_macaddr(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003079 tdlsConnInfo
3080 [staIdx].
3081 peerMac,
3082 &pRoamInfo->
3083 peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303084 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003085 break;
3086 }
3087 }
3088 if (staIdx < pHddCtx->max_num_tdls_sta) {
3089 if (-1 ==
3090 wlan_hdd_tdls_set_sta_id(pAdapter,
3091 pRoamInfo->
3092 peerMac.bytes,
3093 pRoamInfo->
3094 staId)) {
3095 hddLog(LOGE,
3096 "wlan_hdd_tdls_set_sta_id() failed");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303097 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003098 }
3099
3100 (WLAN_HDD_GET_CTX(pAdapter))->
3101 sta_to_adapter[pRoamInfo->staId] =
3102 pAdapter;
3103 /*
3104 * store the ucast signature,
3105 * if required for further reference.
3106 */
3107
3108 wlan_hdd_tdls_set_signature(pAdapter,
3109 pRoamInfo->
3110 peerMac.bytes,
3111 pRoamInfo->
3112 ucastSig);
3113 } else {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303114 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003115 hddLog(LOGE,
3116 FL("no available slot in conn_info. staId %d cannot be stored"),
3117 pRoamInfo->staId);
3118 }
3119 pAdapter->tdlsAddStaStatus = status;
3120 }
3121 complete(&pAdapter->tdls_add_station_comp);
3122 break;
3123 }
3124 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3125 {
3126 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
3127 hddLog(LOGE,
3128 FL("Add Sta failed. status code(=%d)"),
3129 pRoamInfo->statusCode);
3130 }
3131 /* store the ucast signature which will be used later when
3132 * registering to TL
3133 */
3134 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3135 complete(&pAdapter->tdls_add_station_comp);
3136 break;
3137 }
3138 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3139 {
3140 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode) {
3141 hddLog(LOGE,
3142 FL("Link Establish Request failed. status(=%d)"),
3143 pRoamInfo->statusCode);
3144 }
3145 complete(&pAdapter->tdls_link_establish_req_comp);
3146 break;
3147 }
3148 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
3149 {
3150 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3151 staIdx++) {
3152 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3153 pRoamInfo->sessionId)
3154 && pRoamInfo->staId ==
3155 pHddCtx->tdlsConnInfo[staIdx].staId) {
3156 hddLog(LOGW,
3157 ("HDD: del STA IDX = %x"),
3158 pRoamInfo->staId);
3159
3160 curr_peer =
3161 wlan_hdd_tdls_find_peer(pAdapter,
3162 pRoamInfo->
3163 peerMac.bytes,
3164 true);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303165 if (NULL != curr_peer) {
3166 hdd_info("Current status for peer " MAC_ADDRESS_STR " is %d",
3167 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3168 curr_peer->link_status);
3169 if (TDLS_IS_CONNECTED(curr_peer)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003170 hdd_roam_deregister_tdlssta
3171 (pAdapter,
3172 pRoamInfo->staId);
3173 wlan_hdd_tdls_decrement_peer_count
3174 (pAdapter);
Agrawal Ashishdd2075b2015-10-30 13:05:27 +05303175 } else if (eTDLS_LINK_CONNECTING ==
3176 curr_peer->link_status) {
3177 hdd_roam_deregister_tdlssta
3178 (pAdapter,
3179 pRoamInfo->staId);
3180 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003181 }
3182 wlan_hdd_tdls_reset_peer(pAdapter,
3183 pRoamInfo->
3184 peerMac.bytes);
3185
3186 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3187 pHddCtx->tdlsConnInfo[staIdx].
3188 sessionId = 255;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303189 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003190 tdlsConnInfo[staIdx].
3191 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303192 QDF_MAC_ADDR_SIZE);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303193 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003194 break;
3195 }
3196 }
3197 complete(&pAdapter->tdls_del_station_comp);
3198 }
3199 break;
3200 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3201 {
3202 hddLog(LOGE,
3203 FL("Sending teardown to supplicant with reason code %u"),
3204 pRoamInfo->reasonCode);
3205
3206 curr_peer =
3207 wlan_hdd_tdls_find_peer(pAdapter,
3208 pRoamInfo->peerMac.bytes, true);
3209 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer,
3210 pRoamInfo->reasonCode);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303211 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3212 curr_peer->peerMac);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303213 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003214 break;
3215 }
3216 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3217 {
3218 /* 0 staIdx is assigned to AP we dont want to touch that */
3219 for (staIdx = 0; staIdx < pHddCtx->max_num_tdls_sta;
3220 staIdx++) {
3221 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId ==
3222 pRoamInfo->sessionId)
3223 && pHddCtx->tdlsConnInfo[staIdx].staId) {
3224 hddLog(LOGW,
3225 ("hdd_tdlsStatusUpdate: staIdx %d "
3226 MAC_ADDRESS_STR),
3227 pHddCtx->tdlsConnInfo[staIdx].
3228 staId,
3229 MAC_ADDR_ARRAY(pHddCtx->
3230 tdlsConnInfo
3231 [staIdx].
3232 peerMac.
3233 bytes));
3234 wlan_hdd_tdls_reset_peer(pAdapter,
3235 pHddCtx->
3236 tdlsConnInfo
3237 [staIdx].
3238 peerMac.bytes);
3239 hdd_roam_deregister_tdlssta(pAdapter,
3240 pHddCtx->
3241 tdlsConnInfo
3242 [staIdx].
3243 staId);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303244 qdf_mem_zero(&smeTdlsPeerStateParams,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003245 sizeof
3246 (smeTdlsPeerStateParams));
3247 smeTdlsPeerStateParams.vdevId =
3248 pHddCtx->tdlsConnInfo[staIdx].
3249 sessionId;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303250 qdf_mem_copy(&smeTdlsPeerStateParams.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003251 peerMacAddr,
3252 &pHddCtx->
3253 tdlsConnInfo[staIdx].
3254 peerMac.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303255 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003256 smeTdlsPeerStateParams.peerState =
3257 eSME_TDLS_PEER_STATE_TEARDOWN;
3258
3259 hddLog(LOG1,
3260 FL("calling sme_update_tdls_peer_state for staIdx %d "
3261 MAC_ADDRESS_STR),
3262 pHddCtx->tdlsConnInfo[staIdx].
3263 staId,
3264 MAC_ADDR_ARRAY(pHddCtx->
3265 tdlsConnInfo
3266 [staIdx].
3267 peerMac.
3268 bytes));
3269 status =
3270 sme_update_tdls_peer_state(
3271 pHddCtx->hHal,
3272 &smeTdlsPeerStateParams);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303273 if (QDF_STATUS_SUCCESS != status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003274 hddLog(LOGE,
3275 FL("sme_update_tdls_peer_state failed for "
3276 MAC_ADDRESS_STR),
3277 MAC_ADDR_ARRAY
3278 (pHddCtx->
3279 tdlsConnInfo[staIdx].
3280 peerMac.bytes));
3281 }
3282 wlan_hdd_tdls_decrement_peer_count
3283 (pAdapter);
3284
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303285 qdf_mem_zero(&pHddCtx->
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003286 tdlsConnInfo[staIdx].
3287 peerMac,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303288 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003289 pHddCtx->tdlsConnInfo[staIdx].staId = 0;
3290 pHddCtx->tdlsConnInfo[staIdx].
3291 sessionId = 255;
3292
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303293 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003294 }
3295 }
3296 break;
3297 }
3298 case eCSR_ROAM_RESULT_TDLS_SHOULD_DISCOVER:
3299 {
3300 /* ignore TDLS_SHOULD_DISCOVER if any concurrency detected */
Anurag Chouhan6d760662016-02-20 16:05:43 +05303301 if (((1 << QDF_STA_MODE) != pHddCtx->concurrency_mode) ||
3302 (pHddCtx->no_of_active_sessions[QDF_STA_MODE] > 1)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003303 hddLog(LOG2,
3304 FL("concurrency detected. ignore SHOULD_DISCOVER concurrency_mode: 0x%x, active_sessions: %d"),
3305 pHddCtx->concurrency_mode,
Anurag Chouhan6d760662016-02-20 16:05:43 +05303306 pHddCtx->no_of_active_sessions[QDF_STA_MODE]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303307 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003308 break;
3309 }
3310
3311 curr_peer =
3312 wlan_hdd_tdls_get_peer(pAdapter,
3313 pRoamInfo->peerMac.bytes);
3314 if (!curr_peer) {
3315 hddLog(LOGE, FL("curr_peer is null"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303316 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003317 } else {
3318 if (eTDLS_LINK_CONNECTED ==
3319 curr_peer->link_status) {
3320 hddLog(LOGE,
3321 FL("TDLS link status is connected, ignore SHOULD_DISCOVER"));
3322 } else {
3323 /*
3324 * If external control is enabled then initiate
3325 * TDLS only if forced peer is set otherwise
3326 * ignore should Discover trigger from fw.
3327 */
3328 if (pHddCtx->config->
3329 fTDLSExternalControl
3330 && (false ==
3331 curr_peer->isForcedPeer)) {
3332 hddLog(LOG2,
3333 FL
3334 ("TDLS ExternalControl enabled but curr_peer is not forced, ignore SHOULD_DISCOVER"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303335 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003336 break;
3337 } else {
3338 hddLog(LOG2,
3339 FL
3340 ("initiate TDLS setup on SHOULD_DISCOVER, fTDLSExternalControl: %d, curr_peer->isForcedPeer: %d, reason: %d"),
3341 pHddCtx->config->
3342 fTDLSExternalControl,
3343 curr_peer->isForcedPeer,
3344 pRoamInfo->reasonCode);
3345 }
3346 wlan_hdd_tdls_pre_setup_init_work
3347 (pHddTdlsCtx, curr_peer);
3348 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303349 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003350 }
3351 break;
3352 }
3353
3354 case eCSR_ROAM_RESULT_TDLS_SHOULD_TEARDOWN:
3355 {
3356 curr_peer =
3357 wlan_hdd_tdls_find_peer(pAdapter,
3358 pRoamInfo->peerMac.bytes, true);
3359 if (!curr_peer) {
3360 hddLog(LOGE, FL("curr_peer is null"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303361 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003362 } else {
3363 if (eTDLS_LINK_CONNECTED ==
3364 curr_peer->link_status) {
3365 hddLog(LOGE,
3366 FL
3367 ("Received SHOULD_TEARDOWN for peer "
3368 MAC_ADDRESS_STR
3369 " staId: %d, reason: %d"),
3370 MAC_ADDR_ARRAY(pRoamInfo->
3371 peerMac.bytes),
3372 pRoamInfo->staId,
3373 pRoamInfo->reasonCode);
3374
3375 if (pRoamInfo->reasonCode ==
3376 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
3377 pRoamInfo->reasonCode ==
3378 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
3379 pRoamInfo->reasonCode ==
3380 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
3381 pRoamInfo->reasonCode ==
3382 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
3383 reason =
3384 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
3385 } else
3386 reason =
3387 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
3388
3389 wlan_hdd_tdls_indicate_teardown
3390 (pHddTdlsCtx->pAdapter, curr_peer,
3391 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303392 hdd_send_wlan_tdls_teardown_event(
3393 eTDLS_TEARDOWN_BSS_DISCONNECT,
3394 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003395 } else {
3396 hddLog(LOGE,
3397 FL
3398 ("TDLS link is not connected, ignore SHOULD_TEARDOWN, reason: %d"),
3399 pRoamInfo->reasonCode);
3400 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303401 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003402 }
3403 break;
3404 }
3405
3406 case eCSR_ROAM_RESULT_TDLS_SHOULD_PEER_DISCONNECTED:
3407 {
3408 curr_peer =
3409 wlan_hdd_tdls_find_peer(pAdapter,
3410 pRoamInfo->peerMac.bytes, true);
3411 if (!curr_peer) {
3412 hddLog(LOGE, FL("curr_peer is null"));
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303413 status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003414 } else {
3415 if (eTDLS_LINK_CONNECTED ==
3416 curr_peer->link_status) {
3417 hddLog(LOGE,
3418 FL
3419 ("Received SHOULD_PEER_DISCONNECTED for peer "
3420 MAC_ADDRESS_STR
3421 " staId: %d, reason: %d"),
3422 MAC_ADDR_ARRAY(pRoamInfo->peerMac.bytes),
3423 pRoamInfo->staId,
3424 pRoamInfo->reasonCode);
3425
3426 if (pRoamInfo->reasonCode ==
3427 eWNI_TDLS_TEARDOWN_REASON_RSSI ||
3428 pRoamInfo->reasonCode ==
3429 eWNI_TDLS_DISCONNECTED_REASON_PEER_DELETE ||
3430 pRoamInfo->reasonCode ==
3431 eWNI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT ||
3432 pRoamInfo->reasonCode ==
3433 eWNI_TDLS_TEARDOWN_REASON_NO_RESPONSE) {
3434 reason =
3435 eSIR_MAC_TDLS_TEARDOWN_PEER_UNREACHABLE;
3436 } else
3437 reason =
3438 eSIR_MAC_TDLS_TEARDOWN_UNSPEC_REASON;
3439
3440 wlan_hdd_tdls_indicate_teardown
3441 (pHddTdlsCtx->pAdapter, curr_peer,
3442 reason);
Abhishek Singh4ef5fe02016-04-27 12:21:24 +05303443 hdd_send_wlan_tdls_teardown_event(
3444 eTDLS_TEARDOWN_BSS_DISCONNECT,
3445 curr_peer->peerMac);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003446 } else {
3447 hddLog(LOGE,
3448 FL
3449 ("TDLS link is not connected, ignore SHOULD_PEER_DISCONNECTED, reason: %d"),
3450 pRoamInfo->reasonCode);
3451 }
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303452 status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003453 }
3454 break;
3455 }
3456 default:
3457 {
3458 break;
3459 }
3460 }
3461
3462 return status;
3463}
3464#endif
3465
3466#ifdef WLAN_FEATURE_11W
3467/**
3468 * hdd_indicate_unprot_mgmt_frame() - indicate unprotected management frame
3469 * @pAdapter: pointer to the adapter
3470 * @nFrameLength: Length of the unprotected frame being passed
3471 * @pbFrames: Pointer to the frame buffer
3472 * @frameType: 802.11 frame type
3473 *
3474 * This function forwards the unprotected management frame to the supplicant.
3475 *
3476 * Return: nothing
3477 */
3478static void
3479hdd_indicate_unprot_mgmt_frame(hdd_adapter_t *pAdapter, uint32_t nFrameLength,
3480 uint8_t *pbFrames, uint8_t frameType)
3481{
3482 uint8_t type = 0;
3483 uint8_t subType = 0;
3484
3485 hddLog(LOG1, FL("Frame Type = %d Frame Length = %d"),
3486 frameType, nFrameLength);
3487
3488 /* Sanity Checks */
3489 if (NULL == pAdapter) {
3490 hddLog(LOGE, FL("pAdapter is NULL"));
3491 return;
3492 }
3493
3494 if (NULL == pAdapter->dev) {
3495 hddLog(LOGE, FL("pAdapter->dev is NULL"));
3496 return;
3497 }
3498
3499 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic) {
3500 hddLog(LOGE, FL("pAdapter has invalid magic"));
3501 return;
3502 }
3503
3504 if (!nFrameLength) {
3505 hddLog(LOGE, FL("Frame Length is Invalid ZERO"));
3506 return;
3507 }
3508
3509 if (NULL == pbFrames) {
3510 hddLog(LOGE, FL("pbFrames is NULL"));
3511 return;
3512 }
3513
3514 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3515 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3516
3517 /* Get pAdapter from Destination mac address of the frame */
3518 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC) {
3519#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
3520 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
3521 nFrameLength);
3522#else
3523 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames,
3524 nFrameLength);
3525#endif
3526 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
3527 } else if (type == SIR_MAC_MGMT_FRAME &&
3528 subType == SIR_MAC_MGMT_DEAUTH) {
3529#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
3530 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames,
3531 nFrameLength);
3532#else
3533 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames,
3534 nFrameLength);
3535#endif
3536 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
3537 } else {
3538 hddLog(LOGE, FL("Frame type %d and subtype %d are not valid"),
3539 type, subType);
3540 return;
3541 }
3542}
3543#endif
3544
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003545#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003546/**
3547 * hdd_indicate_tsm_ie() - send traffic stream metrics ie
3548 * @pAdapter: pointer to adapter
3549 * @tid: traffic identifier
3550 * @state: state
3551 * @measInterval: measurement interval
3552 *
3553 * This function sends traffic stream metrics IE information to
3554 * the supplicant via wireless event.
3555 *
3556 * Return: none
3557 */
3558static void
3559hdd_indicate_tsm_ie(hdd_adapter_t *pAdapter, uint8_t tid,
3560 uint8_t state, uint16_t measInterval)
3561{
3562 union iwreq_data wrqu;
3563 char buf[IW_CUSTOM_MAX + 1];
3564 int nBytes = 0;
3565
3566 if (NULL == pAdapter)
3567 return;
3568
3569 /* create the event */
3570 memset(&wrqu, '\0', sizeof(wrqu));
3571 memset(buf, '\0', sizeof(buf));
3572
3573 hddLog(LOG1, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
3574 tid, state, measInterval);
3575
3576 nBytes =
3577 snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d", tid, state,
3578 measInterval);
3579
3580 wrqu.data.pointer = buf;
3581 wrqu.data.length = nBytes;
3582 /* send the event */
3583 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3584}
3585
3586/**
3587 * hdd_indicate_cckm_pre_auth() - send cckm preauth indication
3588 * @pAdapter: pointer to adapter
3589 * @pRoamInfo: pointer to roam info
3590 *
3591 * This function sends cckm preauth indication to the supplicant
3592 * via wireless custom event.
3593 *
3594 * Return: none
3595 */
3596static void
3597hdd_indicate_cckm_pre_auth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
3598{
3599 union iwreq_data wrqu;
3600 char buf[IW_CUSTOM_MAX + 1];
3601 char *pos = buf;
3602 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3603
3604 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3605 return;
3606
3607 /* create the event */
3608 memset(&wrqu, '\0', sizeof(wrqu));
3609 memset(buf, '\0', sizeof(buf));
3610
3611 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
3612 hddLog(LOG1,
3613 "CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %d:%d",
3614 MAC_ADDR_ARRAY(pRoamInfo->bssid.bytes),
3615 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
3616
3617 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
3618 pos += nBytes;
3619 freeBytes -= nBytes;
3620
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303621 qdf_mem_copy(pos, pRoamInfo->bssid.bytes, QDF_MAC_ADDR_SIZE);
Anurag Chouhan6d760662016-02-20 16:05:43 +05303622 pos += QDF_MAC_ADDR_SIZE;
3623 freeBytes -= QDF_MAC_ADDR_SIZE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003624
3625 nBytes = snprintf(pos, freeBytes, " %u:%u",
3626 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
3627 freeBytes -= nBytes;
3628
3629 wrqu.data.pointer = buf;
3630 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
3631
3632 /* send the event */
3633 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3634}
3635
3636/**
3637 * hdd_indicate_ese_adj_ap_rep_ind() - send adjacent AP report indication
3638 * @pAdapter: pointer to adapter
3639 * @pRoamInfo: pointer to roam info
3640 *
3641 * Return: none
3642 */
3643static void
3644hdd_indicate_ese_adj_ap_rep_ind(hdd_adapter_t *pAdapter,
3645 tCsrRoamInfo *pRoamInfo)
3646{
3647 union iwreq_data wrqu;
3648 char buf[IW_CUSTOM_MAX + 1];
3649 int nBytes = 0;
3650
3651 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3652 return;
3653
3654 /* create the event */
3655 memset(&wrqu, '\0', sizeof(wrqu));
3656 memset(buf, '\0', sizeof(buf));
3657
3658 hddLog(LOG1, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
3659
3660 nBytes =
3661 snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u",
3662 pRoamInfo->tsmRoamDelay);
3663
3664 wrqu.data.pointer = buf;
3665 wrqu.data.length = nBytes;
3666
3667 /* send the event */
3668 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3669}
3670
3671/**
3672 * hdd_indicate_ese_bcn_report_no_results() - beacon report no scan results
3673 * @pAdapter: pointer to adapter
3674 * @measurementToken: measurement token
3675 * @flag: flag
3676 * @numBss: number of bss
3677 *
3678 * If the measurement is none and no scan results found,
3679 * indicate the supplicant about measurement done.
3680 *
3681 * Return: none
3682 */
3683void
3684hdd_indicate_ese_bcn_report_no_results(const hdd_adapter_t *pAdapter,
3685 const uint16_t measurementToken,
3686 const bool flag, const uint8_t numBss)
3687{
3688 union iwreq_data wrqu;
3689 char buf[IW_CUSTOM_MAX];
3690 char *pos = buf;
3691 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3692
3693 memset(&wrqu, '\0', sizeof(wrqu));
3694 memset(buf, '\0', sizeof(buf));
3695
3696 hddLog(LOG1, FL("CCXBCNREP=%d %d %d"), measurementToken,
3697 flag, numBss);
3698
3699 nBytes =
3700 snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
3701 flag, numBss);
3702
3703 wrqu.data.pointer = buf;
3704 wrqu.data.length = nBytes;
3705 /* send the event */
3706 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3707}
3708
3709/**
3710 * hdd_indicate_ese_bcn_report_ind() - send beacon report indication
3711 * @pAdapter: pointer to adapter
3712 * @pRoamInfo: pointer to roam info
3713 *
3714 * If the measurement is none and no scan results found,
3715 * indicate the supplicant about measurement done.
3716 *
3717 * Return: none
3718 */
3719static void
3720hdd_indicate_ese_bcn_report_ind(const hdd_adapter_t *pAdapter,
3721 const tCsrRoamInfo *pRoamInfo)
3722{
3723 union iwreq_data wrqu;
3724 char buf[IW_CUSTOM_MAX];
3725 char *pos = buf;
3726 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3727 uint8_t i = 0, len = 0;
3728 uint8_t tot_bcn_ieLen = 0; /* total size of the beacon report data */
3729 uint8_t lastSent = 0, sendBss = 0;
3730 int bcnRepFieldSize =
3731 sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].
3732 bcnReportFields);
3733 uint8_t ieLenByte = 1;
3734 /*
3735 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
3736 */
3737#define ESEBCNREPHEADER_LEN (18)
3738
3739 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3740 return;
3741
3742 /*
3743 * Custom event can pass maximum of 256 bytes of data,
3744 * based on the IE len we need to identify how many BSS info can
3745 * be filled in to custom event data.
3746 */
3747 /*
3748 * meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
3749 * bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
3750 * CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
3751 */
3752
3753 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1)
3754 && (!pRoamInfo->pEseBcnReportRsp->numBss)) {
3755 hddLog(LOG1,
3756 "Measurement Done but no scan results");
3757 /* If the measurement is none and no scan results found,
3758 indicate the supplicant about measurement done */
3759 hdd_indicate_ese_bcn_report_no_results(
3760 pAdapter,
3761 pRoamInfo->pEseBcnReportRsp->
3762 measurementToken,
3763 pRoamInfo->pEseBcnReportRsp->flag,
3764 pRoamInfo->pEseBcnReportRsp->numBss);
3765 } else {
3766 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss) {
3767 memset(&wrqu, '\0', sizeof(wrqu));
3768 memset(buf, '\0', sizeof(buf));
3769 tot_bcn_ieLen = 0;
3770 sendBss = 0;
3771 pos = buf;
3772 freeBytes = IW_CUSTOM_MAX;
3773
3774 for (i = lastSent;
3775 i < pRoamInfo->pEseBcnReportRsp->numBss; i++) {
3776 len =
3777 bcnRepFieldSize + ieLenByte +
3778 pRoamInfo->pEseBcnReportRsp->
3779 bcnRepBssInfo[i].ieLen;
3780 if ((len + tot_bcn_ieLen) >
3781 (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN)) {
3782 break;
3783 }
3784 tot_bcn_ieLen += len;
3785 sendBss++;
3786 hddLog(LOG1, "i(%d) sizeof bcnReportFields(%d) IeLength(%d) Length of Ie(%d) totLen(%d)",
3787 i, bcnRepFieldSize, 1,
3788 pRoamInfo->pEseBcnReportRsp->
3789 bcnRepBssInfo[i].ieLen, tot_bcn_ieLen);
3790 }
3791
3792 hddLog(LOG1, "Sending %d BSS Info",
3793 sendBss);
3794 hddLog(LOG1, "CCXBCNREP=%d %d %d %d",
3795 pRoamInfo->pEseBcnReportRsp->measurementToken,
3796 pRoamInfo->pEseBcnReportRsp->flag, sendBss,
3797 tot_bcn_ieLen);
3798
3799 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
3800 pRoamInfo->pEseBcnReportRsp->
3801 measurementToken,
3802 pRoamInfo->pEseBcnReportRsp->flag,
3803 sendBss);
3804 pos += nBytes;
3805 freeBytes -= nBytes;
3806
3807 /* Copy total Beacon report data length */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303808 qdf_mem_copy(pos, (char *)&tot_bcn_ieLen,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003809 sizeof(tot_bcn_ieLen));
3810 pos += sizeof(tot_bcn_ieLen);
3811 freeBytes -= sizeof(tot_bcn_ieLen);
3812
3813 for (i = 0; i < sendBss; i++) {
3814 hddLog(LOG1,
3815 "ChanNum(%d) Spare(%d) MeasDuration(%d)"
3816 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
3817 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
3818 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
3819 pRoamInfo->pEseBcnReportRsp->
3820 bcnRepBssInfo[i +
3821 lastSent].bcnReportFields.
3822 ChanNum,
3823 pRoamInfo->pEseBcnReportRsp->
3824 bcnRepBssInfo[i +
3825 lastSent].bcnReportFields.
3826 Spare,
3827 pRoamInfo->pEseBcnReportRsp->
3828 bcnRepBssInfo[i +
3829 lastSent].bcnReportFields.
3830 MeasDuration,
3831 pRoamInfo->pEseBcnReportRsp->
3832 bcnRepBssInfo[i +
3833 lastSent].bcnReportFields.
3834 PhyType,
3835 pRoamInfo->pEseBcnReportRsp->
3836 bcnRepBssInfo[i +
3837 lastSent].bcnReportFields.
3838 RecvSigPower,
3839 pRoamInfo->pEseBcnReportRsp->
3840 bcnRepBssInfo[i +
3841 lastSent].bcnReportFields.
3842 ParentTsf,
3843 pRoamInfo->pEseBcnReportRsp->
3844 bcnRepBssInfo[i +
3845 lastSent].bcnReportFields.
3846 TargetTsf[0],
3847 pRoamInfo->pEseBcnReportRsp->
3848 bcnRepBssInfo[i +
3849 lastSent].bcnReportFields.
3850 TargetTsf[1],
3851 pRoamInfo->pEseBcnReportRsp->
3852 bcnRepBssInfo[i +
3853 lastSent].bcnReportFields.
3854 BcnInterval,
3855 pRoamInfo->pEseBcnReportRsp->
3856 bcnRepBssInfo[i +
3857 lastSent].bcnReportFields.
3858 CapabilityInfo,
3859 pRoamInfo->pEseBcnReportRsp->
3860 bcnRepBssInfo[i +
3861 lastSent].bcnReportFields.
3862 Bssid[0],
3863 pRoamInfo->pEseBcnReportRsp->
3864 bcnRepBssInfo[i +
3865 lastSent].bcnReportFields.
3866 Bssid[1],
3867 pRoamInfo->pEseBcnReportRsp->
3868 bcnRepBssInfo[i +
3869 lastSent].bcnReportFields.
3870 Bssid[2],
3871 pRoamInfo->pEseBcnReportRsp->
3872 bcnRepBssInfo[i +
3873 lastSent].bcnReportFields.
3874 Bssid[3],
3875 pRoamInfo->pEseBcnReportRsp->
3876 bcnRepBssInfo[i +
3877 lastSent].bcnReportFields.
3878 Bssid[4],
3879 pRoamInfo->pEseBcnReportRsp->
3880 bcnRepBssInfo[i +
3881 lastSent].bcnReportFields.
3882 Bssid[5]);
3883
3884 /* bcn report fields are copied */
3885 len =
3886 sizeof(pRoamInfo->pEseBcnReportRsp->
3887 bcnRepBssInfo[i +
3888 lastSent].
3889 bcnReportFields);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303890 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003891 (char *)&pRoamInfo->
3892 pEseBcnReportRsp->bcnRepBssInfo[i +
3893 lastSent].
3894 bcnReportFields, len);
3895 pos += len;
3896 freeBytes -= len;
3897
3898 /* Add 1 byte of ie len */
3899 len =
3900 pRoamInfo->pEseBcnReportRsp->
3901 bcnRepBssInfo[i + lastSent].ieLen;
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303902 qdf_mem_copy(pos, (char *)&len, sizeof(len));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003903 pos += sizeof(len);
3904 freeBytes -= sizeof(len);
3905
3906 /* copy IE from scan results */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05303907 qdf_mem_copy(pos,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003908 (char *)pRoamInfo->
3909 pEseBcnReportRsp->bcnRepBssInfo[i +
3910 lastSent].
3911 pBuf, len);
3912 pos += len;
3913 freeBytes -= len;
3914 }
3915
3916 wrqu.data.pointer = buf;
3917 wrqu.data.length = IW_CUSTOM_MAX - freeBytes;
3918
3919 /* send the event */
3920 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu,
3921 buf);
3922 lastSent += sendBss;
3923 }
3924 }
3925}
3926
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08003927#endif /* FEATURE_WLAN_ESE */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003928
3929/**
Komal Seelam98760ba2015-12-15 11:05:18 +05303930 * hdd_is_8021x_sha256_auth_type() - check authentication type to 8021x_sha256
3931 * @pHddStaCtx: Station Context
3932 *
3933 * API to check if the connection authentication type is 8021x_sha256.
3934 *
3935 * Return: bool
3936 */
3937#ifdef WLAN_FEATURE_11W
3938static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
3939{
3940 return eCSR_AUTH_TYPE_RSN_8021X_SHA256 ==
3941 pHddStaCtx->conn_info.authType;
3942}
3943#else
3944static inline bool hdd_is_8021x_sha256_auth_type(hdd_station_ctx_t *pHddStaCtx)
3945{
3946 return false;
3947}
3948#endif
3949
3950/**
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003951 * hdd_sme_roam_callback() - hdd sme roam callback
3952 * @pContext: pointer to adapter context
3953 * @pRoamInfo: pointer to roam info
3954 * @roamId: roam id
3955 * @roamStatus: roam status
3956 * @roamResult: roam result
3957 *
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303958 * Return: QDF_STATUS enumeration
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003959 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303960QDF_STATUS
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003961hdd_sme_roam_callback(void *pContext, tCsrRoamInfo *pRoamInfo, uint32_t roamId,
3962 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult)
3963{
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05303964 QDF_STATUS qdf_ret_status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003965 hdd_adapter_t *pAdapter = (hdd_adapter_t *) pContext;
3966 hdd_wext_state_t *pWextState = NULL;
3967 hdd_station_ctx_t *pHddStaCtx = NULL;
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303968 QDF_STATUS status = QDF_STATUS_SUCCESS;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003969 hdd_context_t *pHddCtx = NULL;
3970
3971 hddLog(LOG2,
3972 "CSR Callback: status= %d result= %d roamID=%d",
3973 roamStatus, roamResult, roamId);
3974
3975 /* Sanity check */
3976 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)) {
3977 hddLog(LOGP, "invalid adapter or adapter has invalid magic");
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05303978 return QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003979 }
3980
3981 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3982 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3983
Anurag Chouhanb2dc16f2016-02-25 11:47:37 +05303984 MTRACE(qdf_trace(QDF_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
Sreelakshmi Konamkic88f5372015-12-22 12:50:15 +05303985 pAdapter->sessionId, roamStatus));
3986
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003987 switch (roamStatus) {
3988 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki6f3a8652015-09-25 10:58:15 +05303989 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3990 complete(&pAdapter->session_open_comp_var);
Peng Xu66162de2016-02-11 17:01:20 -08003991 hdd_debug("session %d opened", pAdapter->sessionId);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003992 break;
3993
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08003994 /*
3995 * We did pre-auth,then we attempted a 11r or ese reassoc.
3996 * reassoc failed due to failure, timeout, reject from ap
3997 * in any case tell the OS, our carrier is off and mark
3998 * interface down.
3999 */
4000 case eCSR_ROAM_FT_REASSOC_FAILED:
4001 hddLog(LOGE,
4002 FL
4003 ("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
4004 roamStatus, roamResult, pAdapter->sessionId);
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304005 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004006 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4007 roamStatus, roamResult);
4008 /*
4009 * Check if Mcast/Bcast Filters are set, if yes
4010 * clear the filters here.
4011 */
4012 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set ==
4013 true) {
4014 (WLAN_HDD_GET_CTX(pAdapter))->
4015 hdd_mcastbcast_filter_set = false;
4016 }
4017 pHddStaCtx->ft_carrier_on = false;
4018 pHddStaCtx->hdd_ReassocScenario = false;
4019 hddLog(LOG1,
4020 FL("hdd_ReassocScenario set to: %d, ReAssoc Failed, session: %d"),
4021 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
4022 break;
4023
4024 case eCSR_ROAM_FT_START:
4025 /*
4026 * When we roam for ESE and 11r, we dont want the OS to be
4027 * informed that the link is down. So mark the link ready for
4028 * ft_start. After this the eCSR_ROAM_SHOULD_ROAM will
4029 * be received. Where in we will not mark the link down
4030 * Also we want to stop tx at this point when we will be
4031 * doing disassoc at this time. This saves 30-60 msec
4032 * after reassoc.
4033 */
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004034 hddLog(LOG1, FL("Disabling queues"));
Deepak Dhamdherea2df6bb2015-10-29 15:11:06 -07004035 wlan_hdd_netif_queue_control(pAdapter,
4036 WLAN_NETIF_TX_DISABLE,
4037 WLAN_CONTROL_PATH);
4038 status = hdd_roam_deregister_sta(pAdapter,
4039 pHddStaCtx->conn_info.staId[0]);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304040 if (!QDF_IS_STATUS_SUCCESS(status))
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304041 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004042 pHddStaCtx->ft_carrier_on = true;
4043 pHddStaCtx->hdd_ReassocScenario = true;
4044 hddLog(LOG1,
4045 FL("hdd_ReassocScenario set to: %d, due to eCSR_ROAM_FT_START, session: %d"),
4046 pHddStaCtx->hdd_ReassocScenario, pAdapter->sessionId);
4047 break;
Varun Reddy Yeturuf907f912016-03-21 15:06:22 -07004048 case eCSR_ROAM_DISABLE_QUEUES:
4049 hdd_info("Disabling queues");
4050 wlan_hdd_netif_queue_control(pAdapter,
4051 WLAN_NETIF_TX_DISABLE,
4052 WLAN_CONTROL_PATH);
4053 break;
4054 case eCSR_ROAM_ENABLE_QUEUES:
4055 hdd_info("Enabling queues");
4056 wlan_hdd_netif_queue_control(pAdapter,
4057 WLAN_WAKE_ALL_NETIF_QUEUE,
4058 WLAN_CONTROL_PATH);
4059 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004060
4061 case eCSR_ROAM_SHOULD_ROAM:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004062 /* notify apps that we can't pass traffic anymore */
4063 hddLog(LOG1, FL("Disabling queues"));
4064 wlan_hdd_netif_queue_control(pAdapter,
4065 WLAN_NETIF_TX_DISABLE,
4066 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004067 if (pHddStaCtx->ft_carrier_on == false) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004068 wlan_hdd_netif_queue_control(pAdapter,
4069 WLAN_NETIF_CARRIER_OFF,
4070 WLAN_CONTROL_PATH);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004071 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004072 break;
4073 case eCSR_ROAM_LOSTLINK:
4074 if (roamResult == eCSR_ROAM_RESULT_LOSTLINK) {
4075 hddLog(LOG2, "Roaming started due to connection lost");
4076 hddLog(LOG1, FL("Disabling queues"));
4077 wlan_hdd_netif_queue_control(pAdapter,
4078 WLAN_NETIF_TX_DISABLE_N_CARRIER,
4079 WLAN_CONTROL_PATH);
4080 break;
4081 }
4082 case eCSR_ROAM_DISASSOCIATED:
4083 {
4084 hddLog(LOG1, "****eCSR_ROAM_DISASSOCIATED****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304085 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004086 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4087 roamStatus, roamResult);
4088 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
4089 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4090 if (pHddCtx->hdd_mcastbcast_filter_set == true) {
4091 hdd_conf_mcastbcast_filter(pHddCtx, false);
4092
4093 if (true ==
4094 pHddCtx->sus_res_mcastbcast_filter_valid) {
4095 pHddCtx->configuredMcastBcastFilter =
4096 pHddCtx->sus_res_mcastbcast_filter;
4097 pHddCtx->
4098 sus_res_mcastbcast_filter_valid =
4099 false;
4100 }
4101
4102 hddLog(LOG1,
4103 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4104 hddLog(LOG1,
4105 "McastBcastFilter = %d",
4106 pHddCtx->configuredMcastBcastFilter);
4107 hddLog(LOG1,
4108 "offload: already called mcastbcast filter");
4109 (WLAN_HDD_GET_CTX(pAdapter))->
4110 hdd_mcastbcast_filter_set = false;
4111 }
4112 /* Call to clear any MC Addr List filter applied after
4113 * successful connection.
4114 */
4115 wlan_hdd_set_mc_addr_list(pAdapter, false);
4116 }
4117 break;
4118 case eCSR_ROAM_IBSS_LEAVE:
4119 hddLog(LOG1, "****eCSR_ROAM_IBSS_LEAVE****");
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304120 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004121 hdd_dis_connect_handler(pAdapter, pRoamInfo, roamId,
4122 roamStatus, roamResult);
4123 break;
4124 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4125 hddLog(LOG1, "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
4126 /*
4127 * To Do - address probable memory leak with WEP encryption upon
4128 * successful association.
4129 */
4130 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult) {
4131 /* Clear saved connection information in HDD */
4132 hdd_conn_remove_connect_info(
4133 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter));
4134 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304135 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004136 hdd_association_completion_handler(pAdapter, pRoamInfo,
4137 roamId, roamStatus,
4138 roamResult);
4139#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4140 if (pRoamInfo)
4141 pRoamInfo->roamSynchInProgress = false;
4142#endif
4143 break;
4144 case eCSR_ROAM_ASSOCIATION_FAILURE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304145 qdf_ret_status = hdd_association_completion_handler(pAdapter,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004146 pRoamInfo,
4147 roamId,
4148 roamStatus,
4149 roamResult);
4150 break;
4151 case eCSR_ROAM_IBSS_IND:
4152 hdd_roam_ibss_indication_handler(pAdapter, pRoamInfo, roamId,
4153 roamStatus, roamResult);
4154 break;
4155
4156 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304157 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004158 roam_roam_connect_status_update_handler(pAdapter,
4159 pRoamInfo,
4160 roamId,
4161 roamStatus,
4162 roamResult);
4163 break;
4164
4165 case eCSR_ROAM_MIC_ERROR_IND:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304166 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004167 hdd_roam_mic_error_indication_handler(pAdapter,
4168 pRoamInfo,
4169 roamId,
4170 roamStatus,
4171 roamResult);
4172 break;
4173
4174 case eCSR_ROAM_SET_KEY_COMPLETE:
4175 {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304176 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004177 hdd_roam_set_key_complete_handler(pAdapter, pRoamInfo,
4178 roamId, roamStatus,
4179 roamResult);
4180 if (eCSR_ROAM_RESULT_AUTHENTICATED == roamResult) {
4181 pHddStaCtx->hdd_ReassocScenario = false;
4182 hddLog(LOG1,
4183 FL("hdd_ReassocScenario set to: %d, set key complete, session: %d"),
4184 pHddStaCtx->hdd_ReassocScenario,
4185 pAdapter->sessionId);
4186 }
4187 }
4188#ifdef WLAN_FEATURE_ROAM_OFFLOAD
4189 if (pRoamInfo != NULL)
4190 pRoamInfo->roamSynchInProgress = false;
4191#endif
4192 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004193
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004194 case eCSR_ROAM_FT_RESPONSE:
4195 hdd_send_ft_event(pAdapter);
4196 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004197
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004198 case eCSR_ROAM_PMK_NOTIFY:
Komal Seelam98760ba2015-12-15 11:05:18 +05304199 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType
4200 || hdd_is_8021x_sha256_auth_type(pHddStaCtx)) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004201 /* notify the supplicant of a new candidate */
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304202 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004203 wlan_hdd_cfg80211_pmksa_candidate_notify(
4204 pAdapter, pRoamInfo, 1, false);
4205 }
4206 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004207
4208#ifdef FEATURE_WLAN_LFR_METRICS
4209 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4210 /* This event is to notify pre-auth initiation */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304211 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004212 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter,
4213 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304214 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004215 }
4216 break;
4217 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4218 /*
4219 * This event will notify pre-auth completion in case of success
4220 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304221 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004222 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4223 pRoamInfo, 1)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304224 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004225 }
4226 break;
4227 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4228 /*
4229 * This event will notify pre-auth completion incase of failure.
4230 */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304231 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004232 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4233 pRoamInfo, 0)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304234 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004235 }
4236 break;
4237 case eCSR_ROAM_HANDOVER_SUCCESS:
4238 /* This event is to notify handover success.
4239 It will be only invoked on success */
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304240 if (QDF_STATUS_SUCCESS !=
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004241 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter,
4242 pRoamInfo)) {
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304243 qdf_ret_status = QDF_STATUS_E_FAILURE;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004244 }
4245 break;
4246#endif
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004247 case eCSR_ROAM_REMAIN_CHAN_READY:
4248 hdd_remain_chan_ready_handler(pAdapter, pRoamInfo->roc_scan_id);
4249 break;
4250 case eCSR_ROAM_SEND_ACTION_CNF:
4251 hdd_send_action_cnf(pAdapter,
4252 (roamResult ==
4253 eCSR_ROAM_RESULT_NONE) ? true : false);
4254 break;
4255#ifdef FEATURE_WLAN_TDLS
4256 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304257 qdf_ret_status =
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004258 hdd_roam_tdls_status_update_handler(pAdapter, pRoamInfo,
4259 roamId,
4260 roamStatus,
4261 roamResult);
4262 break;
4263 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4264 wlan_hdd_tdls_mgmt_completion_callback(pAdapter,
4265 pRoamInfo->reasonCode);
4266 break;
4267#endif
4268#ifdef WLAN_FEATURE_11W
4269 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4270 hdd_indicate_unprot_mgmt_frame(pAdapter,
4271 pRoamInfo->nFrameLength,
4272 pRoamInfo->pbFrames,
4273 pRoamInfo->frameType);
4274 break;
4275#endif
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004276#ifdef FEATURE_WLAN_ESE
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004277 case eCSR_ROAM_TSM_IE_IND:
4278 hdd_indicate_tsm_ie(pAdapter, pRoamInfo->tsmIe.tsid,
4279 pRoamInfo->tsmIe.state,
4280 pRoamInfo->tsmIe.msmt_interval);
4281 break;
4282
4283 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4284 {
4285 if (eCSR_AUTH_TYPE_CCKM_WPA ==
4286 pHddStaCtx->conn_info.authType
4287 || eCSR_AUTH_TYPE_CCKM_RSN ==
4288 pHddStaCtx->conn_info.authType) {
4289 hdd_indicate_cckm_pre_auth(pAdapter, pRoamInfo);
4290 }
4291 break;
4292 }
4293
4294 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
4295 {
4296 hdd_indicate_ese_adj_ap_rep_ind(pAdapter, pRoamInfo);
4297 break;
4298 }
4299
4300 case eCSR_ROAM_ESE_BCN_REPORT_IND:
4301 {
4302 hdd_indicate_ese_bcn_report_ind(pAdapter, pRoamInfo);
4303 break;
4304 }
Srinivas Girigowda515a9ef2015-12-11 11:00:48 -08004305#endif /* FEATURE_WLAN_ESE */
Manishekar Chandrasekarancb052172016-04-22 12:19:04 +05304306 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4307 hdd_info("channel switch for session:%d to channel:%d",
4308 pAdapter->sessionId, pRoamInfo->chan_info.chan_id);
4309
4310 status = hdd_chan_change_notify(pAdapter, pAdapter->dev,
4311 pRoamInfo->chan_info.chan_id);
4312 if (QDF_IS_STATUS_ERROR(status))
4313 hdd_err("channel change notification failed");
4314
4315 status = cds_set_hw_mode_on_channel_switch(pAdapter->sessionId);
4316 if (QDF_IS_STATUS_ERROR(status))
4317 hdd_info("set hw mode change not done");
4318 break;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004319 default:
4320 break;
4321 }
Anurag Chouhanf04e84f2016-03-03 10:12:12 +05304322 return qdf_ret_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004323}
4324
4325/**
4326 * hdd_translate_rsn_to_csr_auth_type() - Translate RSN to CSR auth type
4327 * @auth_suite: auth suite
4328 *
4329 * Return: eCsrAuthType enumeration
4330 */
4331eCsrAuthType hdd_translate_rsn_to_csr_auth_type(uint8_t auth_suite[4])
4332{
4333 eCsrAuthType auth_type;
4334 /* is the auth type supported? */
4335 if (memcmp(auth_suite, ccp_rsn_oui01, 4) == 0) {
4336 auth_type = eCSR_AUTH_TYPE_RSN;
4337 } else if (memcmp(auth_suite, ccp_rsn_oui02, 4) == 0) {
4338 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08004339 } else if (memcmp(auth_suite, ccp_rsn_oui04, 4) == 0) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004340 /* Check for 11r FT Authentication with PSK */
4341 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
4342 } else if (memcmp(auth_suite, ccp_rsn_oui03, 4) == 0) {
4343 /* Check for 11R FT Authentication with 802.1X */
4344 auth_type = eCSR_AUTH_TYPE_FT_RSN;
4345 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004346#ifdef FEATURE_WLAN_ESE
4347 if (memcmp(auth_suite, ccp_rsn_oui06, 4) == 0) {
4348 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4349 } else
4350#endif /* FEATURE_WLAN_ESE */
4351#ifdef WLAN_FEATURE_11W
4352 if (memcmp(auth_suite, ccp_rsn_oui07, 4) == 0) {
4353 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4354 } else if (memcmp(auth_suite, ccp_rsn_oui08, 4) == 0) {
4355 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4356 } else
4357#endif
4358 {
4359 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4360 }
4361 return auth_type;
4362}
4363
4364/**
4365 * hdd_translate_wpa_to_csr_auth_type() - Translate WPA to CSR auth type
4366 * @auth_suite: auth suite
4367 *
4368 * Return: eCsrAuthType enumeration
4369 */
4370eCsrAuthType hdd_translate_wpa_to_csr_auth_type(uint8_t auth_suite[4])
4371{
4372 eCsrAuthType auth_type;
4373 /* is the auth type supported? */
4374 if (memcmp(auth_suite, ccp_wpa_oui01, 4) == 0) {
4375 auth_type = eCSR_AUTH_TYPE_WPA;
4376 } else if (memcmp(auth_suite, ccp_wpa_oui02, 4) == 0) {
4377 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
4378 } else
4379#ifdef FEATURE_WLAN_ESE
4380 if (memcmp(auth_suite, ccp_wpa_oui06, 4) == 0) {
4381 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
4382 } else
4383#endif /* FEATURE_WLAN_ESE */
4384 {
4385 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4386 }
4387 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4388 return auth_type;
4389}
4390
4391/**
4392 * hdd_translate_rsn_to_csr_encryption_type() -
4393 * Translate RSN to CSR encryption type
4394 * @cipher_suite: cipher suite
4395 *
4396 * Return: eCsrEncryptionType enumeration
4397 */
4398eCsrEncryptionType
4399hdd_translate_rsn_to_csr_encryption_type(uint8_t cipher_suite[4])
4400{
4401 eCsrEncryptionType cipher_type;
4402
4403 if (memcmp(cipher_suite, ccp_rsn_oui04, 4) == 0)
4404 cipher_type = eCSR_ENCRYPT_TYPE_AES;
4405 else if (memcmp(cipher_suite, ccp_rsn_oui02, 4) == 0)
4406 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
4407 else if (memcmp(cipher_suite, ccp_rsn_oui00, 4) == 0)
4408 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
4409 else if (memcmp(cipher_suite, ccp_rsn_oui01, 4) == 0)
4410 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4411 else if (memcmp(cipher_suite, ccp_rsn_oui05, 4) == 0)
4412 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4413 else
4414 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4415
4416 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4417 return cipher_type;
4418}
4419
4420/**
4421 * hdd_translate_wpa_to_csr_encryption_type() -
4422 * Translate WPA to CSR encryption type
4423 * @cipher_suite: cipher suite
4424 *
4425 * Return: eCsrEncryptionType enumeration
4426 */
4427eCsrEncryptionType
4428hdd_translate_wpa_to_csr_encryption_type(uint8_t cipher_suite[4])
4429{
4430 eCsrEncryptionType cipher_type;
4431
4432 if (memcmp(cipher_suite, ccp_wpa_oui04, 4) == 0)
4433 cipher_type = eCSR_ENCRYPT_TYPE_AES;
4434 else if (memcmp(cipher_suite, ccp_wpa_oui02, 4) == 0)
4435 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
4436 else if (memcmp(cipher_suite, ccp_wpa_oui00, 4) == 0)
4437 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
4438 else if (memcmp(cipher_suite, ccp_wpa_oui01, 4) == 0)
4439 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4440 else if (memcmp(cipher_suite, ccp_wpa_oui05, 4) == 0)
4441 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4442 else
4443 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4444
4445 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4446 return cipher_type;
4447}
4448
4449/**
4450 * hdd_process_genie() - process gen ie
4451 * @pAdapter: pointer to adapter
4452 * @bssid: pointer to mac address
4453 * @pEncryptType: pointer to encryption type
4454 * @mcEncryptType: pointer to multicast encryption type
4455 * @pAuthType: pointer to auth type
4456 *
4457 * Return: 0 on success, error number otherwise
4458 */
4459static int32_t hdd_process_genie(hdd_adapter_t *pAdapter,
4460 u8 *bssid,
4461 eCsrEncryptionType *pEncryptType,
4462 eCsrEncryptionType *mcEncryptType,
4463 eCsrAuthType *pAuthType,
4464#ifdef WLAN_FEATURE_11W
4465 uint8_t *pMfpRequired, uint8_t *pMfpCapable,
4466#endif
4467 uint16_t gen_ie_len, uint8_t *gen_ie)
4468{
4469 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304470 QDF_STATUS result;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004471 tDot11fIERSN dot11RSNIE;
4472 tDot11fIEWPA dot11WPAIE;
4473 uint32_t i;
4474 uint8_t *pRsnIe;
4475 uint16_t RSNIeLen;
4476 tPmkidCacheInfo PMKIDCache[4]; /* Local transfer memory */
4477 bool updatePMKCache = false;
4478
4479 /*
4480 * Clear struct of tDot11fIERSN and tDot11fIEWPA specifically
4481 * setting present flag to 0.
4482 */
4483 memset(&dot11WPAIE, 0, sizeof(tDot11fIEWPA));
4484 memset(&dot11RSNIE, 0, sizeof(tDot11fIERSN));
4485
4486 /* Type check */
4487 if (gen_ie[0] == DOT11F_EID_RSN) {
4488 /* Validity checks */
4489 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN) ||
4490 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN)) {
4491 hddLog(LOGE, FL("Invalid DOT11F RSN IE length :%d"),
4492 gen_ie_len);
4493 return -EINVAL;
4494 }
4495 /* Skip past the EID byte and length byte */
4496 pRsnIe = gen_ie + 2;
4497 RSNIeLen = gen_ie_len - 2;
4498 /* Unpack the RSN IE */
4499 dot11f_unpack_ie_rsn((tpAniSirGlobal) halHandle,
4500 pRsnIe, RSNIeLen, &dot11RSNIE);
4501 /* Copy out the encryption and authentication types */
4502 hddLog(LOG1, FL("pairwise cipher suite count: %d"),
4503 dot11RSNIE.pwise_cipher_suite_count);
4504 hddLog(LOG1, FL("authentication suite count: %d"),
4505 dot11RSNIE.akm_suite_count);
4506 /*Here we have followed the apple base code,
4507 but probably I suspect we can do something different */
4508 /* dot11RSNIE.akm_suite_count */
4509 /* Just translate the FIRST one */
4510 *pAuthType =
4511 hdd_translate_rsn_to_csr_auth_type(
4512 dot11RSNIE.akm_suites[0]);
4513 /* dot11RSNIE.pwise_cipher_suite_count */
4514 *pEncryptType =
4515 hdd_translate_rsn_to_csr_encryption_type(
4516 dot11RSNIE.pwise_cipher_suites[0]);
4517 /* dot11RSNIE.gp_cipher_suite_count */
4518 *mcEncryptType =
4519 hdd_translate_rsn_to_csr_encryption_type(
4520 dot11RSNIE.gp_cipher_suite);
4521#ifdef WLAN_FEATURE_11W
4522 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1;
4523 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1;
4524#endif
4525 /* Set the PMKSA ID Cache for this interface */
4526 for (i = 0; i < dot11RSNIE.pmkid_count; i++) {
4527 if (is_zero_ether_addr(bssid)) {
4528 hddLog(LOGE, FL("MAC address is all zeroes"));
4529 break;
4530 }
4531 updatePMKCache = true;
4532 /*
4533 * For right now, I assume setASSOCIATE() has passed
4534 * in the bssid.
4535 */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304536 qdf_mem_copy(PMKIDCache[i].BSSID.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05304537 bssid, QDF_MAC_ADDR_SIZE);
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304538 qdf_mem_copy(PMKIDCache[i].PMKID,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004539 dot11RSNIE.pmkid[i], CSR_RSN_PMKID_SIZE);
4540 }
4541
4542 if (updatePMKCache) {
4543 /*
4544 * Calling csr_roam_set_pmkid_cache to configure the
4545 * PMKIDs into the cache.
4546 */
4547 hddLog(LOG1,
4548 FL("Calling sme_roam_set_pmkid_cache with cache entry %d."),
4549 i);
4550 /* Finally set the PMKSA ID Cache in CSR */
4551 result =
4552 sme_roam_set_pmkid_cache(halHandle,
4553 pAdapter->sessionId,
4554 PMKIDCache,
4555 dot11RSNIE.pmkid_count,
4556 false);
4557 }
4558 } else if (gen_ie[0] == DOT11F_EID_WPA) {
4559 /* Validity checks */
4560 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN) ||
4561 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN)) {
4562 hddLog(LOGE, FL("Invalid DOT11F WPA IE length :%d"),
4563 gen_ie_len);
4564 return -EINVAL;
4565 }
4566 /* Skip past the EID and length byte - and four byte WiFi OUI */
4567 pRsnIe = gen_ie + 2 + 4;
4568 RSNIeLen = gen_ie_len - (2 + 4);
4569 /* Unpack the WPA IE */
4570 dot11f_unpack_ie_wpa((tpAniSirGlobal) halHandle,
4571 pRsnIe, RSNIeLen, &dot11WPAIE);
4572 /* Copy out the encryption and authentication types */
4573 hddLog(LOG1, FL("WPA unicast cipher suite count: %d"),
4574 dot11WPAIE.unicast_cipher_count);
4575 hddLog(LOG1, FL("WPA authentication suite count: %d"),
4576 dot11WPAIE.auth_suite_count);
4577 /* dot11WPAIE.auth_suite_count */
4578 /* Just translate the FIRST one */
4579 *pAuthType =
4580 hdd_translate_wpa_to_csr_auth_type(
4581 dot11WPAIE.auth_suites[0]);
4582 /* dot11WPAIE.unicast_cipher_count */
4583 *pEncryptType =
4584 hdd_translate_wpa_to_csr_encryption_type(
4585 dot11WPAIE.unicast_ciphers[0]);
4586 /* dot11WPAIE.unicast_cipher_count */
4587 *mcEncryptType =
4588 hdd_translate_wpa_to_csr_encryption_type(
4589 dot11WPAIE.multicast_cipher);
4590 } else {
4591 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
4592 return -EINVAL;
4593 }
4594 return 0;
4595}
4596
4597/**
4598 * hdd_set_genie_to_csr() - set genie to csr
4599 * @pAdapter: pointer to adapter
4600 * @RSNAuthType: pointer to auth type
4601 *
4602 * Return: 0 on success, error number otherwise
4603 */
4604int hdd_set_genie_to_csr(hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4605{
4606 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4607 uint32_t status = 0;
4608 eCsrEncryptionType RSNEncryptType;
4609 eCsrEncryptionType mcRSNEncryptType;
4610#ifdef WLAN_FEATURE_11W
4611 uint8_t RSNMfpRequired = 0;
4612 uint8_t RSNMfpCapable = 0;
4613#endif
4614 u8 bssid[ETH_ALEN]; /* MAC address of assoc peer */
4615 /* MAC address of assoc peer */
4616 /* But, this routine is only called when we are NOT associated. */
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304617 qdf_mem_copy(bssid,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004618 pWextState->roamProfile.BSSIDs.bssid,
4619 sizeof(bssid));
4620 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN
4621 || pWextState->WPARSNIE[0] == DOT11F_EID_WPA) {
4622 /* continue */
4623 } else {
4624 return 0;
4625 }
4626 /* The actual processing may eventually be more extensive than this. */
4627 /* Right now, just consume any PMKIDs that are sent in by the app. */
4628 status = hdd_process_genie(pAdapter, bssid,
4629 &RSNEncryptType,
4630 &mcRSNEncryptType, RSNAuthType,
4631#ifdef WLAN_FEATURE_11W
4632 &RSNMfpRequired, &RSNMfpCapable,
4633#endif
4634 pWextState->WPARSNIE[1] + 2,
4635 pWextState->WPARSNIE);
4636 if (status == 0) {
4637 /*
4638 * Now copy over all the security attributes
4639 * you have parsed out.
4640 */
4641 pWextState->roamProfile.EncryptionType.numEntries = 1;
4642 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
4643
4644 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; /* Use the cipher type in the RSN IE */
4645 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
4646 mcRSNEncryptType;
4647
Krunal Sonibe766b02016-03-10 13:00:44 -08004648 if ((QDF_IBSS_MODE == pAdapter->device_mode) &&
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004649 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4650 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType))) {
4651 /*
4652 * For wpa none supplicant sends the WPA IE with unicast
4653 * cipher as eCSR_ENCRYPT_TYPE_NONE ,where as the
4654 * multicast cipher as either AES/TKIP based on group
4655 * cipher configuration mentioned in the
4656 * wpa_supplicant.conf.
4657 */
4658
4659 /* Set the unicast cipher same as multicast cipher */
4660 pWextState->roamProfile.EncryptionType.encryptionType[0]
4661 = mcRSNEncryptType;
4662 }
4663#ifdef WLAN_FEATURE_11W
4664 hddLog(LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4665 RSNMfpRequired, RSNMfpCapable);
4666 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4667 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4668#endif
4669 hddLog(LOG1,
4670 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4671 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
4672 }
4673 return 0;
4674}
4675
4676/**
4677 * hdd_set_csr_auth_type() - set csr auth type
4678 * @pAdapter: pointer to adapter
4679 * @RSNAuthType: auth type
4680 *
4681 * Return: 0 on success, error number otherwise
4682 */
4683int hdd_set_csr_auth_type(hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4684{
4685 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4686 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
4687 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004688
4689 pRoamProfile->AuthType.numEntries = 1;
4690 hddLog(LOG1, FL("pHddStaCtx->conn_info.authType = %d"),
4691 pHddStaCtx->conn_info.authType);
4692
4693 switch (pHddStaCtx->conn_info.authType) {
4694 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4695#ifdef FEATURE_WLAN_ESE
4696 case eCSR_AUTH_TYPE_CCKM_WPA:
4697 case eCSR_AUTH_TYPE_CCKM_RSN:
4698#endif
4699 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4700
4701 pRoamProfile->AuthType.authType[0] =
4702 eCSR_AUTH_TYPE_OPEN_SYSTEM;
4703 } else if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
4704
4705#ifdef FEATURE_WLAN_ESE
4706 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4707 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4708 == IW_AUTH_KEY_MGMT_802_1X)) {
4709 hddLog(LOG1,
4710 FL("set authType to CCKM WPA. AKM also 802.1X."));
4711 pRoamProfile->AuthType.authType[0] =
4712 eCSR_AUTH_TYPE_CCKM_WPA;
4713 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) {
4714 hddLog(LOG1,
4715 FL("Last chance to set authType to CCKM WPA."));
4716 pRoamProfile->AuthType.authType[0] =
4717 eCSR_AUTH_TYPE_CCKM_WPA;
4718 } else
4719#endif
4720 if ((pWextState->
4721 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4722 == IW_AUTH_KEY_MGMT_802_1X) {
4723 pRoamProfile->AuthType.authType[0] =
4724 eCSR_AUTH_TYPE_WPA;
4725 } else
4726 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4727 == IW_AUTH_KEY_MGMT_PSK) {
4728 pRoamProfile->AuthType.authType[0] =
4729 eCSR_AUTH_TYPE_WPA_PSK;
4730 } else {
4731 pRoamProfile->AuthType.authType[0] =
4732 eCSR_AUTH_TYPE_WPA_NONE;
4733 }
4734 }
4735 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
4736#ifdef FEATURE_WLAN_ESE
4737 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4738 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4739 == IW_AUTH_KEY_MGMT_802_1X)) {
4740 hddLog(LOG1,
4741 FL("set authType to CCKM RSN. AKM also 802.1X."));
4742 pRoamProfile->AuthType.authType[0] =
4743 eCSR_AUTH_TYPE_CCKM_RSN;
4744 } else if (RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) {
4745 hddLog(LOG1,
4746 FL("Last chance to set authType to CCKM RSN."));
4747 pRoamProfile->AuthType.authType[0] =
4748 eCSR_AUTH_TYPE_CCKM_RSN;
4749 } else
4750#endif
4751
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004752 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4753 ((pWextState->
4754 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4755 == IW_AUTH_KEY_MGMT_802_1X)) {
4756 pRoamProfile->AuthType.authType[0] =
4757 eCSR_AUTH_TYPE_FT_RSN;
4758 } else if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK)
4759 &&
4760 ((pWextState->
4761 authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4762 == IW_AUTH_KEY_MGMT_PSK)) {
4763 pRoamProfile->AuthType.authType[0] =
4764 eCSR_AUTH_TYPE_FT_RSN_PSK;
4765 } else
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004766
4767#ifdef WLAN_FEATURE_11W
4768 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4769 pRoamProfile->AuthType.authType[0] =
4770 eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4771 } else if (RSNAuthType ==
4772 eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4773 pRoamProfile->AuthType.authType[0] =
4774 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4775 } else
4776#endif
4777
4778 if ((pWextState->
4779 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4780 == IW_AUTH_KEY_MGMT_802_1X) {
4781 pRoamProfile->AuthType.authType[0] =
4782 eCSR_AUTH_TYPE_RSN;
4783 } else
4784 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4785 == IW_AUTH_KEY_MGMT_PSK) {
4786 pRoamProfile->AuthType.authType[0] =
4787 eCSR_AUTH_TYPE_RSN_PSK;
4788 } else {
4789 pRoamProfile->AuthType.authType[0] =
4790 eCSR_AUTH_TYPE_UNKNOWN;
4791 }
4792 }
4793 break;
4794
4795 case eCSR_AUTH_TYPE_SHARED_KEY:
4796
4797 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
4798 break;
4799 default:
4800
4801#ifdef FEATURE_WLAN_ESE
4802 hddLog(LOG1, FL("In default, unknown auth type."));
4803#endif /* FEATURE_WLAN_ESE */
4804 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4805 break;
4806 }
4807
4808 hddLog(LOG1, FL("Set roam Authtype to %d"),
4809 pWextState->roamProfile.AuthType.authType[0]);
4810
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004811 return 0;
4812}
4813
4814/**
4815 * __iw_set_essid() - This function sets the ssid received from wpa_supplicant
4816 * to the CSR roam profile.
4817 *
4818 * @dev: Pointer to the net device.
4819 * @info: Pointer to the iw_request_info.
4820 * @wrqu: Pointer to the iwreq_data.
4821 * @extra: Pointer to the data.
4822 *
4823 * Return: 0 for success, error number on failure
4824 */
4825static int __iw_set_essid(struct net_device *dev,
4826 struct iw_request_info *info,
4827 union iwreq_data *wrqu, char *extra)
4828{
4829 unsigned long rc;
4830 uint32_t status = 0;
4831 hdd_wext_state_t *pWextState;
4832 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4833 hdd_context_t *hdd_ctx;
4834 uint32_t roamId;
4835 tCsrRoamProfile *pRoamProfile;
4836 eMib_dot11DesiredBssType connectedBssType;
4837 eCsrAuthType RSNAuthType;
4838 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4839 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4840 int ret;
4841
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08004842 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004843
4844 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4845 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05304846 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004847 return ret;
4848
Krunal Sonibe766b02016-03-10 13:00:44 -08004849 if (pAdapter->device_mode != QDF_STA_MODE &&
4850 pAdapter->device_mode != QDF_P2P_CLIENT_MODE) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004851 hddLog(LOGW, FL("device mode %s(%d) is not allowed"),
4852 hdd_device_mode_to_string(pAdapter->device_mode),
4853 pAdapter->device_mode);
4854 return -EINVAL;
4855 }
4856
4857 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4858
4859 if (pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4860 hddLog(LOG2, FL("Counter measure is in progress"));
4861 return -EBUSY;
4862 }
4863 if (SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length)
4864 return -EINVAL;
4865
4866 pRoamProfile = &pWextState->roamProfile;
4867 if (hdd_conn_get_connected_bss_type(pHddStaCtx, &connectedBssType) ||
4868 (eMib_dot11DesiredBssType_independent ==
4869 pHddStaCtx->conn_info.connDot11DesiredBssType)) {
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304870 QDF_STATUS qdf_status;
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004871
4872 /* Need to issue a disconnect to CSR. */
4873 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304874 qdf_status = sme_roam_disconnect(hHal, pAdapter->sessionId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004875 eCSR_DISCONNECT_REASON_UNSPECIFIED);
4876
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304877 if (QDF_STATUS_SUCCESS == qdf_status) {
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004878 rc = wait_for_completion_timeout(&pAdapter->
4879 disconnect_comp_var,
4880 msecs_to_jiffies
4881 (WLAN_WAIT_TIME_DISCONNECT));
4882 if (!rc)
4883 hddLog(LOGE, FL("Disconnect event timed out"));
4884 }
4885 }
4886
4887 /*
4888 * when cfg80211 defined, wpa_supplicant wext driver uses
4889 * zero-length, null-string ssid for force disconnection.
4890 * after disconnection (if previously connected) and cleaning ssid,
4891 * driver MUST return success.
4892 */
4893 if (0 == wrqu->essid.length)
4894 return 0;
4895
4896 status = hdd_wmm_get_uapsd_mask(pAdapter,
4897 &pWextState->roamProfile.uapsd_mask);
Anurag Chouhanfb54ab02016-02-18 18:00:46 +05304898 if (QDF_STATUS_SUCCESS != status)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004899 pWextState->roamProfile.uapsd_mask = 0;
4900
4901 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
4902
4903 pWextState->roamProfile.SSIDs.SSIDList->SSID.length =
4904 wrqu->essid.length;
4905
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304906 qdf_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004907 sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05304908 qdf_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08004909 ssId), extra, wrqu->essid.length);
4910 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion
4911 || IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion) {
4912
4913 /* set gen ie */
4914 hdd_set_genie_to_csr(pAdapter, &RSNAuthType);
4915
4916 /* set auth */
4917 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4918 }
4919#ifdef FEATURE_WLAN_WAPI
4920 hddLog(LOG1, FL("Setting WAPI AUTH Type and Encryption Mode values"));
4921 if (pAdapter->wapi_info.nWapiMode) {
4922 switch (pAdapter->wapi_info.wapiAuthMode) {
4923 case WAPI_AUTH_MODE_PSK:
4924 {
4925 hddLog(LOG1, FL("WAPI AUTH TYPE: PSK: %d"),
4926 pAdapter->wapi_info.wapiAuthMode);
4927 pRoamProfile->AuthType.numEntries = 1;
4928 pRoamProfile->AuthType.authType[0] =
4929 eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4930 break;
4931 }
4932 case WAPI_AUTH_MODE_CERT:
4933 {
4934 hddLog(LOG1, FL("WAPI AUTH TYPE: CERT: %d"),
4935 pAdapter->wapi_info.wapiAuthMode);
4936 pRoamProfile->AuthType.numEntries = 1;
4937 pRoamProfile->AuthType.authType[0] =
4938 eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4939 break;
4940 }
4941 } /* End of switch */
4942 if (pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4943 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT) {
4944 hddLog(LOG1, FL("WAPI PAIRWISE/GROUP ENCRYPTION: WPI"));
4945 pRoamProfile->EncryptionType.numEntries = 1;
4946 pRoamProfile->EncryptionType.encryptionType[0] =
4947 eCSR_ENCRYPT_TYPE_WPI;
4948 pRoamProfile->mcEncryptionType.numEntries = 1;
4949 pRoamProfile->mcEncryptionType.encryptionType[0] =
4950 eCSR_ENCRYPT_TYPE_WPI;
4951 }
4952 }
4953#endif /* FEATURE_WLAN_WAPI */
4954 /* if previous genIE is not NULL, update AssocIE */
4955 if (0 != pWextState->genIE.length) {
4956 memset(&pWextState->assocAddIE, 0,
4957 sizeof(pWextState->assocAddIE));
4958 memcpy(pWextState->assocAddIE.addIEdata,
4959 pWextState->genIE.addIEdata, pWextState->genIE.length);
4960 pWextState->assocAddIE.length = pWextState->genIE.length;
4961 pWextState->roamProfile.pAddIEAssoc =
4962 pWextState->assocAddIE.addIEdata;
4963 pWextState->roamProfile.nAddIEAssocLength =
4964 pWextState->assocAddIE.length;
4965
4966 /* clear previous genIE after use it */
4967 memset(&pWextState->genIE, 0, sizeof(pWextState->genIE));
4968 }
4969
4970 /*
4971 * Assumes it is not WPS Association by default, except when
4972 * pAddIEAssoc has WPS IE.
4973 */
4974 pWextState->roamProfile.bWPSAssociation = false;
4975
4976 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4977 pWextState->roamProfile.
4978 nAddIEAssocLength))
4979 pWextState->roamProfile.bWPSAssociation = true;
4980
4981 /* Disable auto BMPS entry by PMC until DHCP is done */
4982 sme_set_dhcp_till_power_active_flag(WLAN_HDD_GET_HAL_CTX(pAdapter),
4983 true);
4984
4985 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
4986
4987 if (eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType) {
4988 hdd_select_cbmode(pAdapter,
4989 (WLAN_HDD_GET_CTX(pAdapter))->config->
4990 AdHocChannel5G);
4991 }
Agrawal Ashish6b015762016-05-05 11:22:18 +05304992 /*
4993 * Change conn_state to connecting before sme_roam_connect(),
4994 * because sme_roam_connect() has a direct path to call
4995 * hdd_sme_roam_callback(), which will change the conn_state
4996 * If direct path, conn_state will be accordingly changed to
4997 * NotConnected or Associated by either
4998 * hdd_association_completion_handler() or hdd_dis_connect_handler()
4999 * in sme_RoamCallback()if sme_RomConnect is to be queued,
5000 * Connecting state will remain until it is completed.
5001 *
5002 * If connection state is not changed,
5003 * connection state will remain in eConnectionState_NotConnected state.
5004 * In hdd_association_completion_handler, "hddDisconInProgress" is
5005 * set to true if conn state is eConnectionState_NotConnected.
5006 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5007 * informed of connect result indication which is an issue.
5008 */
5009 if (QDF_STA_MODE == pAdapter->device_mode ||
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305010 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)
Agrawal Ashish6b015762016-05-05 11:22:18 +05305011 hdd_conn_set_connection_state(pAdapter,
5012 eConnectionState_Connecting);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305013
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005014 status = sme_roam_connect(hHal, pAdapter->sessionId,
5015 &(pWextState->roamProfile), &roamId);
Agrawal Ashish6b015762016-05-05 11:22:18 +05305016 if ((QDF_STATUS_SUCCESS != status) &&
5017 (QDF_STA_MODE == pAdapter->device_mode ||
5018 QDF_P2P_CLIENT_MODE == pAdapter->device_mode)) {
5019 hdd_err("sme_roam_connect (session %d) failed with status %d. -> NotConnected",
5020 pAdapter->sessionId, status);
5021 /* change back to NotAssociated */
5022 hdd_conn_set_connection_state(pAdapter,
5023 eConnectionState_NotConnected);
5024 }
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005025 pRoamProfile->ChannelInfo.ChannelList = NULL;
5026 pRoamProfile->ChannelInfo.numOfChannels = 0;
5027
5028 EXIT();
5029 return status;
5030}
5031
5032/**
5033 * iw_set_essid() - set essid handler function
5034 * @dev: Pointer to the net device.
5035 * @info: Pointer to the iw_request_info.
5036 * @wrqu: Pointer to the iwreq_data.
5037 * @extra: Pointer to the data.
5038 *
5039 * Return: 0 for success, error number on failure
5040 */
5041int iw_set_essid(struct net_device *dev,
5042 struct iw_request_info *info,
5043 union iwreq_data *wrqu, char *extra)
5044{
5045 int ret;
5046
5047 cds_ssr_protect(__func__);
5048 ret = __iw_set_essid(dev, info, wrqu, extra);
5049 cds_ssr_unprotect(__func__);
5050
5051 return ret;
5052}
5053
5054/**
5055 * __iw_get_essid() - This function returns the essid to the wpa_supplicant
5056 * @dev: pointer to the net device
5057 * @info: pointer to the iw request info
5058 * @dwrq: pointer to iw_point
5059 * @extra: pointer to the data
5060 *
5061 * Return: 0 on success, error number otherwise
5062 */
5063static int __iw_get_essid(struct net_device *dev,
5064 struct iw_request_info *info,
5065 struct iw_point *dwrq, char *extra)
5066{
5067 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5068 hdd_context_t *hdd_ctx;
5069 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5070 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5071 int ret;
5072
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005073 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005074
5075 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5076 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305077 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005078 return ret;
5079
5080 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5081 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5082 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected
5083 || pHddStaCtx->conn_info.connState ==
5084 eConnectionState_IbssDisconnected)
5085 && wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0)) {
5086 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5087 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId,
5088 dwrq->length);
5089 dwrq->flags = 1;
5090 } else {
5091 memset(extra, 0, dwrq->length);
5092 dwrq->length = 0;
5093 dwrq->flags = 0;
5094 }
5095 EXIT();
5096 return 0;
5097}
5098
5099/**
5100 * iw_get_essid() - get essid handler function
5101 * @dev: Pointer to the net device.
5102 * @info: Pointer to the iw_request_info.
5103 * @wrqu: Pointer to the iwreq_data.
5104 * @extra: Pointer to the data.
5105 *
5106 * Return: 0 for success, error number on failure
5107 */
5108int iw_get_essid(struct net_device *dev,
5109 struct iw_request_info *info,
5110 struct iw_point *wrqu, char *extra)
5111{
5112 int ret;
5113
5114 cds_ssr_protect(__func__);
5115 ret = __iw_get_essid(dev, info, wrqu, extra);
5116 cds_ssr_unprotect(__func__);
5117
5118 return ret;
5119}
5120
5121/**
5122 * __iw_set_auth() -
5123 * This function sets the auth type received from the wpa_supplicant
5124 * @dev: pointer to the net device
5125 * @info: pointer to the iw request info
5126 * @wrqu: pointer to iwreq_data
5127 * @extra: pointer to the data
5128 *
5129 * Return: 0 on success, error number otherwise
5130 */
5131static int __iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5132 union iwreq_data *wrqu, char *extra)
5133{
5134 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5135 hdd_context_t *hdd_ctx;
5136 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5137 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5138 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5139 eCsrEncryptionType mcEncryptionType;
5140 eCsrEncryptionType ucEncryptionType;
5141 int ret;
5142
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005143 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005144
5145 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5146 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305147 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005148 return ret;
5149
5150 switch (wrqu->param.flags & IW_AUTH_INDEX) {
5151 case IW_AUTH_WPA_VERSION:
5152 pWextState->wpaVersion = wrqu->param.value;
5153 break;
5154
5155 case IW_AUTH_CIPHER_PAIRWISE:
5156 {
5157 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5158 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5159 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5160 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5161 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5162 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5163 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5164 if ((IW_AUTH_KEY_MGMT_802_1X
5165 ==
5166 (pWextState->
5167 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5168 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5169 pHddStaCtx->conn_info.authType))
5170 /*Dynamic WEP key */
5171 ucEncryptionType =
5172 eCSR_ENCRYPT_TYPE_WEP40;
5173 else
5174 /*Static WEP key */
5175 ucEncryptionType =
5176 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5177 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5178 if ((IW_AUTH_KEY_MGMT_802_1X
5179 ==
5180 (pWextState->
5181 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5182 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5183 pHddStaCtx->conn_info.authType))
5184 /*Dynamic WEP key */
5185 ucEncryptionType =
5186 eCSR_ENCRYPT_TYPE_WEP104;
5187 else
5188 /*Static WEP key */
5189 ucEncryptionType =
5190 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5191 } else {
5192 hddLog(LOGW, FL("value %d UNKNOWN IW_AUTH_CIPHER"),
5193 wrqu->param.value);
5194 return -EINVAL;
5195 }
5196
5197 pRoamProfile->EncryptionType.numEntries = 1;
5198 pRoamProfile->EncryptionType.encryptionType[0] =
5199 ucEncryptionType;
5200 }
5201 break;
5202 case IW_AUTH_CIPHER_GROUP:
5203 {
5204 if (wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5205 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5206 } else if (wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5207 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5208 } else if (wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5209 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5210 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
5211 if ((IW_AUTH_KEY_MGMT_802_1X
5212 ==
5213 (pWextState->
5214 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5215 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5216 pHddStaCtx->conn_info.authType))
5217 mcEncryptionType =
5218 eCSR_ENCRYPT_TYPE_WEP40;
5219 else
5220 mcEncryptionType =
5221 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5222 } else if (wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
5223 /* Dynamic WEP keys won't work with shared keys */
5224 if ((IW_AUTH_KEY_MGMT_802_1X
5225 ==
5226 (pWextState->
5227 authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
5228 && (eCSR_AUTH_TYPE_OPEN_SYSTEM ==
5229 pHddStaCtx->conn_info.authType)) {
5230 mcEncryptionType =
5231 eCSR_ENCRYPT_TYPE_WEP104;
5232 } else {
5233 mcEncryptionType =
5234 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5235 }
5236 } else {
5237 hddLog(LOGW, FL("value %d UNKNOWN IW_AUTH_CIPHER"),
5238 wrqu->param.value);
5239 return -EINVAL;
5240 }
5241
5242 pRoamProfile->mcEncryptionType.numEntries = 1;
5243 pRoamProfile->mcEncryptionType.encryptionType[0] =
5244 mcEncryptionType;
5245 }
5246 break;
5247
5248 case IW_AUTH_80211_AUTH_ALG:
5249 {
5250 /* Save the auth algo here and set auth type to SME Roam profile
5251 in the iw_set_ap_address */
5252 if (wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
5253 pHddStaCtx->conn_info.authType =
5254 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5255
5256 else if (wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5257 pHddStaCtx->conn_info.authType =
5258 eCSR_AUTH_TYPE_SHARED_KEY;
5259
5260 else if (wrqu->param.value & IW_AUTH_ALG_LEAP)
5261 /*Not supported */
5262 pHddStaCtx->conn_info.authType =
5263 eCSR_AUTH_TYPE_OPEN_SYSTEM;
5264 pWextState->roamProfile.AuthType.authType[0] =
5265 pHddStaCtx->conn_info.authType;
5266 }
5267 break;
5268
5269 case IW_AUTH_KEY_MGMT:
5270 {
5271#ifdef FEATURE_WLAN_ESE
5272#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5273 /*Check for CCKM AKM type */
5274 if (wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
5275 hddLog(LOG1, FL("CCKM AKM Set %d"), wrqu->param.value);
5276 /* Set the CCKM bit in authKeyMgmt */
5277 /*
5278 * Right now, this breaks all ref to authKeyMgmt because
5279 * our code doesn't realize it is a "bitfield"
5280 */
5281 pWextState->authKeyMgmt |=
5282 IW_AUTH_KEY_MGMT_CCKM;
5283 /* Set the key management to 802.1X */
5284 /* pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X; */
5285 pWextState->isESEConnection = true;
5286 /*
5287 * This is test code. I need to actually KNOW whether
5288 * this is an RSN Assoc or WPA.
5289 */
5290 pWextState->collectedAuthType =
5291 eCSR_AUTH_TYPE_CCKM_RSN;
5292 } else if (wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5293 /* Save the key management */
5294 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5295 pWextState->collectedAuthType =
5296 eCSR_AUTH_TYPE_RSN;
5297 } else
5298 if (!(wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5299 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE;
5300 /* Save the key management anyway */
5301 pWextState->authKeyMgmt = wrqu->param.value;
5302 } else { /* It must be IW_AUTH_KEY_MGMT_802_1X */
5303 /* Save the key management */
5304 pWextState->authKeyMgmt |=
5305 IW_AUTH_KEY_MGMT_802_1X;
5306 pWextState->collectedAuthType =
5307 eCSR_AUTH_TYPE_RSN;
5308 }
5309#else
5310 /* Save the key management */
5311 pWextState->authKeyMgmt = wrqu->param.value;
5312#endif /* FEATURE_WLAN_ESE */
5313 }
5314 break;
5315
5316 case IW_AUTH_TKIP_COUNTERMEASURES:
5317 {
5318 if (wrqu->param.value) {
5319 hddLog(LOG2,
5320 "Counter Measure started %d",
5321 wrqu->param.value);
5322 pWextState->mTKIPCounterMeasures =
5323 TKIP_COUNTER_MEASURE_STARTED;
5324 } else {
5325 hddLog(LOG2,
5326 "Counter Measure stopped=%d",
5327 wrqu->param.value);
5328 pWextState->mTKIPCounterMeasures =
5329 TKIP_COUNTER_MEASURE_STOPED;
5330 }
5331 }
5332 break;
5333 case IW_AUTH_DROP_UNENCRYPTED:
5334 case IW_AUTH_WPA_ENABLED:
5335 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5336 case IW_AUTH_ROAMING_CONTROL:
5337 case IW_AUTH_PRIVACY_INVOKED:
5338
5339 default:
5340
5341 hddLog(LOGW, FL("called with unsupported auth type %d"),
5342 wrqu->param.flags & IW_AUTH_INDEX);
5343 break;
5344 }
5345
5346 EXIT();
5347 return 0;
5348}
5349
5350/**
5351 * iw_set_auth() - set auth callback function
5352 * @dev: Pointer to the net device.
5353 * @info: Pointer to the iw_request_info.
5354 * @wrqu: Pointer to the iwreq_data.
5355 * @extra: Pointer to the data.
5356 *
5357 * Return: 0 for success, error number on failure.
5358 */
5359int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5360 union iwreq_data *wrqu, char *extra)
5361{
5362 int ret;
5363
5364 cds_ssr_protect(__func__);
5365 ret = __iw_set_auth(dev, info, wrqu, extra);
5366 cds_ssr_unprotect(__func__);
5367
5368 return ret;
5369}
5370
5371/**
5372 * __iw_get_auth() -
5373 * This function returns the auth type to the wpa_supplicant
5374 * @dev: pointer to the net device
5375 * @info: pointer to the iw request info
5376 * @wrqu: pointer to iwreq_data
5377 * @extra: pointer to the data
5378 *
5379 * Return: 0 on success, error number otherwise
5380 */
5381static int __iw_get_auth(struct net_device *dev, struct iw_request_info *info,
5382 union iwreq_data *wrqu, char *extra)
5383{
5384 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5385 hdd_context_t *hdd_ctx;
5386 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5387 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
5388 int ret;
5389
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005390 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005391
5392 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
5393 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305394 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005395 return ret;
5396
5397 switch (pRoamProfile->negotiatedAuthType) {
5398 case eCSR_AUTH_TYPE_WPA_NONE:
5399 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5400 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5401 break;
5402 case eCSR_AUTH_TYPE_WPA:
5403 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5404 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5405 break;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005406
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005407 case eCSR_AUTH_TYPE_FT_RSN:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005408 case eCSR_AUTH_TYPE_RSN:
5409 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5410 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5411 break;
5412 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5413 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5414 break;
5415 case eCSR_AUTH_TYPE_SHARED_KEY:
5416 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5417 break;
5418 case eCSR_AUTH_TYPE_UNKNOWN:
5419 hddLog(LOG1, FL("called with unknown auth type"));
5420 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5421 break;
5422 case eCSR_AUTH_TYPE_AUTOSWITCH:
5423 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5424 break;
5425 case eCSR_AUTH_TYPE_WPA_PSK:
5426 hddLog(LOG1, FL("called with WPA PSK auth type"));
5427 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5428 return -EIO;
Deepak Dhamdhere9f09e752016-01-09 23:17:25 -08005429
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005430 case eCSR_AUTH_TYPE_FT_RSN_PSK:
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005431 case eCSR_AUTH_TYPE_RSN_PSK:
5432#ifdef WLAN_FEATURE_11W
5433 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
5434 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
5435#endif
5436 hddLog(LOG1, FL("called with RSN PSK auth type"));
5437 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5438 return -EIO;
5439 default:
5440 hddLog(LOGE, FL("called with unknown auth type"));
5441 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5442 return -EIO;
5443 }
5444 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE)) {
5445 switch (pRoamProfile->negotiatedUCEncryptionType) {
5446 case eCSR_ENCRYPT_TYPE_NONE:
5447 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5448 break;
5449 case eCSR_ENCRYPT_TYPE_WEP40:
5450 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5451 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5452 break;
5453 case eCSR_ENCRYPT_TYPE_TKIP:
5454 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5455 break;
5456 case eCSR_ENCRYPT_TYPE_WEP104:
5457 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5458 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5459 break;
5460 case eCSR_ENCRYPT_TYPE_AES:
5461 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5462 break;
5463 default:
5464 hddLog(LOG1, FL("called with unknown auth type %d"),
5465 pRoamProfile->negotiatedUCEncryptionType);
5466 return -EIO;
5467 }
5468 }
5469
5470 if (((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP)) {
5471 switch (pRoamProfile->negotiatedMCEncryptionType) {
5472 case eCSR_ENCRYPT_TYPE_NONE:
5473 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5474 break;
5475 case eCSR_ENCRYPT_TYPE_WEP40:
5476 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5477 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5478 break;
5479 case eCSR_ENCRYPT_TYPE_TKIP:
5480 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5481 break;
5482 case eCSR_ENCRYPT_TYPE_WEP104:
5483 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5484 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5485 break;
5486 case eCSR_ENCRYPT_TYPE_AES:
5487 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5488 break;
5489 default:
5490 hddLog(LOG1, FL("called with unknown auth type %d"),
5491 pRoamProfile->negotiatedMCEncryptionType);
5492 return -EIO;
5493 }
5494 }
5495
5496 hddLog(LOG1, FL("called with auth type %d"),
5497 pRoamProfile->AuthType.authType[0]);
5498 EXIT();
5499 return 0;
5500}
5501
5502/**
5503 * iw_get_auth() - get auth callback function
5504 * @dev: Pointer to the net device.
5505 * @info: Pointer to the iw_request_info.
5506 * @wrqu: Pointer to the iwreq_data.
5507 * @extra: Pointer to the data.
5508 *
5509 * Return: 0 for success, error number on failure.
5510 */
5511int iw_get_auth(struct net_device *dev, struct iw_request_info *info,
5512 union iwreq_data *wrqu, char *extra)
5513{
5514 int ret;
5515
5516 cds_ssr_protect(__func__);
5517 ret = __iw_get_auth(dev, info, wrqu, extra);
5518 cds_ssr_unprotect(__func__);
5519
5520 return ret;
5521}
5522
5523/**
5524 * __iw_set_ap_address() - set ap address
5525 * @dev: pointer to the net device
5526 * @info: pointer to the iw request info
5527 * @wrqu: pointer to iwreq_data
5528 * @extra: pointer to the data
5529 *
5530 * This function updates the HDD global station context connection info
5531 * BSSID with the MAC address received from the wpa_supplicant.
5532 *
5533 * Return: 0 on success, error number otherwise
5534 */
5535static int __iw_set_ap_address(struct net_device *dev,
5536 struct iw_request_info *info,
5537 union iwreq_data *wrqu, char *extra)
5538{
5539
5540 hdd_adapter_t *adapter;
5541 hdd_context_t *hdd_ctx;
5542 hdd_station_ctx_t *pHddStaCtx =
5543 WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
5544 uint8_t *pMacAddress = NULL;
5545 int ret;
5546
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005547 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005548
5549 adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5550
5551 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5552 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305553 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005554 return ret;
5555
5556 pMacAddress = (uint8_t *) wrqu->ap_addr.sa_data;
5557 hddLog(LOG1, FL(" " MAC_ADDRESS_STR), MAC_ADDR_ARRAY(pMacAddress));
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305558 qdf_mem_copy(pHddStaCtx->conn_info.bssId.bytes, pMacAddress,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305559 sizeof(struct qdf_mac_addr));
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005560 EXIT();
5561
5562 return 0;
5563}
5564
5565/**
5566 * iw_set_ap_address() - set ap addresses callback function
5567 * @dev: Pointer to the net device.
5568 * @info: Pointer to the iw_request_info.
5569 * @wrqu: Pointer to the iwreq_data.
5570 * @extra: Pointer to the data.
5571 *
5572 * Return: 0 for success, error number on failure.
5573 */
5574int iw_set_ap_address(struct net_device *dev, struct iw_request_info *info,
5575 union iwreq_data *wrqu, char *extra)
5576{
5577 int ret;
5578
5579 cds_ssr_protect(__func__);
5580 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5581 cds_ssr_unprotect(__func__);
5582
5583 return ret;
5584}
5585
5586/**
5587 * __iw_get_ap_address() - get ap address
5588 * @dev: pointer to the net device
5589 * @info: pointer to the iw request info
5590 * @wrqu: pointer to iwreq_data
5591 * @extra: pointer to the data
5592 *
5593 * This function returns currently associated BSSID.
5594 *
5595 * Return: 0 on success, error number otherwise
5596 */
5597static int __iw_get_ap_address(struct net_device *dev,
5598 struct iw_request_info *info,
5599 union iwreq_data *wrqu, char *extra)
5600{
5601 hdd_adapter_t *adapter = WLAN_HDD_GET_PRIV_PTR(dev);
5602 hdd_context_t *hdd_ctx;
5603 hdd_station_ctx_t *pHddStaCtx =
5604 WLAN_HDD_GET_STATION_CTX_PTR(adapter);
5605 int ret;
5606
Jeff Johnsonb25dcb12016-02-11 17:46:42 -08005607 ENTER_DEV(dev);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005608
5609 hdd_ctx = WLAN_HDD_GET_CTX(adapter);
5610 ret = wlan_hdd_validate_context(hdd_ctx);
Abhishek Singh23edd1c2016-05-05 11:56:06 +05305611 if (ret)
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005612 return ret;
5613
5614 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated ||
5615 eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) {
Anurag Chouhan600c3a02016-03-01 10:33:54 +05305616 qdf_mem_copy(wrqu->ap_addr.sa_data,
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005617 pHddStaCtx->conn_info.bssId.bytes,
Anurag Chouhan6d760662016-02-20 16:05:43 +05305618 QDF_MAC_ADDR_SIZE);
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08005619 } else {
5620 memset(wrqu->ap_addr.sa_data, 0, sizeof(wrqu->ap_addr.sa_data));
5621 }
5622 EXIT();
5623 return 0;
5624}
5625
5626/**
5627 * iw_get_ap_address() - get ap addresses callback function
5628 * @dev: Pointer to the net device.
5629 * @info: Pointer to the iw_request_info.
5630 * @wrqu: Pointer to the iwreq_data.
5631 * @extra: Pointer to the data.
5632 *
5633 * Return: 0 for success, error number on failure.
5634 */
5635int iw_get_ap_address(struct net_device *dev, struct iw_request_info *info,
5636 union iwreq_data *wrqu, char *extra)
5637{
5638 int ret;
5639
5640 cds_ssr_protect(__func__);
5641 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5642 cds_ssr_unprotect(__func__);
5643
5644 return ret;
5645}