blob: 73db6add7421f0e9b6a7bc95c095dcb10c103f68 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
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*/
Jeff Johnson295189b2012-06-20 16:38:30 -070021
22/**========================================================================
23
24 \file wlan_hdd_cfg80211.c
25
26 \brief WLAN Host Device Driver implementation
27
Gopichand Nakkala747461f2013-04-24 19:24:45 +053028 Copyright 2008 (c) Qualcomm Technologies, Inc. All Rights Reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070029
Gopichand Nakkala747461f2013-04-24 19:24:45 +053030 Qualcomm Technologies Confidential and Proprietary.
Jeff Johnson295189b2012-06-20 16:38:30 -070031
32 ========================================================================*/
33
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070034/**=========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070035
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070036 EDIT HISTORY FOR FILE
Jeff Johnson295189b2012-06-20 16:38:30 -070037
38
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070039 This section contains comments describing changes made to the module.
40 Notice that changes are listed in reverse chronological order.
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070043 $Header:$ $DateTime: $ $Author: $
Jeff Johnson295189b2012-06-20 16:38:30 -070044
45
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070046 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070047 -------- --- --------------------------------------------------------
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070048 21/12/09 Ashwani Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070049
50 07/06/10 Kumar Deepak Implemented cfg80211 callbacks for ANDROID
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -070051 Ganesh K
Jeff Johnson295189b2012-06-20 16:38:30 -070052 ==========================================================================*/
53
Jeff Johnson295189b2012-06-20 16:38:30 -070054
55#include <linux/version.h>
56#include <linux/module.h>
57#include <linux/kernel.h>
58#include <linux/init.h>
59#include <linux/wireless.h>
60#include <wlan_hdd_includes.h>
61#include <net/arp.h>
62#include <net/cfg80211.h>
63#include <linux/wireless.h>
64#include <wlan_hdd_wowl.h>
65#include <aniGlobal.h>
66#include "ccmApi.h"
67#include "sirParams.h"
68#include "dot11f.h"
69#include "wlan_hdd_assoc.h"
70#include "wlan_hdd_wext.h"
71#include "sme_Api.h"
72#include "wlan_hdd_p2p.h"
73#include "wlan_hdd_cfg80211.h"
74#include "wlan_hdd_hostapd.h"
75#include "sapInternal.h"
76#include "wlan_hdd_softap_tx_rx.h"
77#include "wlan_hdd_main.h"
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +053078#include "wlan_hdd_assoc.h"
Gopichand Nakkala20c4c042013-04-19 22:08:55 +053079#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070080#ifdef WLAN_BTAMP_FEATURE
81#include "bap_hdd_misc.h"
82#endif
83#include <qc_sap_ioctl.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080084#ifdef FEATURE_WLAN_TDLS
85#include "wlan_hdd_tdls.h"
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +053086#include "wlan_hdd_wmm.h"
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +053087#include "wlan_qct_wda.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080088#endif
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +053089#include "wlan_nv.h"
Leo Chang6fe1f922013-06-07 19:21:24 -070090#include "wlan_hdd_dev_pwr.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070091
92#define g_mode_rates_size (12)
93#define a_mode_rates_size (8)
94#define FREQ_BASE_80211G (2407)
95#define FREQ_BAND_DIFF_80211G (5)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070096#define MAX_SCAN_SSID 9
Jeff Johnson295189b2012-06-20 16:38:30 -070097#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
98 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
99
100#define HDD2GHZCHAN(freq, chan, flag) { \
101 .band = IEEE80211_BAND_2GHZ, \
102 .center_freq = (freq), \
103 .hw_value = (chan),\
104 .flags = (flag), \
105 .max_antenna_gain = 0 ,\
106 .max_power = 30, \
107}
108
109#define HDD5GHZCHAN(freq, chan, flag) { \
110 .band = IEEE80211_BAND_5GHZ, \
111 .center_freq = (freq), \
112 .hw_value = (chan),\
113 .flags = (flag), \
114 .max_antenna_gain = 0 ,\
115 .max_power = 30, \
116}
117
118#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
119{\
120 .bitrate = rate, \
121 .hw_value = rate_id, \
122 .flags = flag, \
123}
124
Lee Hoonkic1262f22013-01-24 21:59:00 -0800125#ifndef WLAN_FEATURE_TDLS_DEBUG
126#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
127#else
128#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
129#endif
130
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530131#ifdef WLAN_FEATURE_VOWIFI_11R
132#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
133#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
134#endif
135
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530136static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700137{
138 WLAN_CIPHER_SUITE_WEP40,
139 WLAN_CIPHER_SUITE_WEP104,
140 WLAN_CIPHER_SUITE_TKIP,
141#ifdef FEATURE_WLAN_CCX
142#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
143 WLAN_CIPHER_SUITE_KRK,
144 WLAN_CIPHER_SUITE_CCMP,
145#else
146 WLAN_CIPHER_SUITE_CCMP,
147#endif
148#ifdef FEATURE_WLAN_WAPI
149 WLAN_CIPHER_SUITE_SMS4,
150#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700151#ifdef WLAN_FEATURE_11W
152 WLAN_CIPHER_SUITE_AES_CMAC,
153#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700154};
155
156static inline int is_broadcast_ether_addr(const u8 *addr)
157{
158 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
159 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
160}
161
162static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530163{
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 HDD2GHZCHAN(2412, 1, 0) ,
165 HDD2GHZCHAN(2417, 2, 0) ,
166 HDD2GHZCHAN(2422, 3, 0) ,
167 HDD2GHZCHAN(2427, 4, 0) ,
168 HDD2GHZCHAN(2432, 5, 0) ,
169 HDD2GHZCHAN(2437, 6, 0) ,
170 HDD2GHZCHAN(2442, 7, 0) ,
171 HDD2GHZCHAN(2447, 8, 0) ,
172 HDD2GHZCHAN(2452, 9, 0) ,
173 HDD2GHZCHAN(2457, 10, 0) ,
174 HDD2GHZCHAN(2462, 11, 0) ,
175 HDD2GHZCHAN(2467, 12, 0) ,
176 HDD2GHZCHAN(2472, 13, 0) ,
177 HDD2GHZCHAN(2484, 14, 0) ,
178};
179
Jeff Johnson295189b2012-06-20 16:38:30 -0700180static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
181{
182 HDD2GHZCHAN(2412, 1, 0) ,
183 HDD2GHZCHAN(2437, 6, 0) ,
184 HDD2GHZCHAN(2462, 11, 0) ,
185};
Jeff Johnson295189b2012-06-20 16:38:30 -0700186
187static struct ieee80211_channel hdd_channels_5_GHZ[] =
188{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700189 HDD5GHZCHAN(4920, 240, 0) ,
190 HDD5GHZCHAN(4940, 244, 0) ,
191 HDD5GHZCHAN(4960, 248, 0) ,
192 HDD5GHZCHAN(4980, 252, 0) ,
193 HDD5GHZCHAN(5040, 208, 0) ,
194 HDD5GHZCHAN(5060, 212, 0) ,
195 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 HDD5GHZCHAN(5180, 36, 0) ,
197 HDD5GHZCHAN(5200, 40, 0) ,
198 HDD5GHZCHAN(5220, 44, 0) ,
199 HDD5GHZCHAN(5240, 48, 0) ,
200 HDD5GHZCHAN(5260, 52, 0) ,
201 HDD5GHZCHAN(5280, 56, 0) ,
202 HDD5GHZCHAN(5300, 60, 0) ,
203 HDD5GHZCHAN(5320, 64, 0) ,
204 HDD5GHZCHAN(5500,100, 0) ,
205 HDD5GHZCHAN(5520,104, 0) ,
206 HDD5GHZCHAN(5540,108, 0) ,
207 HDD5GHZCHAN(5560,112, 0) ,
208 HDD5GHZCHAN(5580,116, 0) ,
209 HDD5GHZCHAN(5600,120, 0) ,
210 HDD5GHZCHAN(5620,124, 0) ,
211 HDD5GHZCHAN(5640,128, 0) ,
212 HDD5GHZCHAN(5660,132, 0) ,
213 HDD5GHZCHAN(5680,136, 0) ,
214 HDD5GHZCHAN(5700,140, 0) ,
215 HDD5GHZCHAN(5745,149, 0) ,
216 HDD5GHZCHAN(5765,153, 0) ,
217 HDD5GHZCHAN(5785,157, 0) ,
218 HDD5GHZCHAN(5805,161, 0) ,
219 HDD5GHZCHAN(5825,165, 0) ,
220};
221
222static struct ieee80211_rate g_mode_rates[] =
223{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530224 HDD_G_MODE_RATETAB(10, 0x1, 0),
225 HDD_G_MODE_RATETAB(20, 0x2, 0),
226 HDD_G_MODE_RATETAB(55, 0x4, 0),
227 HDD_G_MODE_RATETAB(110, 0x8, 0),
228 HDD_G_MODE_RATETAB(60, 0x10, 0),
229 HDD_G_MODE_RATETAB(90, 0x20, 0),
230 HDD_G_MODE_RATETAB(120, 0x40, 0),
231 HDD_G_MODE_RATETAB(180, 0x80, 0),
232 HDD_G_MODE_RATETAB(240, 0x100, 0),
233 HDD_G_MODE_RATETAB(360, 0x200, 0),
234 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530236};
Jeff Johnson295189b2012-06-20 16:38:30 -0700237
238static struct ieee80211_rate a_mode_rates[] =
239{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530240 HDD_G_MODE_RATETAB(60, 0x10, 0),
241 HDD_G_MODE_RATETAB(90, 0x20, 0),
242 HDD_G_MODE_RATETAB(120, 0x40, 0),
243 HDD_G_MODE_RATETAB(180, 0x80, 0),
244 HDD_G_MODE_RATETAB(240, 0x100, 0),
245 HDD_G_MODE_RATETAB(360, 0x200, 0),
246 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700247 HDD_G_MODE_RATETAB(540, 0x800, 0),
248};
249
250static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
251{
252 .channels = hdd_channels_2_4_GHZ,
253 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
254 .band = IEEE80211_BAND_2GHZ,
255 .bitrates = g_mode_rates,
256 .n_bitrates = g_mode_rates_size,
257 .ht_cap.ht_supported = 1,
258 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
259 | IEEE80211_HT_CAP_GRN_FLD
260 | IEEE80211_HT_CAP_DSSSCCK40
261 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
262 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
263 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
264 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
265 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
266 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
267};
268
Jeff Johnson295189b2012-06-20 16:38:30 -0700269static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
270{
271 .channels = hdd_social_channels_2_4_GHZ,
272 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
273 .band = IEEE80211_BAND_2GHZ,
274 .bitrates = g_mode_rates,
275 .n_bitrates = g_mode_rates_size,
276 .ht_cap.ht_supported = 1,
277 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
278 | IEEE80211_HT_CAP_GRN_FLD
279 | IEEE80211_HT_CAP_DSSSCCK40
280 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
281 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
282 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
283 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
284 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
285 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
286};
Jeff Johnson295189b2012-06-20 16:38:30 -0700287
288static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
289{
290 .channels = hdd_channels_5_GHZ,
291 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
292 .band = IEEE80211_BAND_5GHZ,
293 .bitrates = a_mode_rates,
294 .n_bitrates = a_mode_rates_size,
295 .ht_cap.ht_supported = 1,
296 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
297 | IEEE80211_HT_CAP_GRN_FLD
298 | IEEE80211_HT_CAP_DSSSCCK40
299 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
300 | IEEE80211_HT_CAP_SGI_40
301 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
302 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
303 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
304 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
305 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
306 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
307};
308
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530309/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 TX/RX direction for each kind of interface */
311static const struct ieee80211_txrx_stypes
312wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
313 [NL80211_IFTYPE_STATION] = {
314 .tx = 0xffff,
315 .rx = BIT(SIR_MAC_MGMT_ACTION) |
316 BIT(SIR_MAC_MGMT_PROBE_REQ),
317 },
318 [NL80211_IFTYPE_AP] = {
319 .tx = 0xffff,
320 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
321 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
322 BIT(SIR_MAC_MGMT_PROBE_REQ) |
323 BIT(SIR_MAC_MGMT_DISASSOC) |
324 BIT(SIR_MAC_MGMT_AUTH) |
325 BIT(SIR_MAC_MGMT_DEAUTH) |
326 BIT(SIR_MAC_MGMT_ACTION),
327 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700328 [NL80211_IFTYPE_ADHOC] = {
329 .tx = 0xffff,
330 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
331 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
332 BIT(SIR_MAC_MGMT_PROBE_REQ) |
333 BIT(SIR_MAC_MGMT_DISASSOC) |
334 BIT(SIR_MAC_MGMT_AUTH) |
335 BIT(SIR_MAC_MGMT_DEAUTH) |
336 BIT(SIR_MAC_MGMT_ACTION),
337 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 [NL80211_IFTYPE_P2P_CLIENT] = {
339 .tx = 0xffff,
340 .rx = BIT(SIR_MAC_MGMT_ACTION) |
341 BIT(SIR_MAC_MGMT_PROBE_REQ),
342 },
343 [NL80211_IFTYPE_P2P_GO] = {
344 /* This is also same as for SoftAP */
345 .tx = 0xffff,
346 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
347 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_PROBE_REQ) |
349 BIT(SIR_MAC_MGMT_DISASSOC) |
350 BIT(SIR_MAC_MGMT_AUTH) |
351 BIT(SIR_MAC_MGMT_DEAUTH) |
352 BIT(SIR_MAC_MGMT_ACTION),
353 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700354};
355
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800356#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800357static const struct ieee80211_iface_limit
358wlan_hdd_iface_limit[] = {
359 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800360 /* max = 3 ; Our driver create two interfaces during driver init
361 * wlan0 and p2p0 interfaces. p2p0 is considered as station
362 * interface until a group is formed. In JB architecture, once the
363 * group is formed, interface type of p2p0 is changed to P2P GO or
364 * Client.
365 * When supplicant remove the group, it first issue a set interface
366 * cmd to change the mode back to Station. In JB this works fine as
367 * we advertize two station type interface during driver init.
368 * Some vendors create separate interface for P2P GO/Client,
369 * after group formation(Third one). But while group remove
370 * supplicant first tries to change the mode(3rd interface) to STATION
371 * But as we advertized only two sta type interfaces nl80211 was
372 * returning error for the third one which was leading to failure in
373 * delete interface. Ideally while removing the group, supplicant
374 * should not try to change the 3rd interface mode to Station type.
375 * Till we get a fix in wpa_supplicant, we advertize max STA
376 * interface type to 3
377 */
378 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800379 .types = BIT(NL80211_IFTYPE_STATION),
380 },
381 {
382 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700383 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800384 },
385 {
386 .max = 1,
387 .types = BIT(NL80211_IFTYPE_P2P_GO) |
388 BIT(NL80211_IFTYPE_P2P_CLIENT),
389 },
390};
391
392/* By default, only single channel concurrency is allowed */
393static struct ieee80211_iface_combination
394wlan_hdd_iface_combination = {
395 .limits = wlan_hdd_iface_limit,
396 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800397 /*
398 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
399 * and p2p0 interfaces during driver init
400 * Some vendors create separate interface for P2P operations.
401 * wlan0: STA interface
402 * p2p0: P2P Device interface, action frames goes
403 * through this interface.
404 * p2p-xx: P2P interface, After GO negotiation this interface is
405 * created for p2p operations(GO/CLIENT interface).
406 */
407 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800408 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
409 .beacon_int_infra_match = false,
410};
411#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800412
Jeff Johnson295189b2012-06-20 16:38:30 -0700413static struct cfg80211_ops wlan_hdd_cfg80211_ops;
414
415/* Data rate 100KBPS based on IE Index */
416struct index_data_rate_type
417{
418 v_U8_t beacon_rate_index;
419 v_U16_t supported_rate[4];
420};
421
422/* 11B, 11G Rate table include Basic rate and Extended rate
423 The IDX field is the rate index
424 The HI field is the rate when RSSI is strong or being ignored
425 (in this case we report actual rate)
426 The MID field is the rate when RSSI is moderate
427 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
428 The LO field is the rate when RSSI is low
429 (in this case we don't report rates, actual current rate used)
430 */
431static const struct
432{
433 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700434 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700435} supported_data_rate[] =
436{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700437/* IDX HI HM LM LO (RSSI-based index */
438 {2, { 10, 10, 10, 0}},
439 {4, { 20, 20, 10, 0}},
440 {11, { 55, 20, 10, 0}},
441 {12, { 60, 55, 20, 0}},
442 {18, { 90, 55, 20, 0}},
443 {22, {110, 55, 20, 0}},
444 {24, {120, 90, 60, 0}},
445 {36, {180, 120, 60, 0}},
446 {44, {220, 180, 60, 0}},
447 {48, {240, 180, 90, 0}},
448 {66, {330, 180, 90, 0}},
449 {72, {360, 240, 90, 0}},
450 {96, {480, 240, 120, 0}},
451 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700452};
453
454/* MCS Based rate table */
455static struct index_data_rate_type supported_mcs_rate[] =
456{
457/* MCS L20 L40 S20 S40 */
458 {0, {65, 135, 72, 150}},
459 {1, {130, 270, 144, 300}},
460 {2, {195, 405, 217, 450}},
461 {3, {260, 540, 289, 600}},
462 {4, {390, 810, 433, 900}},
463 {5, {520, 1080, 578, 1200}},
464 {6, {585, 1215, 650, 1350}},
465 {7, {650, 1350, 722, 1500}}
466};
467
Leo Chang6f8870f2013-03-26 18:11:36 -0700468#ifdef WLAN_FEATURE_11AC
469
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530470#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700471
472struct index_vht_data_rate_type
473{
474 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530475 v_U16_t supported_VHT80_rate[2];
476 v_U16_t supported_VHT40_rate[2];
477 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700478};
479
480typedef enum
481{
482 DATA_RATE_11AC_MAX_MCS_7,
483 DATA_RATE_11AC_MAX_MCS_8,
484 DATA_RATE_11AC_MAX_MCS_9,
485 DATA_RATE_11AC_MAX_MCS_NA
486} eDataRate11ACMaxMcs;
487
488/* MCS Based VHT rate table */
489static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
490{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530491/* MCS L80 S80 L40 S40 L20 S40*/
492 {0, {293, 325}, {135, 150}, {65, 72}},
493 {1, {585, 650}, {270, 300}, {130, 144}},
494 {2, {878, 975}, {405, 450}, {195, 217}},
495 {3, {1170, 1300}, {540, 600}, {260, 289}},
496 {4, {1755, 1950}, {810, 900}, {390, 433}},
497 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
498 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
499 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
500 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
501 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700502};
503#endif /* WLAN_FEATURE_11AC */
504
Jeff Johnson295189b2012-06-20 16:38:30 -0700505extern struct net_device_ops net_ops_struct;
506
Leo Chang9056f462013-08-01 19:21:11 -0700507#ifdef WLAN_NL80211_TESTMODE
508enum wlan_hdd_tm_attr
509{
510 WLAN_HDD_TM_ATTR_INVALID = 0,
511 WLAN_HDD_TM_ATTR_CMD = 1,
512 WLAN_HDD_TM_ATTR_DATA = 2,
513 WLAN_HDD_TM_ATTR_TYPE = 3,
514 /* keep last */
515 WLAN_HDD_TM_ATTR_AFTER_LAST,
516 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
517};
518
519enum wlan_hdd_tm_cmd
520{
521 WLAN_HDD_TM_CMD_WLAN_HB = 1,
522};
523
524#define WLAN_HDD_TM_DATA_MAX_LEN 5000
525
526static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
527{
528 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
529 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
530 .len = WLAN_HDD_TM_DATA_MAX_LEN },
531};
532#endif /* WLAN_NL80211_TESTMODE */
533
Jeff Johnson295189b2012-06-20 16:38:30 -0700534/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530535 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530536 * This function is called by hdd_wlan_startup()
537 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530538 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530540struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700541{
542 struct wiphy *wiphy;
543 ENTER();
544
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530545 /*
546 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 */
548 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
549
550 if (!wiphy)
551 {
552 /* Print error and jump into err label and free the memory */
553 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
554 return NULL;
555 }
556
557 return wiphy;
558}
559
560/*
561 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530562 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 * private ioctl to change the band value
564 */
565int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
566{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530567 int i, j;
568 eNVChannelEnabledType channelEnabledState;
569
Jeff Johnsone7245742012-09-05 17:12:55 -0700570 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530571 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530573
574 if (NULL == wiphy->bands[i])
575 {
576 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
577 __func__, i);
578 continue;
579 }
580
581 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
582 {
583 struct ieee80211_supported_band *band = wiphy->bands[i];
584
585 channelEnabledState = vos_nv_getChannelEnabledState(
586 band->channels[j].hw_value);
587
588 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
589 {
590 // Enable Social channels for P2P
591 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
592 NV_CHANNEL_ENABLE == channelEnabledState)
593 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
594 else
595 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
596 continue;
597 }
598 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
599 {
600 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
601 continue;
602 }
603
604 if (NV_CHANNEL_DISABLE == channelEnabledState ||
605 NV_CHANNEL_INVALID == channelEnabledState)
606 {
607 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
608 }
609 else if (NV_CHANNEL_DFS == channelEnabledState)
610 {
611 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
612 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
613 }
614 else
615 {
616 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
617 |IEEE80211_CHAN_RADAR);
618 }
619 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 }
621 return 0;
622}
623/*
624 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530625 * This function is called by hdd_wlan_startup()
626 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 * This function is used to initialize and register wiphy structure.
628 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530629int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 struct wiphy *wiphy,
631 hdd_config_t *pCfg
632 )
633{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530634 int i, j;
Jeff Johnsone7245742012-09-05 17:12:55 -0700635 ENTER();
636
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 /* Now bind the underlying wlan device with wiphy */
638 set_wiphy_dev(wiphy, dev);
639
640 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700641
642 /* This will disable updating of NL channels from passive to
643 * active if a beacon is received on passive channel. */
644 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700645
Amar Singhalfddc28c2013-09-05 13:03:40 -0700646
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700647#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700648 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
649 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
650 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700651 | WIPHY_FLAG_OFFCHAN_TX;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700652#endif
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700653#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
654 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800655#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700656 || pCfg->isFastRoamIniFeatureEnabled
657#endif
658#ifdef FEATURE_WLAN_CCX
659 || pCfg->isCcxIniFeatureEnabled
660#endif
661 )
662 {
663 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
664 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800665#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800666#ifdef FEATURE_WLAN_TDLS
667 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
668 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
669#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530670#ifdef FEATURE_WLAN_SCAN_PNO
671 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
Madan Mohan Koyyalamudi75de0102013-09-17 14:56:29 +0530672 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530673 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +0530674 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530675#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800676
Amar Singhalfddc28c2013-09-05 13:03:40 -0700677#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700678 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
679 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700680 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700681 driver need to determine what to do with both
682 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700683
684 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
685#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700686
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530687 wiphy->max_scan_ssids = MAX_SCAN_SSID;
688
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530689 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700690
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530691 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530694 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700695 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 | BIT(NL80211_IFTYPE_P2P_CLIENT)
697 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 | BIT(NL80211_IFTYPE_AP);
699
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800700#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800701 if( pCfg->enableMCC )
702 {
703 /* Currently, supports up to two channels */
704 wlan_hdd_iface_combination.num_different_channels = 2;
705
706 if( !pCfg->allowMCCGODiffBI )
707 wlan_hdd_iface_combination.beacon_int_infra_match = true;
708
709 }
710 wiphy->iface_combinations = &wlan_hdd_iface_combination;
711 wiphy->n_iface_combinations = 1;
712#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800713
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 /* Before registering we need to update the ht capabilitied based
715 * on ini values*/
716 if( !pCfg->ShortGI20MhzEnable )
717 {
718 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
719 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
720 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
721 }
722
723 if( !pCfg->ShortGI40MhzEnable )
724 {
725 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
726 }
727
728 if( !pCfg->nChannelBondingMode5GHz )
729 {
730 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
731 }
732
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530733 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
734 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
735
736 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
737 {
738
739 if (NULL == wiphy->bands[i])
740 {
741 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
742 __func__, i);
743 continue;
744 }
745
746 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
747 {
748 struct ieee80211_supported_band *band = wiphy->bands[i];
749
750 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
751 {
752 // Enable social channels for P2P
753 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
754 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
755 else
756 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
757 continue;
758 }
759 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
760 {
761 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
762 continue;
763 }
764 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 }
766 /*Initialise the supported cipher suite details*/
767 wiphy->cipher_suites = hdd_cipher_suites;
768 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
769
770 /*signal strength in mBm (100*dBm) */
771 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
772
773#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 wiphy->max_remain_on_channel_duration = 1000;
775#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700776
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530777 EXIT();
778 return 0;
779}
780
781/* In this function we are registering wiphy. */
782int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
783{
784 ENTER();
785 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 if (0 > wiphy_register(wiphy))
787 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530788 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
790 return -EIO;
791 }
792
793 EXIT();
794 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530795}
Jeff Johnson295189b2012-06-20 16:38:30 -0700796
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530797/* In this function we are updating channel list when,
798 regulatory domain is FCC and country code is US.
799 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
800 As per FCC smart phone is not a indoor device.
801 GO should not opeate on indoor channels */
802void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
803{
804 int j;
805 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
806 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
807 //Default counrtycode from NV at the time of wiphy initialization.
808 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
809 &defaultCountryCode[0]))
810 {
811 hddLog(LOGE, FL("%s Failed to get default country code from NV"));
812 }
813 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
814 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530815 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
816 {
817 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
818 return;
819 }
820 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
821 {
822 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
823 // Mark UNII -1 band channel as passive
824 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
825 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
826 }
827 }
828}
829
Jeff Johnson295189b2012-06-20 16:38:30 -0700830/* In this function we will do all post VOS start initialization.
831 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530832 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700833*/
834void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
835{
Jeff Johnson295189b2012-06-20 16:38:30 -0700836 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
837 /* Register for all P2P action, public action etc frames */
838 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
839
Jeff Johnsone7245742012-09-05 17:12:55 -0700840 ENTER();
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 /* Right now we are registering these frame when driver is getting
843 initialized. Once we will move to 2.6.37 kernel, in which we have
844 frame register ops, we will move this code as a part of that */
845 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530846 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
848
849 /* GAS Initial Response */
850 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
851 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530852
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 /* GAS Comeback Request */
854 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
855 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
856
857 /* GAS Comeback Response */
858 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
859 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
860
861 /* P2P Public Action */
862 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530863 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700864 P2P_PUBLIC_ACTION_FRAME_SIZE );
865
866 /* P2P Action */
867 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
868 (v_U8_t*)P2P_ACTION_FRAME,
869 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700870
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530871 /* WNM BSS Transition Request frame */
872 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
873 (v_U8_t*)WNM_BSS_ACTION_FRAME,
874 WNM_BSS_ACTION_FRAME_SIZE );
875
Chet Lanctot186b5732013-03-18 10:26:30 -0700876#ifdef WLAN_FEATURE_11W
877 /* SA Query Response Action Frame */
878 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
879 (v_U8_t*)SA_QUERY_FRAME_RSP,
880 SA_QUERY_FRAME_RSP_SIZE );
881#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700882}
883
884void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
885{
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
887 /* Register for all P2P action, public action etc frames */
888 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
889
Jeff Johnsone7245742012-09-05 17:12:55 -0700890 ENTER();
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 /* Right now we are registering these frame when driver is getting
893 initialized. Once we will move to 2.6.37 kernel, in which we have
894 frame register ops, we will move this code as a part of that */
895 /* GAS Initial Request */
896
897 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
898 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
899
900 /* GAS Initial Response */
901 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
902 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* GAS Comeback Request */
905 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
906 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
907
908 /* GAS Comeback Response */
909 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
910 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
911
912 /* P2P Public Action */
913 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530914 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700915 P2P_PUBLIC_ACTION_FRAME_SIZE );
916
917 /* P2P Action */
918 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
919 (v_U8_t*)P2P_ACTION_FRAME,
920 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700921
922#ifdef WLAN_FEATURE_11W
923 /* SA Query Response Action Frame */
924 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
925 (v_U8_t*)SA_QUERY_FRAME_RSP,
926 SA_QUERY_FRAME_RSP_SIZE );
927#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700928}
929
930#ifdef FEATURE_WLAN_WAPI
931void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
932 const u8 *mac_addr, u8 *key , int key_Len)
933{
934 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
935 tCsrRoamSetKey setKey;
936 v_BOOL_t isConnected = TRUE;
937 int status = 0;
938 v_U32_t roamId= 0xFF;
939 tANI_U8 *pKeyPtr = NULL;
940 int n = 0;
941
942 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
943 __func__,pAdapter->device_mode);
944
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530945 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 setKey.keyId = key_index; // Store Key ID
947 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
948 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
949 setKey.paeRole = 0 ; // the PAE role
950 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
951 {
952 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
953 }
954 else
955 {
956 isConnected = hdd_connIsConnected(pHddStaCtx);
957 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
958 }
959 setKey.keyLength = key_Len;
960 pKeyPtr = setKey.Key;
961 memcpy( pKeyPtr, key, key_Len);
962
963 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
964 __func__, key_Len);
965 for (n = 0 ; n < key_Len; n++)
966 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
967 __func__,n,setKey.Key[n]);
968
969 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
970 if ( isConnected )
971 {
972 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
973 pAdapter->sessionId, &setKey, &roamId );
974 }
975 if ( status != 0 )
976 {
977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
978 "[%4d] sme_RoamSetKey returned ERROR status= %d",
979 __LINE__, status );
980 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
981 }
982}
983#endif /* FEATURE_WLAN_WAPI*/
984
985#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530986int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 beacon_data_t **ppBeacon,
988 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700989#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530990int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700991 beacon_data_t **ppBeacon,
992 struct cfg80211_beacon_data *params,
993 int dtim_period)
994#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530995{
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 int size;
997 beacon_data_t *beacon = NULL;
998 beacon_data_t *old = NULL;
999 int head_len,tail_len;
1000
Jeff Johnsone7245742012-09-05 17:12:55 -07001001 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 if (params->head && !params->head_len)
1003 return -EINVAL;
1004
1005 old = pAdapter->sessionCtx.ap.beacon;
1006
1007 if (!params->head && !old)
1008 return -EINVAL;
1009
1010 if (params->tail && !params->tail_len)
1011 return -EINVAL;
1012
1013#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1014 /* Kernel 3.0 is not updating dtim_period for set beacon */
1015 if (!params->dtim_period)
1016 return -EINVAL;
1017#endif
1018
1019 if(params->head)
1020 head_len = params->head_len;
1021 else
1022 head_len = old->head_len;
1023
1024 if(params->tail || !old)
1025 tail_len = params->tail_len;
1026 else
1027 tail_len = old->tail_len;
1028
1029 size = sizeof(beacon_data_t) + head_len + tail_len;
1030
1031 beacon = kzalloc(size, GFP_KERNEL);
1032
1033 if( beacon == NULL )
1034 return -ENOMEM;
1035
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001036#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 if(params->dtim_period || !old )
1038 beacon->dtim_period = params->dtim_period;
1039 else
1040 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001041#else
1042 if(dtim_period || !old )
1043 beacon->dtim_period = dtim_period;
1044 else
1045 beacon->dtim_period = old->dtim_period;
1046#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301047
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1049 beacon->tail = beacon->head + head_len;
1050 beacon->head_len = head_len;
1051 beacon->tail_len = tail_len;
1052
1053 if(params->head) {
1054 memcpy (beacon->head,params->head,beacon->head_len);
1055 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301056 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 if(old)
1058 memcpy (beacon->head,old->head,beacon->head_len);
1059 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301060
Jeff Johnson295189b2012-06-20 16:38:30 -07001061 if(params->tail) {
1062 memcpy (beacon->tail,params->tail,beacon->tail_len);
1063 }
1064 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301065 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 memcpy (beacon->tail,old->tail,beacon->tail_len);
1067 }
1068
1069 *ppBeacon = beacon;
1070
1071 kfree(old);
1072
1073 return 0;
1074
1075}
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
1077v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1078{
1079 int left = length;
1080 v_U8_t *ptr = pIes;
1081 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301084 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001085 elem_id = ptr[0];
1086 elem_len = ptr[1];
1087 left -= 2;
1088 if(elem_len > left)
1089 {
1090 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001091 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 eid,elem_len,left);
1093 return NULL;
1094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301095 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001096 {
1097 return ptr;
1098 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301099
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 left -= elem_len;
1101 ptr += (elem_len + 2);
1102 }
1103 return NULL;
1104}
1105
Jeff Johnson295189b2012-06-20 16:38:30 -07001106/* Check if rate is 11g rate or not */
1107static int wlan_hdd_rate_is_11g(u8 rate)
1108{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001109 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 u8 i;
1111 for (i = 0; i < 8; i++)
1112 {
1113 if(rate == gRateArray[i])
1114 return TRUE;
1115 }
1116 return FALSE;
1117}
1118
1119/* Check for 11g rate and set proper 11g only mode */
1120static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1121 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1122{
1123 u8 i, num_rates = pIe[0];
1124
1125 pIe += 1;
1126 for ( i = 0; i < num_rates; i++)
1127 {
1128 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1129 {
1130 /* If rate set have 11g rate than change the mode to 11G */
1131 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1132 if (pIe[i] & BASIC_RATE_MASK)
1133 {
1134 /* If we have 11g rate as basic rate, it means mode
1135 is 11g only mode.
1136 */
1137 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1138 *pCheckRatesfor11g = FALSE;
1139 }
1140 }
1141 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1142 {
1143 *require_ht = TRUE;
1144 }
1145 }
1146 return;
1147}
1148
1149static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1150{
1151 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1152 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1153 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1154 u8 checkRatesfor11g = TRUE;
1155 u8 require_ht = FALSE;
1156 u8 *pIe=NULL;
1157
1158 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1159
1160 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1161 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1162 if (pIe != NULL)
1163 {
1164 pIe += 1;
1165 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1166 &pConfig->SapHw_mode);
1167 }
1168
1169 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1170 WLAN_EID_EXT_SUPP_RATES);
1171 if (pIe != NULL)
1172 {
1173
1174 pIe += 1;
1175 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1176 &pConfig->SapHw_mode);
1177 }
1178
1179 if( pConfig->channel > 14 )
1180 {
1181 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1182 }
1183
1184 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1185 WLAN_EID_HT_CAPABILITY);
1186
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301187 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 {
1189 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1190 if(require_ht)
1191 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1192 }
1193}
1194
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301195static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1196 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1197{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001198 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301199 v_U8_t *pIe = NULL;
1200 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1201
1202 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1203 pBeacon->tail, pBeacon->tail_len);
1204
1205 if (pIe)
1206 {
1207 ielen = pIe[1] + 2;
1208 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1209 {
1210 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1211 }
1212 else
1213 {
1214 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1215 return -EINVAL;
1216 }
1217 *total_ielen += ielen;
1218 }
1219 return 0;
1220}
1221
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001222static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1223 v_U8_t *genie, v_U8_t *total_ielen)
1224{
1225 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1226 int left = pBeacon->tail_len;
1227 v_U8_t *ptr = pBeacon->tail;
1228 v_U8_t elem_id, elem_len;
1229 v_U16_t ielen = 0;
1230
1231 if ( NULL == ptr || 0 == left )
1232 return;
1233
1234 while (left >= 2)
1235 {
1236 elem_id = ptr[0];
1237 elem_len = ptr[1];
1238 left -= 2;
1239 if (elem_len > left)
1240 {
1241 hddLog( VOS_TRACE_LEVEL_ERROR,
1242 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1243 elem_id, elem_len, left);
1244 return;
1245 }
1246 if (IE_EID_VENDOR == elem_id)
1247 {
1248 /* skipping the VSIE's which we don't want to include or
1249 * it will be included by existing code
1250 */
1251 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1252#ifdef WLAN_FEATURE_WFD
1253 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1254#endif
1255 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1256 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1257 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1258 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1259 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1260 {
1261 ielen = ptr[1] + 2;
1262 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1263 {
1264 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1265 *total_ielen += ielen;
1266 }
1267 else
1268 {
1269 hddLog( VOS_TRACE_LEVEL_ERROR,
1270 "IE Length is too big "
1271 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1272 elem_id, elem_len, *total_ielen);
1273 }
1274 }
1275 }
1276
1277 left -= elem_len;
1278 ptr += (elem_len + 2);
1279 }
1280 return;
1281}
1282
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001283#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001284static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1285 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001286#else
1287static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1288 struct cfg80211_beacon_data *params)
1289#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001290{
1291 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301292 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001293 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001294 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001295
1296 genie = vos_mem_malloc(MAX_GENIE_LEN);
1297
1298 if(genie == NULL) {
1299
1300 return -ENOMEM;
1301 }
1302
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301303 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1304 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301306 ret = -EINVAL;
1307 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 }
1309
1310#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301311 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1312 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1313 {
1314 ret = -EINVAL;
1315 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001316 }
1317#endif
1318
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301319 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1320 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301322 ret = -EINVAL;
1323 goto done;
1324 }
1325
1326 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1327 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001328 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001330
1331 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1332 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1333 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1334 {
1335 hddLog(LOGE,
1336 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001337 ret = -EINVAL;
1338 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 }
1340
1341 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1342 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1343 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1344 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1345 ==eHAL_STATUS_FAILURE)
1346 {
1347 hddLog(LOGE,
1348 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001349 ret = -EINVAL;
1350 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 }
1352
1353 // Added for ProResp IE
1354 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1355 {
1356 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1357 u8 probe_rsp_ie_len[3] = {0};
1358 u8 counter = 0;
1359 /* Check Probe Resp Length if it is greater then 255 then Store
1360 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1361 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1362 Store More then 255 bytes into One Variable.
1363 */
1364 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1365 {
1366 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1367 {
1368 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1369 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1370 }
1371 else
1372 {
1373 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1374 rem_probe_resp_ie_len = 0;
1375 }
1376 }
1377
1378 rem_probe_resp_ie_len = 0;
1379
1380 if (probe_rsp_ie_len[0] > 0)
1381 {
1382 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1383 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1384 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1385 probe_rsp_ie_len[0], NULL,
1386 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1387 {
1388 hddLog(LOGE,
1389 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001390 ret = -EINVAL;
1391 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 }
1393 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1394 }
1395
1396 if (probe_rsp_ie_len[1] > 0)
1397 {
1398 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1399 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1400 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1401 probe_rsp_ie_len[1], NULL,
1402 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1403 {
1404 hddLog(LOGE,
1405 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001406 ret = -EINVAL;
1407 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 }
1409 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1410 }
1411
1412 if (probe_rsp_ie_len[2] > 0)
1413 {
1414 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1415 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1416 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1417 probe_rsp_ie_len[2], NULL,
1418 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1419 {
1420 hddLog(LOGE,
1421 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001422 ret = -EINVAL;
1423 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 }
1425 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1426 }
1427
1428 if (probe_rsp_ie_len[1] == 0 )
1429 {
1430 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1431 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1432 eANI_BOOLEAN_FALSE) )
1433 {
1434 hddLog(LOGE,
1435 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1436 }
1437 }
1438
1439 if (probe_rsp_ie_len[2] == 0 )
1440 {
1441 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1442 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1443 eANI_BOOLEAN_FALSE) )
1444 {
1445 hddLog(LOGE,
1446 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1447 }
1448 }
1449
1450 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1451 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1452 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1453 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1454 == eHAL_STATUS_FAILURE)
1455 {
1456 hddLog(LOGE,
1457 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001458 ret = -EINVAL;
1459 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001460 }
1461 }
1462 else
1463 {
1464 // Reset WNI_CFG_PROBE_RSP Flags
1465 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1466
1467 hddLog(VOS_TRACE_LEVEL_INFO,
1468 "%s: No Probe Response IE received in set beacon",
1469 __func__);
1470 }
1471
1472 // Added for AssocResp IE
1473 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1474 {
1475 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1476 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1477 params->assocresp_ies_len, NULL,
1478 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1479 {
1480 hddLog(LOGE,
1481 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001482 ret = -EINVAL;
1483 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 }
1485
1486 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1487 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1488 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1489 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1490 == eHAL_STATUS_FAILURE)
1491 {
1492 hddLog(LOGE,
1493 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 ret = -EINVAL;
1495 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 }
1497 }
1498 else
1499 {
1500 hddLog(VOS_TRACE_LEVEL_INFO,
1501 "%s: No Assoc Response IE received in set beacon",
1502 __func__);
1503
1504 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1505 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1506 eANI_BOOLEAN_FALSE) )
1507 {
1508 hddLog(LOGE,
1509 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1510 }
1511 }
1512
Jeff Johnsone7245742012-09-05 17:12:55 -07001513done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301515 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516}
Jeff Johnson295189b2012-06-20 16:38:30 -07001517
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301518/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001519 * FUNCTION: wlan_hdd_validate_operation_channel
1520 * called by wlan_hdd_cfg80211_start_bss() and
1521 * wlan_hdd_cfg80211_set_channel()
1522 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301523 * channel list.
1524 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001525VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001526{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301527
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 v_U32_t num_ch = 0;
1529 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1530 u32 indx = 0;
1531 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301532 v_U8_t fValidChannel = FALSE, count = 0;
1533 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301534
Jeff Johnson295189b2012-06-20 16:38:30 -07001535 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1536
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301537 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301539 /* Validate the channel */
1540 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001541 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301542 if ( channel == rfChannels[count].channelNum )
1543 {
1544 fValidChannel = TRUE;
1545 break;
1546 }
1547 }
1548 if (fValidChannel != TRUE)
1549 {
1550 hddLog(VOS_TRACE_LEVEL_ERROR,
1551 "%s: Invalid Channel [%d]", __func__, channel);
1552 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 }
1554 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301555 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301557 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1558 valid_ch, &num_ch))
1559 {
1560 hddLog(VOS_TRACE_LEVEL_ERROR,
1561 "%s: failed to get valid channel list", __func__);
1562 return VOS_STATUS_E_FAILURE;
1563 }
1564 for (indx = 0; indx < num_ch; indx++)
1565 {
1566 if (channel == valid_ch[indx])
1567 {
1568 break;
1569 }
1570 }
1571
1572 if (indx >= num_ch)
1573 {
1574 hddLog(VOS_TRACE_LEVEL_ERROR,
1575 "%s: Invalid Channel [%d]", __func__, channel);
1576 return VOS_STATUS_E_FAILURE;
1577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 }
1579 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301580
Jeff Johnson295189b2012-06-20 16:38:30 -07001581}
1582
Viral Modi3a32cc52013-02-08 11:14:52 -08001583/**
1584 * FUNCTION: wlan_hdd_cfg80211_set_channel
1585 * This function is used to set the channel number
1586 */
1587static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1588 struct ieee80211_channel *chan,
1589 enum nl80211_channel_type channel_type
1590 )
1591{
1592 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001593 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001594 hdd_adapter_t *pAdapter = NULL;
1595 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301596 hdd_context_t *pHddCtx;
1597 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001598
1599 ENTER();
1600
1601 if( NULL == dev )
1602 {
1603 hddLog(VOS_TRACE_LEVEL_ERROR,
1604 "%s: Called with dev = NULL.\n", __func__);
1605 return -ENODEV;
1606 }
1607 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1608
1609 hddLog(VOS_TRACE_LEVEL_INFO,
1610 "%s: device_mode = %d freq = %d \n",__func__,
1611 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301612
1613 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1614 status = wlan_hdd_validate_context(pHddCtx);
1615
1616 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001617 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1619 "%s: HDD context is not valid", __func__);
1620 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001621 }
1622
1623 /*
1624 * Do freq to chan conversion
1625 * TODO: for 11a
1626 */
1627
1628 channel = ieee80211_frequency_to_channel(freq);
1629
1630 /* Check freq range */
1631 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1632 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1633 {
1634 hddLog(VOS_TRACE_LEVEL_ERROR,
1635 "%s: Channel [%d] is outside valid range from %d to %d\n",
1636 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1637 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1638 return -EINVAL;
1639 }
1640
1641 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1642
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301643 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1644 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001645 {
1646 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1647 {
1648 hddLog(VOS_TRACE_LEVEL_ERROR,
1649 "%s: Invalid Channel [%d] \n", __func__, channel);
1650 return -EINVAL;
1651 }
1652 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1653 "%s: set channel to [%d] for device mode =%d",
1654 __func__, channel,pAdapter->device_mode);
1655 }
1656 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001657 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001658 )
1659 {
1660 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1661 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1662 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1663
1664 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1665 {
1666 /* Link is up then return cant set channel*/
1667 hddLog( VOS_TRACE_LEVEL_ERROR,
1668 "%s: IBSS Associated, can't set the channel\n", __func__);
1669 return -EINVAL;
1670 }
1671
1672 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1673 pHddStaCtx->conn_info.operationChannel = channel;
1674 pRoamProfile->ChannelInfo.ChannelList =
1675 &pHddStaCtx->conn_info.operationChannel;
1676 }
1677 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001678 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001679 )
1680 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301681 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1682 {
1683 if(VOS_STATUS_SUCCESS !=
1684 wlan_hdd_validate_operation_channel(pAdapter,channel))
1685 {
1686 hddLog(VOS_TRACE_LEVEL_ERROR,
1687 "%s: Invalid Channel [%d] \n", __func__, channel);
1688 return -EINVAL;
1689 }
1690 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1691 }
1692 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001693 {
1694 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1695
1696 /* If auto channel selection is configured as enable/ 1 then ignore
1697 channel set by supplicant
1698 */
1699 if ( cfg_param->apAutoChannelSelection )
1700 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301701 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1702 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001703 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1704 "%s: set channel to auto channel (0) for device mode =%d",
1705 __func__, pAdapter->device_mode);
1706 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301707 else
1708 {
1709 if(VOS_STATUS_SUCCESS !=
1710 wlan_hdd_validate_operation_channel(pAdapter,channel))
1711 {
1712 hddLog(VOS_TRACE_LEVEL_ERROR,
1713 "%s: Invalid Channel [%d] \n", __func__, channel);
1714 return -EINVAL;
1715 }
1716 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1717 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001718 }
1719 }
1720 else
1721 {
1722 hddLog(VOS_TRACE_LEVEL_FATAL,
1723 "%s: Invalid device mode failed to set valid channel", __func__);
1724 return -EINVAL;
1725 }
1726 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301727 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001728}
1729
Jeff Johnson295189b2012-06-20 16:38:30 -07001730#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1731static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1732 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001733#else
1734static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1735 struct cfg80211_beacon_data *params,
1736 const u8 *ssid, size_t ssid_len,
1737 enum nl80211_hidden_ssid hidden_ssid)
1738#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001739{
1740 tsap_Config_t *pConfig;
1741 beacon_data_t *pBeacon = NULL;
1742 struct ieee80211_mgmt *pMgmt_frame;
1743 v_U8_t *pIe=NULL;
1744 v_U16_t capab_info;
1745 eCsrAuthType RSNAuthType;
1746 eCsrEncryptionType RSNEncryptType;
1747 eCsrEncryptionType mcRSNEncryptType;
1748 int status = VOS_STATUS_SUCCESS;
1749 tpWLAN_SAPEventCB pSapEventCallback;
1750 hdd_hostapd_state_t *pHostapdState;
1751 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1752 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301753 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 struct qc_mac_acl_entry *acl_entry = NULL;
1755 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001756 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001757
1758 ENTER();
1759
1760 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1761
1762 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1763
1764 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1765
1766 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1767
1768 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1769
1770 //channel is already set in the set_channel Call back
1771 //pConfig->channel = pCommitConfig->channel;
1772
1773 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301774 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1776
1777 pConfig->dtim_period = pBeacon->dtim_period;
1778
1779 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1780 pConfig->dtim_period);
1781
1782
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001783 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001784 {
1785 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001787 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001789 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001790 pConfig->ieee80211d = 1;
1791 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1792 sme_setRegInfo(hHal, pConfig->countryCode);
1793 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001795 else
1796 {
1797 pConfig->ieee80211d = 0;
1798 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301799 /*
1800 * If auto channel is configured i.e. channel is 0,
1801 * so skip channel validation.
1802 */
1803 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1804 {
1805 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1806 {
1807 hddLog(VOS_TRACE_LEVEL_ERROR,
1808 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1809 return -EINVAL;
1810 }
1811 }
1812 else
1813 {
1814 if(1 != pHddCtx->is_dynamic_channel_range_set)
1815 {
1816 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1817 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1818 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1819 }
1820 pHddCtx->is_dynamic_channel_range_set = 0;
1821 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001822 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001823 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001824 {
1825 pConfig->ieee80211d = 0;
1826 }
1827 pConfig->authType = eSAP_AUTO_SWITCH;
1828
1829 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301830
1831 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1833
1834 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1835
1836 /*Set wps station to configured*/
1837 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1838
1839 if(pIe)
1840 {
1841 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1842 {
1843 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1844 return -EINVAL;
1845 }
1846 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1847 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001848 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001849 /* Check 15 bit of WPS IE as it contain information for wps state
1850 * WPS state
1851 */
1852 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1853 {
1854 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1855 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1856 {
1857 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1858 }
1859 }
1860 }
1861 else
1862 {
1863 pConfig->wps_state = SAP_WPS_DISABLED;
1864 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301865 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001866
1867 pConfig->RSNWPAReqIELength = 0;
1868 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301869 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 WLAN_EID_RSN);
1871 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301872 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001873 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1874 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1875 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301876 /* The actual processing may eventually be more extensive than
1877 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 * by the app.
1879 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301880 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1882 &RSNEncryptType,
1883 &mcRSNEncryptType,
1884 &RSNAuthType,
1885 pConfig->pRSNWPAReqIE[1]+2,
1886 pConfig->pRSNWPAReqIE );
1887
1888 if( VOS_STATUS_SUCCESS == status )
1889 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301890 /* Now copy over all the security attributes you have
1891 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 * */
1893 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1894 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1895 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1896 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301897 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 "EncryptionType = %d mcEncryptionType = %d\n"),
1899 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1900 }
1901 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301902
Jeff Johnson295189b2012-06-20 16:38:30 -07001903 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1904 pBeacon->tail, pBeacon->tail_len);
1905
1906 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1907 {
1908 if (pConfig->pRSNWPAReqIE)
1909 {
1910 /*Mixed mode WPA/WPA2*/
1911 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1912 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1913 }
1914 else
1915 {
1916 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1917 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1918 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301919 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1921 &RSNEncryptType,
1922 &mcRSNEncryptType,
1923 &RSNAuthType,
1924 pConfig->pRSNWPAReqIE[1]+2,
1925 pConfig->pRSNWPAReqIE );
1926
1927 if( VOS_STATUS_SUCCESS == status )
1928 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301929 /* Now copy over all the security attributes you have
1930 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 * */
1932 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1933 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1934 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1935 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301936 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 "EncryptionType = %d mcEncryptionType = %d\n"),
1938 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1939 }
1940 }
1941 }
1942
Jeff Johnson4416a782013-03-25 14:17:50 -07001943 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1944 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1945 return -EINVAL;
1946 }
1947
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1949
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001950#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 if (params->ssid != NULL)
1952 {
1953 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1954 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1955 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1956 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1957 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001958#else
1959 if (ssid != NULL)
1960 {
1961 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1962 pConfig->SSIDinfo.ssid.length = ssid_len;
1963 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1964 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1965 }
1966#endif
1967
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301968 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301970
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 /* default value */
1972 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1973 pConfig->num_accept_mac = 0;
1974 pConfig->num_deny_mac = 0;
1975
1976 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1977 pBeacon->tail, pBeacon->tail_len);
1978
1979 /* pIe for black list is following form:
1980 type : 1 byte
1981 length : 1 byte
1982 OUI : 4 bytes
1983 acl type : 1 byte
1984 no of mac addr in black list: 1 byte
1985 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301986 */
1987 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001988 {
1989 pConfig->SapMacaddr_acl = pIe[6];
1990 pConfig->num_deny_mac = pIe[7];
1991 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
1992 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05301993 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
1994 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001995 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
1996 for (i = 0; i < pConfig->num_deny_mac; i++)
1997 {
1998 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
1999 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 }
2002 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2003 pBeacon->tail, pBeacon->tail_len);
2004
2005 /* pIe for white list is following form:
2006 type : 1 byte
2007 length : 1 byte
2008 OUI : 4 bytes
2009 acl type : 1 byte
2010 no of mac addr in white list: 1 byte
2011 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302012 */
2013 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 {
2015 pConfig->SapMacaddr_acl = pIe[6];
2016 pConfig->num_accept_mac = pIe[7];
2017 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2018 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302019 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2020 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2022 for (i = 0; i < pConfig->num_accept_mac; i++)
2023 {
2024 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2025 acl_entry++;
2026 }
2027 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302028
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2030
Jeff Johnsone7245742012-09-05 17:12:55 -07002031#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002032 /* Overwrite the hostapd setting for HW mode only for 11ac.
2033 * This is valid only if mode is set to 11n in hostapd and either AUTO or 11ac in .ini .
2034 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode) */
2035 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2036 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302037 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002038 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
2039 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002040 {
2041 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002042
2043 /* Disable VHT support in 2.4 GHz band */
2044 if (pConfig->channel <= 14 &&
2045 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2046 {
2047 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2048 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002049 }
2050#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302051
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002052 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2053 {
2054 sme_SelectCBMode(hHal,
2055 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2056 pConfig->channel);
2057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 // ht_capab is not what the name conveys,this is used for protection bitmap
2059 pConfig->ht_capab =
2060 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2061
2062 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2063 {
2064 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2065 return -EINVAL;
2066 }
2067
2068 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302069 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2071 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302072 pConfig->obssProtEnabled =
2073 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002074
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302075 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302077 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2079 (int)pConfig->channel);
2080 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302081 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2082 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302084 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2086 pConfig->protEnabled, pConfig->obssProtEnabled);
2087
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302088 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 {
2090 //Bss already started. just return.
2091 //TODO Probably it should update some beacon params.
2092 hddLog( LOGE, "Bss Already started...Ignore the request");
2093 EXIT();
2094 return 0;
2095 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302096
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 pConfig->persona = pHostapdAdapter->device_mode;
2098
2099 pSapEventCallback = hdd_hostapd_SAPEventCB;
2100 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2101 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2102 {
2103 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2104 return -EINVAL;
2105 }
2106
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302107 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2109
2110 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302111
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302113 {
2114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002116 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002117 VOS_ASSERT(0);
2118 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302119
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 //Succesfully started Bss update the state bit.
2121 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2122
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002123#ifdef WLAN_FEATURE_P2P_DEBUG
2124 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2125 {
2126 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2127 {
2128 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2129 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002130 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002131 }
2132 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2133 {
2134 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2135 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002136 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002137 }
2138 }
2139#endif
2140
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 pHostapdState->bCommit = TRUE;
2142 EXIT();
2143
2144 return 0;
2145}
2146
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002147#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302148static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2149 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002150 struct beacon_parameters *params)
2151{
2152 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302153 hdd_context_t *pHddCtx;
2154 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002155
2156 ENTER();
2157
2158 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2159
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302160 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2161 status = wlan_hdd_validate_context(pHddCtx);
2162
2163 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002164 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2166 "%s: HDD context is not valid", __func__);
2167 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002168 }
2169
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302170 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 )
2173 {
2174 beacon_data_t *old,*new;
2175
2176 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302177
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 if (old)
2179 return -EALREADY;
2180
2181 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2182
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302183 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 {
2185 hddLog(VOS_TRACE_LEVEL_FATAL,
2186 "%s:Error!!! Allocating the new beacon\n",__func__);
2187 return -EINVAL;
2188 }
2189
2190 pAdapter->sessionCtx.ap.beacon = new;
2191
2192 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2193 }
2194
2195 EXIT();
2196 return status;
2197}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302198
2199static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 struct net_device *dev,
2201 struct beacon_parameters *params)
2202{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302203 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302204 hdd_context_t *pHddCtx;
2205 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002206
2207 ENTER();
2208
2209 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2210 __func__,pAdapter->device_mode);
2211
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302212 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2213 status = wlan_hdd_validate_context(pHddCtx);
2214
2215 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002216 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302217 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2218 "%s: HDD context is not valid", __func__);
2219 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002220 }
2221
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302222 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302224 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002225 {
2226 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302227
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302229
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 if (!old)
2231 return -ENOENT;
2232
2233 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2234
2235 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302236 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 "%s: Error!!! Allocating the new beacon\n",__func__);
2238 return -EINVAL;
2239 }
2240
2241 pAdapter->sessionCtx.ap.beacon = new;
2242
2243 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2244 }
2245
2246 EXIT();
2247 return status;
2248}
2249
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002250#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2251
2252#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002253static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2254 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002255#else
2256static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2257 struct net_device *dev)
2258#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002259{
2260 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002261 hdd_context_t *pHddCtx = NULL;
2262 hdd_scaninfo_t *pScanInfo = NULL;
2263 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302264 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
2266 ENTER();
2267
2268 if (NULL == pAdapter)
2269 {
2270 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002271 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002272 return -ENODEV;
2273 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002274
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302275 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2276 status = wlan_hdd_validate_context(pHddCtx);
2277
2278 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002279 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302280 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2281 "%s: HDD context is not valid", __func__);
2282 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002283 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002284
2285 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2286 if (NULL == staAdapter)
2287 {
2288 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2289 if (NULL == staAdapter)
2290 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302291 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002292 "%s: HDD adapter context is Null", __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002293 return -ENODEV;
2294 }
2295 }
2296
2297 pScanInfo = &pHddCtx->scan_info;
2298
Jeff Johnson295189b2012-06-20 16:38:30 -07002299 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2300 __func__,pAdapter->device_mode);
2301
Jeff Johnsone7245742012-09-05 17:12:55 -07002302 if ((pScanInfo != NULL) && pScanInfo->mScanPending)
2303 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002304 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302305 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002306 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002307 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002308 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2309 if (!status)
2310 {
2311 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Jeff Johnson902c9832012-12-10 14:28:09 -08002312 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002313 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002314 VOS_ASSERT(pScanInfo->mScanPending);
2315 return 0;
2316 }
2317 }
2318
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002321 )
2322 {
2323 beacon_data_t *old;
2324
2325 old = pAdapter->sessionCtx.ap.beacon;
2326
2327 if (!old)
2328 return -ENOENT;
2329
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002331
2332 mutex_lock(&pHddCtx->sap_lock);
2333 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2334 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002335 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 {
2337 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2338
2339 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2340
2341 if (!VOS_IS_STATUS_SUCCESS(status))
2342 {
2343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2344 ("ERROR: HDD vos wait for single_event failed!!\n"));
2345 VOS_ASSERT(0);
2346 }
2347 }
2348 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2349 }
2350 mutex_unlock(&pHddCtx->sap_lock);
2351
2352 if(status != VOS_STATUS_SUCCESS)
2353 {
2354 hddLog(VOS_TRACE_LEVEL_FATAL,
2355 "%s:Error!!! Stopping the BSS\n",__func__);
2356 return -EINVAL;
2357 }
2358
Jeff Johnson4416a782013-03-25 14:17:50 -07002359 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2361 ==eHAL_STATUS_FAILURE)
2362 {
2363 hddLog(LOGE,
2364 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2365 }
2366
Jeff Johnson4416a782013-03-25 14:17:50 -07002367 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2369 eANI_BOOLEAN_FALSE) )
2370 {
2371 hddLog(LOGE,
2372 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2373 }
2374
2375 // Reset WNI_CFG_PROBE_RSP Flags
2376 wlan_hdd_reset_prob_rspies(pAdapter);
2377
2378 pAdapter->sessionCtx.ap.beacon = NULL;
2379 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002380#ifdef WLAN_FEATURE_P2P_DEBUG
2381 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2382 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2383 {
2384 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2385 "GO got removed");
2386 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2387 }
2388#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002389 }
2390 EXIT();
2391 return status;
2392}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002393
2394#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2395
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302396static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2397 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002398 struct cfg80211_ap_settings *params)
2399{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302400 hdd_adapter_t *pAdapter;
2401 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302402 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002403
2404 ENTER();
2405
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302406 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002407 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302408 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302409 "%s: Device is Null", __func__);
2410 return -ENODEV;
2411 }
2412
2413 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2414 if (NULL == pAdapter)
2415 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302416 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302417 "%s: HDD adapter is Null", __func__);
2418 return -ENODEV;
2419 }
2420
2421 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2422 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302423 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302424 "%s: HDD adapter magic is invalid", __func__);
2425 return -ENODEV;
2426 }
2427
2428 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302429 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302430
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302431 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302432 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2434 "%s: HDD context is not valid", __func__);
2435 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302436 }
2437
2438 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2439 __func__, pAdapter->device_mode);
2440
2441 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002442 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002443 )
2444 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302445 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002446
2447 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302448
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002449 if (old)
2450 return -EALREADY;
2451
2452 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2453
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302454 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002455 {
2456 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302457 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002458 return -EINVAL;
2459 }
2460 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002461#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002462 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2463#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2464 params->channel, params->channel_type);
2465#else
2466 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2467#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002468#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002469 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2470 params->ssid_len, params->hidden_ssid);
2471 }
2472
2473 EXIT();
2474 return status;
2475}
2476
2477
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302478static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002479 struct net_device *dev,
2480 struct cfg80211_beacon_data *params)
2481{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302482 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302483 hdd_context_t *pHddCtx;
2484 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002485
2486 ENTER();
2487
2488 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2489 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302490
2491 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2492 status = wlan_hdd_validate_context(pHddCtx);
2493
2494 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002495 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2497 "%s: HDD context is not valid", __func__);
2498 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002499 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002500
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302501 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002502 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302503 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002504 {
2505 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302506
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302508
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002509 if (!old)
2510 return -ENOENT;
2511
2512 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2513
2514 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302515 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002516 "%s: Error!!! Allocating the new beacon\n",__func__);
2517 return -EINVAL;
2518 }
2519
2520 pAdapter->sessionCtx.ap.beacon = new;
2521
2522 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2523 }
2524
2525 EXIT();
2526 return status;
2527}
2528
2529#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2530
Jeff Johnson295189b2012-06-20 16:38:30 -07002531
2532static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2533 struct net_device *dev,
2534 struct bss_parameters *params)
2535{
2536 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2537
2538 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302539
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2541 __func__,pAdapter->device_mode);
2542
2543 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302545 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 {
2547 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2548 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302549 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 {
2551 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002553 }
2554
2555 EXIT();
2556 return 0;
2557}
2558
2559/*
2560 * FUNCTION: wlan_hdd_cfg80211_change_iface
2561 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2562 */
2563int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2564 struct net_device *ndev,
2565 enum nl80211_iftype type,
2566 u32 *flags,
2567 struct vif_params *params
2568 )
2569{
2570 struct wireless_dev *wdev;
2571 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2572 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002573 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 tCsrRoamProfile *pRoamProfile = NULL;
2575 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302576 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 eMib_dot11DesiredBssType connectedBssType;
2578 VOS_STATUS status;
2579
2580 ENTER();
2581
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302582 status = wlan_hdd_validate_context(pHddCtx);
2583
2584 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2587 "%s: HDD context is not valid", __func__);
2588 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 }
2590
2591 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2592 __func__, pAdapter->device_mode);
2593
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302594 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 wdev = ndev->ieee80211_ptr;
2596
2597#ifdef WLAN_BTAMP_FEATURE
2598 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2599 (NL80211_IFTYPE_ADHOC == type)||
2600 (NL80211_IFTYPE_AP == type)||
2601 (NL80211_IFTYPE_P2P_GO == type))
2602 {
2603 pHddCtx->isAmpAllowed = VOS_FALSE;
2604 // stop AMP traffic
2605 status = WLANBAP_StopAmp();
2606 if(VOS_STATUS_SUCCESS != status )
2607 {
2608 pHddCtx->isAmpAllowed = VOS_TRUE;
2609 hddLog(VOS_TRACE_LEVEL_FATAL,
2610 "%s: Failed to stop AMP", __func__);
2611 return -EINVAL;
2612 }
2613 }
2614#endif //WLAN_BTAMP_FEATURE
2615 /* Reset the current device mode bit mask*/
2616 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2617
2618 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002620 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 )
2622 {
2623 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2624 pRoamProfile = &pWextState->roamProfile;
2625 LastBSSType = pRoamProfile->BSSType;
2626
2627 switch (type)
2628 {
2629 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 hddLog(VOS_TRACE_LEVEL_INFO,
2632 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2633 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002634#ifdef WLAN_FEATURE_11AC
2635 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2636 {
2637 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2638 }
2639#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302640 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002641 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002643 //Check for sub-string p2p to confirm its a p2p interface
2644 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302645 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002646 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2647 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2648 }
2649 else
2650 {
2651 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002653 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302654#ifdef FEATURE_WLAN_TDLS
2655 /* The open adapter for the p2p shall skip initializations in
2656 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2657 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2658 * tdls_init when the change_iface sets the device mode to
2659 * WLAN_HDD_P2P_CLIENT.
2660 */
2661
2662 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2663 {
2664 if (0 != wlan_hdd_tdls_init (pAdapter))
2665 {
2666 return -EINVAL;
2667 }
2668 }
2669#endif
2670
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 break;
2672 case NL80211_IFTYPE_ADHOC:
2673 hddLog(VOS_TRACE_LEVEL_INFO,
2674 "%s: setting interface Type to ADHOC", __func__);
2675 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2676 pRoamProfile->phyMode =
2677 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002678 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 wdev->iftype = type;
2680 break;
2681
2682 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 {
2685 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2686 "%s: setting interface Type to %s", __func__,
2687 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2688
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002689 //Cancel any remain on channel for GO mode
2690 if (NL80211_IFTYPE_P2P_GO == type)
2691 {
2692 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2693 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002694 if (NL80211_IFTYPE_AP == type)
2695 {
2696 /* As Loading WLAN Driver one interface being created for p2p device
2697 * address. This will take one HW STA and the max number of clients
2698 * that can connect to softAP will be reduced by one. so while changing
2699 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2700 * interface as it is not required in SoftAP mode.
2701 */
2702
2703 // Get P2P Adapter
2704 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2705
2706 if (pP2pAdapter)
2707 {
2708 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2709 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2710 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2711 }
2712 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302713#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002714
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302715 /* A Mutex Lock is introduced while changing the mode to
2716 * protect the concurrent access for the Adapters by TDLS
2717 * module.
2718 */
2719 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2720 {
2721 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2722 "%s: unable to lock list", __func__);
2723 return -EINVAL;
2724 }
2725#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 //De-init the adapter.
2727 hdd_stop_adapter( pHddCtx, pAdapter );
2728 hdd_deinit_adapter( pHddCtx, pAdapter );
2729 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2731 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302732#ifdef FEATURE_WLAN_TDLS
2733 mutex_unlock(&pHddCtx->tdls_lock);
2734#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002735
2736 //Disable BMPS and IMPS if enabled
2737 //before starting Go
2738 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2739 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302740 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002741 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2742 {
2743 //Fail to Exit BMPS
2744 VOS_ASSERT(0);
2745 }
2746 }
2747
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002748 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2749 (pConfig->apRandomBssidEnabled))
2750 {
2751 /* To meet Android requirements create a randomized
2752 MAC address of the form 02:1A:11:Fx:xx:xx */
2753 get_random_bytes(&ndev->dev_addr[3], 3);
2754 ndev->dev_addr[0] = 0x02;
2755 ndev->dev_addr[1] = 0x1A;
2756 ndev->dev_addr[2] = 0x11;
2757 ndev->dev_addr[3] |= 0xF0;
2758 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2759 VOS_MAC_ADDR_SIZE);
2760 pr_info("wlan: Generated HotSpot BSSID "
2761 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2762 ndev->dev_addr[0],
2763 ndev->dev_addr[1],
2764 ndev->dev_addr[2],
2765 ndev->dev_addr[3],
2766 ndev->dev_addr[4],
2767 ndev->dev_addr[5]);
2768 }
2769
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 hdd_set_ap_ops( pAdapter->dev );
2771
2772 status = hdd_init_ap_mode(pAdapter);
2773 if(status != VOS_STATUS_SUCCESS)
2774 {
2775 hddLog(VOS_TRACE_LEVEL_FATAL,
2776 "%s: Error initializing the ap mode", __func__);
2777 return -EINVAL;
2778 }
2779 hdd_set_conparam(1);
2780
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 /*interface type changed update in wiphy structure*/
2782 if(wdev)
2783 {
2784 wdev->iftype = type;
2785 pHddCtx->change_iface = type;
2786 }
2787 else
2788 {
2789 hddLog(VOS_TRACE_LEVEL_ERROR,
2790 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2791 return -EINVAL;
2792 }
2793 goto done;
2794 }
2795
2796 default:
2797 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2798 __func__);
2799 return -EOPNOTSUPP;
2800 }
2801 }
2802 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 )
2805 {
2806 switch(type)
2807 {
2808 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302811#ifdef FEATURE_WLAN_TDLS
2812
2813 /* A Mutex Lock is introduced while changing the mode to
2814 * protect the concurrent access for the Adapters by TDLS
2815 * module.
2816 */
2817 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2818 {
2819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2820 "%s: unable to lock list", __func__);
2821 return -EINVAL;
2822 }
2823#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002824 hdd_stop_adapter( pHddCtx, pAdapter );
2825 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002827 //Check for sub-string p2p to confirm its a p2p interface
2828 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002829 {
2830 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2831 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2832 }
2833 else
2834 {
2835 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 hdd_set_conparam(0);
2839 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2841 hdd_set_station_ops( pAdapter->dev );
2842 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302843#ifdef FEATURE_WLAN_TDLS
2844 mutex_unlock(&pHddCtx->tdls_lock);
2845#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 if( VOS_STATUS_SUCCESS != status )
2847 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002848 /* In case of JB, for P2P-GO, only change interface will be called,
2849 * This is the right place to enable back bmps_imps()
2850 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302851 if (pHddCtx->hdd_wlan_suspended)
2852 {
2853 hdd_set_pwrparams(pHddCtx);
2854 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002855 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 goto done;
2857 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2861 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 goto done;
2863 default:
2864 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2865 __func__);
2866 return -EOPNOTSUPP;
2867
2868 }
2869
2870 }
2871 else
2872 {
2873 return -EOPNOTSUPP;
2874 }
2875
2876
2877 if(pRoamProfile)
2878 {
2879 if ( LastBSSType != pRoamProfile->BSSType )
2880 {
2881 /*interface type changed update in wiphy structure*/
2882 wdev->iftype = type;
2883
2884 /*the BSS mode changed, We need to issue disconnect
2885 if connected or in IBSS disconnect state*/
2886 if ( hdd_connGetConnectedBssType(
2887 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2888 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2889 {
2890 /*need to issue a disconnect to CSR.*/
2891 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2892 if( eHAL_STATUS_SUCCESS ==
2893 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2894 pAdapter->sessionId,
2895 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2896 {
2897 wait_for_completion_interruptible_timeout(
2898 &pAdapter->disconnect_comp_var,
2899 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2900 }
2901 }
2902 }
2903 }
2904
2905done:
2906 /*set bitmask based on updated value*/
2907 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002908
2909 /* Only STA mode support TM now
2910 * all other mode, TM feature should be disabled */
2911 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2912 (~VOS_STA & pHddCtx->concurrency_mode) )
2913 {
2914 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2915 }
2916
Jeff Johnson295189b2012-06-20 16:38:30 -07002917#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302918 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002919 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2920 {
2921 //we are ok to do AMP
2922 pHddCtx->isAmpAllowed = VOS_TRUE;
2923 }
2924#endif //WLAN_BTAMP_FEATURE
2925 EXIT();
2926 return 0;
2927}
2928
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002929#ifdef FEATURE_WLAN_TDLS
2930static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2931 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2932{
2933 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2934 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2935 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002936 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002937
2938 ENTER();
2939
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302940 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002941 {
2942 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2943 "Invalid arguments");
2944 return -EINVAL;
2945 }
Hoonki Lee27511902013-03-14 18:19:06 -07002946
2947 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2948 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2949 {
2950 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2951 "%s: TDLS mode is disabled OR not enabled in FW."
2952 MAC_ADDRESS_STR " Request declined.",
2953 __func__, MAC_ADDR_ARRAY(mac));
2954 return -ENOTSUPP;
2955 }
2956
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002957 if (pHddCtx->isLogpInProgress)
2958 {
2959 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2960 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002961 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002962 return -EBUSY;
2963 }
2964
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302965 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002966
2967 if ( NULL == pTdlsPeer ) {
2968 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2969 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2970 __func__, MAC_ADDR_ARRAY(mac), update);
2971 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002972 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002973
2974 /* in add station, we accept existing valid staId if there is */
2975 if ((0 == update) &&
2976 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2977 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002978 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002979 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002980 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002981 " link_status %d. staId %d. add station ignored.",
2982 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2983 return 0;
2984 }
2985 /* in change station, we accept only when staId is valid */
2986 if ((1 == update) &&
2987 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2988 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2989 {
2990 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2991 "%s: " MAC_ADDRESS_STR
2992 " link status %d. staId %d. change station %s.",
2993 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
2994 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
2995 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002996 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002997
2998 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302999 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003000 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3002 "%s: " MAC_ADDRESS_STR
3003 " TDLS setup is ongoing. Request declined.",
3004 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003005 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003006 }
3007
3008 /* first to check if we reached to maximum supported TDLS peer.
3009 TODO: for now, return -EPERM looks working fine,
3010 but need to check if any other errno fit into this category.*/
3011 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3012 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3014 "%s: " MAC_ADDRESS_STR
3015 " TDLS Max peer already connected. Request declined.",
3016 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003017 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003018 }
3019 else
3020 {
3021 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303022 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003023 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003024 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003025 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3026 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3027 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003028 return -EPERM;
3029 }
3030 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003031 if (0 == update)
3032 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003033
Jeff Johnsond75fe012013-04-06 10:53:06 -07003034 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303035 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003036 {
3037 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3038 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003039 if(StaParams->htcap_present)
3040 {
3041 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3042 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3043 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3044 "ht_capa->extended_capabilities: %0x",
3045 StaParams->HTCap.extendedHtCapInfo);
3046 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003047 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3048 "params->capability: %0x",StaParams->capability);
3049 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3050 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003051 if(StaParams->vhtcap_present)
3052 {
3053 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3054 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3055 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3056 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3057 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003058 {
3059 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003060 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003061 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3062 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3063 "[%d]: %x ", i, StaParams->supported_rates[i]);
3064 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003065 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303066 else if ((1 == update) && (NULL == StaParams))
3067 {
3068 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3069 "%s : update is true, but staParams is NULL. Error!", __func__);
3070 return -EPERM;
3071 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003072
3073 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3074
3075 if (!update)
3076 {
3077 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3078 pAdapter->sessionId, mac);
3079 }
3080 else
3081 {
3082 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3083 pAdapter->sessionId, mac, StaParams);
3084 }
3085
3086 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3087 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3088
3089 if (!status)
3090 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003091 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003092 "%s: timeout waiting for tdls add station indication",
3093 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003094 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003095 }
3096 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3097 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003098 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003099 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003100 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003101 }
3102
3103 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003104
3105error:
3106 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3107 return -EPERM;
3108
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003109}
3110#endif
3111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112static int wlan_hdd_change_station(struct wiphy *wiphy,
3113 struct net_device *dev,
3114 u8 *mac,
3115 struct station_parameters *params)
3116{
3117 VOS_STATUS status = VOS_STATUS_SUCCESS;
3118 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303119 hdd_context_t *pHddCtx;
3120 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003122#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003123 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003124 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003125#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003126 ENTER();
3127
Gopichand Nakkala29149562013-05-10 21:43:41 +05303128 if ((NULL == pAdapter))
3129 {
3130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3131 "invalid adapter ");
3132 return -EINVAL;
3133 }
3134
3135 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3136 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3137
3138 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3139 {
3140 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3141 "invalid HDD state or HDD station context");
3142 return -EINVAL;
3143 }
3144
3145 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003146 {
3147 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3148 "%s:LOGP in Progress. Ignore!!!", __func__);
3149 return -EAGAIN;
3150 }
3151
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3153
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003154 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3155 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003157 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303159 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 WLANTL_STA_AUTHENTICATED);
3161
Gopichand Nakkala29149562013-05-10 21:43:41 +05303162 if (status != VOS_STATUS_SUCCESS)
3163 {
3164 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3165 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3166 return -EINVAL;
3167 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 }
3169 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003170 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3171 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303172#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003173 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3174 StaParams.capability = params->capability;
3175 StaParams.uapsd_queues = params->uapsd_queues;
3176 StaParams.max_sp = params->max_sp;
3177
3178 if (0 != params->ext_capab_len)
3179 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3180 sizeof(StaParams.extn_capability));
3181
3182 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003183 {
3184 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003185 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003186 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003187
3188 StaParams.supported_rates_len = params->supported_rates_len;
3189
3190 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3191 * The supported_rates array , for all the structures propogating till Add Sta
3192 * to the firmware has to be modified , if the supplicant (ieee80211) is
3193 * modified to send more rates.
3194 */
3195
3196 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3197 */
3198 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3199 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3200
3201 if (0 != StaParams.supported_rates_len) {
3202 int i = 0;
3203 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3204 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003205 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003206 "Supported Rates with Length %d", StaParams.supported_rates_len);
3207 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003208 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003209 "[%d]: %0x", i, StaParams.supported_rates[i]);
3210 }
3211
3212 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003213 {
3214 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003215 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003216 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003217
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003218 if (0 != params->ext_capab_len ) {
3219 /*Define A Macro : TODO Sunil*/
3220 if ((1<<4) & StaParams.extn_capability[3]) {
3221 isBufSta = 1;
3222 }
3223 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303224 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3225 params->max_sp, isBufSta);
3226 if (VOS_STATUS_SUCCESS != status) {
3227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3228 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3229 return -EINVAL;
3230 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003231 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3232
3233 if (VOS_STATUS_SUCCESS != status) {
3234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3235 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3236 return -EINVAL;
3237 }
3238 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003239#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303240 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003241 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 return status;
3243}
3244
3245/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 * FUNCTION: wlan_hdd_cfg80211_add_key
3247 * This function is used to initialize the key information
3248 */
3249#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003250static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 struct net_device *ndev,
3252 u8 key_index, bool pairwise,
3253 const u8 *mac_addr,
3254 struct key_params *params
3255 )
3256#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003257static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 struct net_device *ndev,
3259 u8 key_index, const u8 *mac_addr,
3260 struct key_params *params
3261 )
3262#endif
3263{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003264 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 tCsrRoamSetKey setKey;
3266 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303267 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003268 v_U32_t roamId= 0xFF;
3269 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 hdd_hostapd_state_t *pHostapdState;
3271 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003272 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303273 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003274
3275 ENTER();
3276
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303277 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3278 status = wlan_hdd_validate_context(pHddCtx);
3279
3280 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003281 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3283 "%s: HDD context is not valid", __func__);
3284 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003285 }
3286
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003287 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3288 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003289
3290 if (CSR_MAX_NUM_KEY <= key_index)
3291 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003292 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 key_index);
3294
3295 return -EINVAL;
3296 }
3297
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003298 if (CSR_MAX_KEY_LEN < params->key_len)
3299 {
3300 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3301 params->key_len);
3302
3303 return -EINVAL;
3304 }
3305
3306 hddLog(VOS_TRACE_LEVEL_INFO,
3307 "%s: called with key index = %d & key length %d",
3308 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309
3310 /*extract key idx, key len and key*/
3311 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3312 setKey.keyId = key_index;
3313 setKey.keyLength = params->key_len;
3314 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3315
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003316 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 {
3318 case WLAN_CIPHER_SUITE_WEP40:
3319 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3320 break;
3321
3322 case WLAN_CIPHER_SUITE_WEP104:
3323 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3324 break;
3325
3326 case WLAN_CIPHER_SUITE_TKIP:
3327 {
3328 u8 *pKey = &setKey.Key[0];
3329 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3330
3331 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3332
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003333 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003334
3335 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003336 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 |--------------|----------|----------|
3338 <---16bytes---><--8bytes--><--8bytes-->
3339
3340 */
3341 /*Sme expects the 32 bytes key to be in the below order
3342
3343 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003344 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 |--------------|----------|----------|
3346 <---16bytes---><--8bytes--><--8bytes-->
3347 */
3348 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003349 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003350
3351 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003352 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003353
3354 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003355 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003356
3357
3358 break;
3359 }
3360
3361 case WLAN_CIPHER_SUITE_CCMP:
3362 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3363 break;
3364
3365#ifdef FEATURE_WLAN_WAPI
3366 case WLAN_CIPHER_SUITE_SMS4:
3367 {
3368 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3369 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3370 params->key, params->key_len);
3371 return 0;
3372 }
3373#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003374
Jeff Johnson295189b2012-06-20 16:38:30 -07003375#ifdef FEATURE_WLAN_CCX
3376 case WLAN_CIPHER_SUITE_KRK:
3377 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3378 break;
3379#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003380
3381#ifdef WLAN_FEATURE_11W
3382 case WLAN_CIPHER_SUITE_AES_CMAC:
3383 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003384 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003385#endif
3386
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 default:
3388 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3389 __func__, params->cipher);
3390 return -EOPNOTSUPP;
3391 }
3392
3393 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3394 __func__, setKey.encType);
3395
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003396 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003397#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3398 (!pairwise)
3399#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003400 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003401#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003402 )
3403 {
3404 /* set group key*/
3405 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3406 "%s- %d: setting Broadcast key",
3407 __func__, __LINE__);
3408 setKey.keyDirection = eSIR_RX_ONLY;
3409 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3410 }
3411 else
3412 {
3413 /* set pairwise key*/
3414 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3415 "%s- %d: setting pairwise key",
3416 __func__, __LINE__);
3417 setKey.keyDirection = eSIR_TX_RX;
3418 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3419 }
3420 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3421 {
3422 setKey.keyDirection = eSIR_TX_RX;
3423 /*Set the group key*/
3424 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3425 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003426
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003427 if ( 0 != status )
3428 {
3429 hddLog(VOS_TRACE_LEVEL_ERROR,
3430 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3431 return -EINVAL;
3432 }
3433 /*Save the keys here and call sme_RoamSetKey for setting
3434 the PTK after peer joins the IBSS network*/
3435 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3436 &setKey, sizeof(tCsrRoamSetKey));
3437 return status;
3438 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303439 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3440 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3441 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003443 if( pHostapdState->bssState == BSS_START )
3444 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3446
3447 if ( status != eHAL_STATUS_SUCCESS )
3448 {
3449 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3450 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3451 __LINE__, status );
3452 }
3453 }
3454
3455 /* Saving WEP keys */
3456 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3457 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3458 {
3459 //Save the wep key in ap context. Issue setkey after the BSS is started.
3460 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3461 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3462 }
3463 else
3464 {
3465 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003466 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3468 }
3469 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003470 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3471 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 {
3473 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3474 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3475
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303476#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3477 if (!pairwise)
3478#else
3479 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3480#endif
3481 {
3482 /* set group key*/
3483 if (pHddStaCtx->roam_info.deferKeyComplete)
3484 {
3485 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3486 "%s- %d: Perform Set key Complete",
3487 __func__, __LINE__);
3488 hdd_PerformRoamSetKeyComplete(pAdapter);
3489 }
3490 }
3491
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3493
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003494 pWextState->roamProfile.Keys.defaultIndex = key_index;
3495
3496
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003497 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 params->key, params->key_len);
3499
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3502
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303503 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303505 __func__, setKey.peerMac[0], setKey.peerMac[1],
3506 setKey.peerMac[2], setKey.peerMac[3],
3507 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003508 setKey.keyDirection);
3509
3510 vos_status = wlan_hdd_check_ula_done(pAdapter);
3511
3512 if ( vos_status != VOS_STATUS_SUCCESS )
3513 {
3514 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3515 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3516 __LINE__, vos_status );
3517
3518 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3519
3520 return -EINVAL;
3521
3522 }
3523
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003524#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303525 /* The supplicant may attempt to set the PTK once pre-authentication
3526 is done. Save the key in the UMAC and include it in the ADD BSS
3527 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003528 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303529 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003530 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303531 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3532 "%s: Update PreAuth Key success", __func__);
3533 return 0;
3534 }
3535 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3536 {
3537 hddLog(VOS_TRACE_LEVEL_ERROR,
3538 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303539 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003540 }
3541#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003542
3543 /* issue set key request to SME*/
3544 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3545 pAdapter->sessionId, &setKey, &roamId );
3546
3547 if ( 0 != status )
3548 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303549 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3551 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3552 return -EINVAL;
3553 }
3554
3555
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303556 /* in case of IBSS as there was no information available about WEP keys during
3557 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303559 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3560 !( ( IW_AUTH_KEY_MGMT_802_1X
3561 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3563 )
3564 &&
3565 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3566 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3567 )
3568 )
3569 {
3570 setKey.keyDirection = eSIR_RX_ONLY;
3571 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3572
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303573 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303575 __func__, setKey.peerMac[0], setKey.peerMac[1],
3576 setKey.peerMac[2], setKey.peerMac[3],
3577 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003578 setKey.keyDirection);
3579
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303580 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 pAdapter->sessionId, &setKey, &roamId );
3582
3583 if ( 0 != status )
3584 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303585 hddLog(VOS_TRACE_LEVEL_ERROR,
3586 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 __func__, status);
3588 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3589 return -EINVAL;
3590 }
3591 }
3592 }
3593
3594 return 0;
3595}
3596
3597/*
3598 * FUNCTION: wlan_hdd_cfg80211_get_key
3599 * This function is used to get the key information
3600 */
3601#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303602static int wlan_hdd_cfg80211_get_key(
3603 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303605 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 const u8 *mac_addr, void *cookie,
3607 void (*callback)(void *cookie, struct key_params*)
3608 )
3609#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303610static int wlan_hdd_cfg80211_get_key(
3611 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 struct net_device *ndev,
3613 u8 key_index, const u8 *mac_addr, void *cookie,
3614 void (*callback)(void *cookie, struct key_params*)
3615 )
3616#endif
3617{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303618 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3620 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3621 struct key_params params;
3622
3623 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303624
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3626 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303627
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 memset(&params, 0, sizeof(params));
3629
3630 if (CSR_MAX_NUM_KEY <= key_index)
3631 {
3632 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003634
3635 switch(pRoamProfile->EncryptionType.encryptionType[0])
3636 {
3637 case eCSR_ENCRYPT_TYPE_NONE:
3638 params.cipher = IW_AUTH_CIPHER_NONE;
3639 break;
3640
3641 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3642 case eCSR_ENCRYPT_TYPE_WEP40:
3643 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3644 break;
3645
3646 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3647 case eCSR_ENCRYPT_TYPE_WEP104:
3648 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3649 break;
3650
3651 case eCSR_ENCRYPT_TYPE_TKIP:
3652 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3653 break;
3654
3655 case eCSR_ENCRYPT_TYPE_AES:
3656 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3657 break;
3658
3659 default:
3660 params.cipher = IW_AUTH_CIPHER_NONE;
3661 break;
3662 }
3663
3664 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3665 params.seq_len = 0;
3666 params.seq = NULL;
3667 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3668 callback(cookie, &params);
3669 return 0;
3670}
3671
3672/*
3673 * FUNCTION: wlan_hdd_cfg80211_del_key
3674 * This function is used to delete the key information
3675 */
3676#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303677static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303679 u8 key_index,
3680 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 const u8 *mac_addr
3682 )
3683#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303684static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 struct net_device *ndev,
3686 u8 key_index,
3687 const u8 *mac_addr
3688 )
3689#endif
3690{
3691 int status = 0;
3692
3693 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303694 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003695 //it is observed that this is invalidating peer
3696 //key index whenever re-key is done. This is affecting data link.
3697 //It should be ok to ignore del_key.
3698#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303699 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3700 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3702 tCsrRoamSetKey setKey;
3703 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303704
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 ENTER();
3706
3707 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3708 __func__,pAdapter->device_mode);
3709
3710 if (CSR_MAX_NUM_KEY <= key_index)
3711 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303712 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 key_index);
3714
3715 return -EINVAL;
3716 }
3717
3718 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3719 setKey.keyId = key_index;
3720
3721 if (mac_addr)
3722 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3723 else
3724 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3725
3726 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3727
3728 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303730 )
3731 {
3732
3733 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3735 if( pHostapdState->bssState == BSS_START)
3736 {
3737 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303738
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 if ( status != eHAL_STATUS_SUCCESS )
3740 {
3741 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3742 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3743 __LINE__, status );
3744 }
3745 }
3746 }
3747 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303748 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 )
3750 {
3751 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3752
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303753 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3754
3755 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303757 __func__, setKey.peerMac[0], setKey.peerMac[1],
3758 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303760 if(pAdapter->sessionCtx.station.conn_info.connState ==
3761 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303763 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303765
Jeff Johnson295189b2012-06-20 16:38:30 -07003766 if ( 0 != status )
3767 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303768 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 "%s: sme_RoamSetKey failure, returned %d",
3770 __func__, status);
3771 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3772 return -EINVAL;
3773 }
3774 }
3775 }
3776#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003777 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 return status;
3779}
3780
3781/*
3782 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3783 * This function is used to set the default tx key index
3784 */
3785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3786static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3787 struct net_device *ndev,
3788 u8 key_index,
3789 bool unicast, bool multicast)
3790#else
3791static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3792 struct net_device *ndev,
3793 u8 key_index)
3794#endif
3795{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303796 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303797 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303798 hdd_wext_state_t *pWextState;
3799 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303800 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003801
3802 ENTER();
3803
Gopichand Nakkala29149562013-05-10 21:43:41 +05303804 if ((NULL == pAdapter))
3805 {
3806 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3807 "invalid adapter");
3808 return -EINVAL;
3809 }
3810
3811 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3812 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3813
3814 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3815 {
3816 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3817 "invalid Wext state or HDD context");
3818 return -EINVAL;
3819 }
3820
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3822 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303823
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 if (CSR_MAX_NUM_KEY <= key_index)
3825 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303826 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 key_index);
3828
3829 return -EINVAL;
3830 }
3831
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303832 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3833 status = wlan_hdd_validate_context(pHddCtx);
3834
3835 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003836 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303837 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3838 "%s: HDD context is not valid", __func__);
3839 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003840 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303841
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303844 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003845 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303846 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003847 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303848 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 pWextState->roamProfile.EncryptionType.encryptionType[0])
3850 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303851 {
3852 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303854
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 tCsrRoamSetKey setKey;
3856 v_U32_t roamId= 0xFF;
3857 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303858
3859 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303861
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 Keys->defaultIndex = (u8)key_index;
3863 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3864 setKey.keyId = key_index;
3865 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303866
3867 vos_mem_copy(&setKey.Key[0],
3868 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003869 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303870
Gopichand Nakkala29149562013-05-10 21:43:41 +05303871 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303872
3873 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 &pHddStaCtx->conn_info.bssId[0],
3875 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303876
Gopichand Nakkala29149562013-05-10 21:43:41 +05303877 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3878 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3879 eCSR_ENCRYPT_TYPE_WEP104)
3880 {
3881 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3882 even though ap is configured for WEP-40 encryption. In this canse the key length
3883 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3884 type(104) and switching encryption type to 40*/
3885 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3886 eCSR_ENCRYPT_TYPE_WEP40;
3887 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3888 eCSR_ENCRYPT_TYPE_WEP40;
3889 }
3890
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303891 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303895 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303897
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 if ( 0 != status )
3899 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303900 hddLog(VOS_TRACE_LEVEL_ERROR,
3901 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 status);
3903 return -EINVAL;
3904 }
3905 }
3906 }
3907
3908 /* In SoftAp mode setting key direction for default mode */
3909 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3910 {
3911 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3912 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3913 (eCSR_ENCRYPT_TYPE_AES !=
3914 pWextState->roamProfile.EncryptionType.encryptionType[0])
3915 )
3916 {
3917 /* Saving key direction for default key index to TX default */
3918 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3919 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3920 }
3921 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303922
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 return status;
3924}
3925
Jeff Johnson295189b2012-06-20 16:38:30 -07003926/*
3927 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3928 * This function is used to inform the BSS details to nl80211 interface.
3929 */
3930static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3931 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3932{
3933 struct net_device *dev = pAdapter->dev;
3934 struct wireless_dev *wdev = dev->ieee80211_ptr;
3935 struct wiphy *wiphy = wdev->wiphy;
3936 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3937 int chan_no;
3938 int ie_length;
3939 const char *ie;
3940 unsigned int freq;
3941 struct ieee80211_channel *chan;
3942 int rssi = 0;
3943 struct cfg80211_bss *bss = NULL;
3944
3945 ENTER();
3946
3947 if( NULL == pBssDesc )
3948 {
3949 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3950 return bss;
3951 }
3952
3953 chan_no = pBssDesc->channelId;
3954 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3955 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3956
3957 if( NULL == ie )
3958 {
3959 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3960 return bss;
3961 }
3962
3963#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3964 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3965 {
3966 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3967 }
3968 else
3969 {
3970 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3971 }
3972#else
3973 freq = ieee80211_channel_to_frequency(chan_no);
3974#endif
3975
3976 chan = __ieee80211_get_channel(wiphy, freq);
3977
3978 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3979 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3980 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3981 if (bss == NULL)
3982 {
3983 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3984
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303985 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3986 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 pBssDesc->capabilityInfo,
3988 pBssDesc->beaconInterval, ie, ie_length,
3989 rssi, GFP_KERNEL ));
3990}
3991 else
3992 {
3993 return bss;
3994 }
3995}
3996
3997
3998
3999/*
4000 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4001 * This function is used to inform the BSS details to nl80211 interface.
4002 */
4003struct cfg80211_bss*
4004wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4005 tSirBssDescription *bss_desc
4006 )
4007{
4008 /*
4009 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4010 already exists in bss data base of cfg80211 for that particular BSS ID.
4011 Using cfg80211_inform_bss_frame to update the bss entry instead of
4012 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4013 now there is no possibility to get the mgmt(probe response) frame from PE,
4014 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4015 cfg80211_inform_bss_frame.
4016 */
4017 struct net_device *dev = pAdapter->dev;
4018 struct wireless_dev *wdev = dev->ieee80211_ptr;
4019 struct wiphy *wiphy = wdev->wiphy;
4020 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004021#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4022 qcom_ie_age *qie_age = NULL;
4023 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4024#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004026#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 const char *ie =
4028 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4029 unsigned int freq;
4030 struct ieee80211_channel *chan;
4031 struct ieee80211_mgmt *mgmt =
4032 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4033 struct cfg80211_bss *bss_status = NULL;
4034 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4035 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004036#ifdef WLAN_OPEN_SOURCE
4037 struct timespec ts;
4038#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004039
4040 ENTER();
4041
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004042 if (!mgmt)
4043 return NULL;
4044
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004046
4047#ifdef WLAN_OPEN_SOURCE
4048 /* Android does not want the timestamp from the frame.
4049 Instead it wants a monotonic increasing value */
4050 get_monotonic_boottime(&ts);
4051 mgmt->u.probe_resp.timestamp =
4052 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4053#else
4054 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4056 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004057
4058#endif
4059
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4061 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004062
4063#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4064 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4065 /* Assuming this is the last IE, copy at the end */
4066 ie_length -=sizeof(qcom_ie_age);
4067 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4068 qie_age->element_id = QCOM_VENDOR_IE_ID;
4069 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4070 qie_age->oui_1 = QCOM_OUI1;
4071 qie_age->oui_2 = QCOM_OUI2;
4072 qie_age->oui_3 = QCOM_OUI3;
4073 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4074 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4075#endif
4076
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304078 if (bss_desc->fProbeRsp)
4079 {
4080 mgmt->frame_control |=
4081 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4082 }
4083 else
4084 {
4085 mgmt->frame_control |=
4086 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004088
4089#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304090 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4092 {
4093 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4094 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304095 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004096 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4097
4098 {
4099 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4100 }
4101 else
4102 {
4103 kfree(mgmt);
4104 return NULL;
4105 }
4106#else
4107 freq = ieee80211_channel_to_frequency(chan_no);
4108#endif
4109 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004110 /*when the band is changed on the fly using the GUI, three things are done
4111 * 1. scan abort 2.flush scan results from cache 3.update the band with the new band user specified(refer to the hdd_setBand_helper function)
4112 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4113 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4114 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4115 * and discards the channels correponding to previous band and calls back with zero bss results.
4116 * but if the time between band update and scan done callback is very small then band change will not reflect in SME and SME reports to HDD
4117 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4118 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4119 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4120 * So drop the bss and continue to next bss.
4121 */
4122 if(chan == NULL)
4123 {
4124 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004125 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004126 return NULL;
4127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304129 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 * */
4131 if (( eConnectionState_Associated ==
4132 pAdapter->sessionCtx.station.conn_info.connState ) &&
4133 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4134 pAdapter->sessionCtx.station.conn_info.bssId,
4135 WNI_CFG_BSSID_LEN)))
4136 {
4137 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4138 rssi = (pAdapter->rssi * 100);
4139 }
4140 else
4141 {
4142 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4143 }
4144
4145 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4146 frame_len, rssi, GFP_KERNEL);
4147 kfree(mgmt);
4148 return bss_status;
4149}
4150
4151/*
4152 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4153 * This function is used to update the BSS data base of CFG8011
4154 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304155struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 tCsrRoamInfo *pRoamInfo
4157 )
4158{
4159 tCsrRoamConnectedProfile roamProfile;
4160 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4161 struct cfg80211_bss *bss = NULL;
4162
4163 ENTER();
4164
4165 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4166 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4167
4168 if (NULL != roamProfile.pBssDesc)
4169 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304170 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 &roamProfile);
4172
4173 if (NULL == bss)
4174 {
4175 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4176 __func__);
4177 }
4178
4179 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4180 }
4181 else
4182 {
4183 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4184 __func__);
4185 }
4186 return bss;
4187}
4188
4189/*
4190 * FUNCTION: wlan_hdd_cfg80211_update_bss
4191 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304192static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4193 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004194 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304195{
Jeff Johnson295189b2012-06-20 16:38:30 -07004196 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4197 tCsrScanResultInfo *pScanResult;
4198 eHalStatus status = 0;
4199 tScanResultHandle pResult;
4200 struct cfg80211_bss *bss_status = NULL;
4201
4202 ENTER();
4203
4204 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4205 {
4206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
4207 return -EAGAIN;
4208 }
4209
4210 /*
4211 * start getting scan results and populate cgf80211 BSS database
4212 */
4213 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4214
4215 /* no scan results */
4216 if (NULL == pResult)
4217 {
4218 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4219 return status;
4220 }
4221
4222 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4223
4224 while (pScanResult)
4225 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304226 /*
4227 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4228 * entry already exists in bss data base of cfg80211 for that
4229 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4230 * bss entry instead of cfg80211_inform_bss, But this call expects
4231 * mgmt packet as input. As of now there is no possibility to get
4232 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 * ieee80211_mgmt(probe response) and passing to c
4234 * fg80211_inform_bss_frame.
4235 * */
4236
4237 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4238 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240
4241 if (NULL == bss_status)
4242 {
4243 hddLog(VOS_TRACE_LEVEL_INFO,
4244 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4245 }
4246 else
4247 {
Yue Maf49ba872013-08-19 12:04:25 -07004248 cfg80211_put_bss(
4249#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4250 wiphy,
4251#endif
4252 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 }
4254
4255 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4256 }
4257
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304258 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004259
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304260 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004261}
4262
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004263void
4264hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4265{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304266 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004267 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4268 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4269 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004270} /****** end hddPrintMacAddr() ******/
4271
4272void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004273hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004274{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304275 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004276 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4277 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4278 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4279 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004280} /****** end hddPrintPmkId() ******/
4281
4282//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4283//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4284
4285//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4286//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4287
4288#define dump_bssid(bssid) \
4289 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004290 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4291 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4292 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004293 }
4294
4295#define dump_pmkid(pMac, pmkid) \
4296 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004297 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4298 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4299 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004300 }
4301
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004302#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004303/*
4304 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4305 * This function is used to notify the supplicant of a new PMKSA candidate.
4306 */
4307int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304308 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004309 int index, bool preauth )
4310{
Jeff Johnsone7245742012-09-05 17:12:55 -07004311#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004312 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004313 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004314
4315 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004316 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004317
4318 if( NULL == pRoamInfo )
4319 {
4320 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4321 return -EINVAL;
4322 }
4323
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004324 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4325 {
4326 dump_bssid(pRoamInfo->bssid);
4327 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004328 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004329 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004330#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304331 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004332}
4333#endif //FEATURE_WLAN_LFR
4334
Yue Maef608272013-04-08 23:09:17 -07004335#ifdef FEATURE_WLAN_LFR_METRICS
4336/*
4337 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4338 * 802.11r/LFR metrics reporting function to report preauth initiation
4339 *
4340 */
4341#define MAX_LFR_METRICS_EVENT_LENGTH 100
4342VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4343 tCsrRoamInfo *pRoamInfo)
4344{
4345 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4346 union iwreq_data wrqu;
4347
4348 ENTER();
4349
4350 if (NULL == pAdapter)
4351 {
4352 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4353 return VOS_STATUS_E_FAILURE;
4354 }
4355
4356 /* create the event */
4357 memset(&wrqu, 0, sizeof(wrqu));
4358 memset(metrics_notification, 0, sizeof(metrics_notification));
4359
4360 wrqu.data.pointer = metrics_notification;
4361 wrqu.data.length = scnprintf(metrics_notification,
4362 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4363 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4364
4365 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4366
4367 EXIT();
4368
4369 return VOS_STATUS_SUCCESS;
4370}
4371
4372/*
4373 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4374 * 802.11r/LFR metrics reporting function to report preauth completion
4375 * or failure
4376 */
4377VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4378 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4379{
4380 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4381 union iwreq_data wrqu;
4382
4383 ENTER();
4384
4385 if (NULL == pAdapter)
4386 {
4387 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4388 return VOS_STATUS_E_FAILURE;
4389 }
4390
4391 /* create the event */
4392 memset(&wrqu, 0, sizeof(wrqu));
4393 memset(metrics_notification, 0, sizeof(metrics_notification));
4394
4395 scnprintf(metrics_notification, sizeof(metrics_notification),
4396 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4397 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4398
4399 if (1 == preauth_status)
4400 strncat(metrics_notification, " TRUE", 5);
4401 else
4402 strncat(metrics_notification, " FALSE", 6);
4403
4404 wrqu.data.pointer = metrics_notification;
4405 wrqu.data.length = strlen(metrics_notification);
4406
4407 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4408
4409 EXIT();
4410
4411 return VOS_STATUS_SUCCESS;
4412}
4413
4414/*
4415 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4416 * 802.11r/LFR metrics reporting function to report handover initiation
4417 *
4418 */
4419VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4420 tCsrRoamInfo *pRoamInfo)
4421{
4422 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4423 union iwreq_data wrqu;
4424
4425 ENTER();
4426
4427 if (NULL == pAdapter)
4428 {
4429 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4430 return VOS_STATUS_E_FAILURE;
4431 }
4432
4433 /* create the event */
4434 memset(&wrqu, 0, sizeof(wrqu));
4435 memset(metrics_notification, 0, sizeof(metrics_notification));
4436
4437 wrqu.data.pointer = metrics_notification;
4438 wrqu.data.length = scnprintf(metrics_notification,
4439 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4440 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4441
4442 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4443
4444 EXIT();
4445
4446 return VOS_STATUS_SUCCESS;
4447}
4448#endif
4449
Jeff Johnson295189b2012-06-20 16:38:30 -07004450/*
4451 * FUNCTION: hdd_cfg80211_scan_done_callback
4452 * scanning callback function, called after finishing scan
4453 *
4454 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304455static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4457{
4458 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304459 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004461 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4462 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 struct cfg80211_scan_request *req = NULL;
4464 int ret = 0;
4465
4466 ENTER();
4467
4468 hddLog(VOS_TRACE_LEVEL_INFO,
4469 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304470 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 __func__, halHandle, pContext, (int) scanId, (int) status);
4472
4473 //Block on scan req completion variable. Can't wait forever though.
4474 ret = wait_for_completion_interruptible_timeout(
4475 &pScanInfo->scan_req_completion_event,
4476 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4477 if (!ret)
4478 {
4479 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004480 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 }
4482
Yue Maef608272013-04-08 23:09:17 -07004483 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 {
4485 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004486 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 }
4488
4489 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304490 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 {
4492 hddLog(VOS_TRACE_LEVEL_INFO,
4493 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304494 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 (int) scanId);
4496 }
4497
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304498 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 pAdapter);
4500
4501 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304502 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004503
4504
4505 /* If any client wait scan result through WEXT
4506 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004507 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 {
4509 /* The other scan request waiting for current scan finish
4510 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004511 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004512 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004513 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 }
4515 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004516 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 {
4518 struct net_device *dev = pAdapter->dev;
4519 union iwreq_data wrqu;
4520 int we_event;
4521 char *msg;
4522
4523 memset(&wrqu, '\0', sizeof(wrqu));
4524 we_event = SIOCGIWSCAN;
4525 msg = NULL;
4526 wireless_send_event(dev, we_event, &wrqu, msg);
4527 }
4528 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004529 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004530
4531 /* Get the Scan Req */
4532 req = pAdapter->request;
4533
4534 if (!req)
4535 {
4536 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004537 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004538 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 }
4540
4541 /*
4542 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304543 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004544 req->n_ssids = 0;
4545 req->n_channels = 0;
4546 req->ie = 0;
4547
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004549 /* Scan is no longer pending */
4550 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004551
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004552 /*
4553 * cfg80211_scan_done informing NL80211 about completion
4554 * of scanning
4555 */
4556 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004557 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004558
Jeff Johnsone7245742012-09-05 17:12:55 -07004559allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004560 /* release the wake lock at the end of the scan*/
4561 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004562
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004563 /* Acquire wakelock to handle the case where APP's tries to suspend
4564 * immediatly after the driver gets connect request(i.e after scan)
4565 * from supplicant, this result in app's is suspending and not able
4566 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004567 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004568
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004569#ifdef FEATURE_WLAN_TDLS
4570 wlan_hdd_tdls_scan_done_callback(pAdapter);
4571#endif
4572
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 EXIT();
4574 return 0;
4575}
4576
4577/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004578 * FUNCTION: hdd_isScanAllowed
4579 * Go through each adapter and check if scan allowed
4580 *
4581 */
4582v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4583{
4584 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4585 hdd_station_ctx_t *pHddStaCtx = NULL;
4586 hdd_adapter_t *pAdapter = NULL;
4587 VOS_STATUS status = 0;
4588 v_U8_t staId = 0;
4589 v_U8_t *staMac = NULL;
4590
4591 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4592
4593 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4594 {
4595 pAdapter = pAdapterNode->pAdapter;
4596
4597 if( pAdapter )
4598 {
4599 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304600 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004601 __func__, pAdapter->device_mode);
4602 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4603 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4604 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4605 {
4606 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4607 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4608 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4609 {
4610 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4611 hddLog(VOS_TRACE_LEVEL_ERROR,
4612 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304613 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004614 staMac[0], staMac[1], staMac[2],
4615 staMac[3], staMac[4], staMac[5]);
4616 return VOS_FALSE;
4617 }
4618 }
4619 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4620 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4621 {
4622 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4623 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304624 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004625 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4626 {
4627 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4628
4629 hddLog(VOS_TRACE_LEVEL_ERROR,
4630 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304631 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004632 staMac[0], staMac[1], staMac[2],
4633 staMac[3], staMac[4], staMac[5]);
4634 return VOS_FALSE;
4635 }
4636 }
4637 }
4638 }
4639 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4640 pAdapterNode = pNext;
4641 }
4642 hddLog(VOS_TRACE_LEVEL_INFO,
4643 "%s: Scan allowed", __func__);
4644 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304645}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004646
4647/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 * FUNCTION: wlan_hdd_cfg80211_scan
4649 * this scan respond to scan trigger and update cfg80211 scan database
4650 * later, scan dump command can be used to recieve scan results
4651 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004652int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4653#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4654 struct net_device *dev,
4655#endif
4656 struct cfg80211_scan_request *request)
4657{
4658#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4659 struct net_device *dev = request->wdev->netdev;
4660#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304661 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4663 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304664 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004665 tCsrScanRequest scanRequest;
4666 tANI_U8 *channelList = NULL, i;
4667 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304668 int status;
4669 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004671
4672 ENTER();
4673
4674 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4675 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004676
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304677 status = wlan_hdd_validate_context(pHddCtx);
4678
4679 if (0 != status)
4680 {
4681 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4682 "%s: HDD context is not valid", __func__);
4683 return status;
4684 }
4685
4686 cfg_param = pHddCtx->cfg_ini;
4687 pScanInfo = &pHddCtx->scan_info;
4688
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004689 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004690 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004691 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004692 {
4693 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004694 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4695 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004696 return -EBUSY;
4697 }
4698
Jeff Johnson295189b2012-06-20 16:38:30 -07004699#ifdef WLAN_BTAMP_FEATURE
4700 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004701 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004702 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004703 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 "%s: No scanning when AMP is on", __func__);
4705 return -EOPNOTSUPP;
4706 }
4707#endif
4708 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004709 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004711 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 "%s: Not scanning on device_mode = %d",
4713 __func__, pAdapter->device_mode);
4714 return -EOPNOTSUPP;
4715 }
4716
4717 if (TRUE == pScanInfo->mScanPending)
4718 {
4719 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004720 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 }
4722
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304723 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004724 //Channel and action frame is pending
4725 //Otherwise Cancel Remain On Channel and allow Scan
4726 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004727 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004728 {
4729 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4730 return -EBUSY;
4731 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004732#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004733 /* if tdls disagree scan right now, return immediately.
4734 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4735 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4736 */
4737 status = wlan_hdd_tdls_scan_callback (pAdapter,
4738 wiphy,
4739#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4740 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004741#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004742 request);
4743 if(status <= 0)
4744 {
4745 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4746 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004747 }
4748#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004749
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4751 {
4752 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004753 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4757 {
4758 hddLog(VOS_TRACE_LEVEL_WARN,
4759 "%s: MAX TM Level Scan not allowed", __func__);
4760 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304761 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 }
4763 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4764
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004765 /* Check if scan is allowed at this point of time.
4766 */
4767 if (!hdd_isScanAllowed(pHddCtx))
4768 {
4769 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4770 return -EBUSY;
4771 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304772
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4774
4775 if (NULL != request)
4776 {
4777 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304778 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004779
4780 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4781 * Becasue of this, driver is assuming that this is not wildcard scan and so
4782 * is not aging out the scan results.
4783 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004784 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 {
4786 request->n_ssids = 0;
4787 }
4788
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004789 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 {
4791 tCsrSSIDInfo *SsidInfo;
4792 int j;
4793 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4794 /* Allocate num_ssid tCsrSSIDInfo structure */
4795 SsidInfo = scanRequest.SSIDs.SSIDList =
4796 ( tCsrSSIDInfo *)vos_mem_malloc(
4797 request->n_ssids*sizeof(tCsrSSIDInfo));
4798
4799 if(NULL == scanRequest.SSIDs.SSIDList)
4800 {
4801 hddLog(VOS_TRACE_LEVEL_ERROR,
4802 "memory alloc failed SSIDInfo buffer");
4803 return -ENOMEM;
4804 }
4805
4806 /* copy all the ssid's and their length */
4807 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4808 {
4809 /* get the ssid length */
4810 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4811 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4812 SsidInfo->SSID.length);
4813 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4814 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4815 j, SsidInfo->SSID.ssId);
4816 }
4817 /* set the scan type to active */
4818 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4819 }
4820 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4821 {
4822 /* set the scan type to active */
4823 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4824 }
4825 else
4826 {
4827 /*Set the scan type to default type, in this case it is ACTIVE*/
4828 scanRequest.scanType = pScanInfo->scan_mode;
4829 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304830 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4832 }
4833 else
4834 {
4835 /* set the scan type to active */
4836 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4837 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4838
4839 /* set min and max channel time to zero */
4840 scanRequest.minChnTime = 0;
4841 scanRequest.maxChnTime = 0;
4842 }
4843
4844 /* set BSSType to default type */
4845 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4846
4847 /*TODO: scan the requested channels only*/
4848
4849 /*Right now scanning all the channels */
4850 if( request )
4851 {
4852 if( request->n_channels )
4853 {
4854 channelList = vos_mem_malloc( request->n_channels );
4855 if( NULL == channelList )
4856 {
4857 status = -ENOMEM;
4858 goto free_mem;
4859 }
4860
4861 for( i = 0 ; i < request->n_channels ; i++ )
4862 channelList[i] = request->channels[i]->hw_value;
4863 }
4864
4865 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4866 scanRequest.ChannelInfo.ChannelList = channelList;
4867
4868 /* set requestType to full scan */
4869 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304870
4871 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004872 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304873 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004874 */
4875
4876 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304877 * and in that case driver shoudnt flush scan results. If
4878 * driver flushes the scan results here and unfortunately if
4879 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004880 * fails which is not desired
4881 */
4882
4883 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4884 {
4885 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4886 pAdapter->sessionId );
4887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004888
4889 if( request->ie_len )
4890 {
4891 /* save this for future association (join requires this) */
4892 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4893 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4894 pScanInfo->scanAddIE.length = request->ie_len;
4895
4896 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004897 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4898 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004899 )
4900 {
4901 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4902 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4903 }
4904
4905 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4906 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4907
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4909 request->ie_len);
4910 if (pP2pIe != NULL)
4911 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004912#ifdef WLAN_FEATURE_P2P_DEBUG
4913 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4914 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4915 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4916 {
4917 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4918 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4919 "Go nego completed to Connection is started");
4920 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4921 "for 8way Handshake");
4922 }
4923 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4924 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4925 {
4926 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4927 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4928 "Disconnected state to Connection is started");
4929 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4930 "for 4way Handshake");
4931 }
4932#endif
4933
Jeff Johnsone7245742012-09-05 17:12:55 -07004934 /* no_cck will be set during p2p find to disable 11b rates */
4935 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004937 hddLog(VOS_TRACE_LEVEL_INFO,
4938 "%s: This is a P2P Search", __func__);
4939 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004940
Jeff Johnsone7245742012-09-05 17:12:55 -07004941 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4942 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004943 /* set requestType to P2P Discovery */
4944 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004945 }
4946
4947 /*
4948 Skip Dfs Channel in case of P2P Search
4949 if it is set in ini file
4950 */
4951 if(cfg_param->skipDfsChnlInP2pSearch)
4952 {
4953 scanRequest.skipDfsChnlInP2pSearch = 1;
4954 }
4955 else
4956 {
4957 scanRequest.skipDfsChnlInP2pSearch = 0;
4958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004959
Jeff Johnson295189b2012-06-20 16:38:30 -07004960 }
4961 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 }
4963 }
4964
4965 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4966
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004967 /* acquire the wakelock to avoid the apps suspend during the scan. To
4968 * address the following issues.
4969 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4970 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4971 * for long time, this result in apps running at full power for long time.
4972 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4973 * be stuck in full power because of resume BMPS
4974 */
4975 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004976
4977 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 pAdapter->sessionId, &scanRequest, &scanId,
4979 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004980
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 if (eHAL_STATUS_SUCCESS != status)
4982 {
4983 hddLog(VOS_TRACE_LEVEL_ERROR,
4984 "%s: sme_ScanRequest returned error %d", __func__, status);
4985 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004986 if(eHAL_STATUS_RESOURCES == status)
4987 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004988 hddLog(VOS_TRACE_LEVEL_INFO, "%s: HO is in progress.So defer the scan by informing busy",__func__);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004989 status = -EBUSY;
4990 } else {
4991 status = -EIO;
4992 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004993 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 goto free_mem;
4995 }
4996
4997 pScanInfo->mScanPending = TRUE;
4998 pAdapter->request = request;
4999 pScanInfo->scanId = scanId;
5000
5001 complete(&pScanInfo->scan_req_completion_event);
5002
5003free_mem:
5004 if( scanRequest.SSIDs.SSIDList )
5005 {
5006 vos_mem_free(scanRequest.SSIDs.SSIDList);
5007 }
5008
5009 if( channelList )
5010 vos_mem_free( channelList );
5011
5012 EXIT();
5013
5014 return status;
5015}
5016
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005017
5018void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5019{
5020 v_U8_t iniDot11Mode =
5021 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5022 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5023
5024 switch ( iniDot11Mode )
5025 {
5026 case eHDD_DOT11_MODE_AUTO:
5027 case eHDD_DOT11_MODE_11ac:
5028 case eHDD_DOT11_MODE_11ac_ONLY:
5029#ifdef WLAN_FEATURE_11AC
5030 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5031#else
5032 hddDot11Mode = eHDD_DOT11_MODE_11n;
5033#endif
5034 break;
5035 case eHDD_DOT11_MODE_11n:
5036 case eHDD_DOT11_MODE_11n_ONLY:
5037 hddDot11Mode = eHDD_DOT11_MODE_11n;
5038 break;
5039 default:
5040 hddDot11Mode = iniDot11Mode;
5041 break;
5042 }
5043 /* This call decides required channel bonding mode */
5044 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5045 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5046 operationChannel);
5047}
5048
Jeff Johnson295189b2012-06-20 16:38:30 -07005049/*
5050 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305051 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005052 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305053int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005054 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005055{
5056 int status = 0;
5057 hdd_wext_state_t *pWextState;
5058 v_U32_t roamId;
5059 tCsrRoamProfile *pRoamProfile;
5060 eMib_dot11DesiredBssType connectedBssType;
5061 eCsrAuthType RSNAuthType;
5062
5063 ENTER();
5064
5065 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305066
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5068 {
5069 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5070 return -EINVAL;
5071 }
5072
5073 pRoamProfile = &pWextState->roamProfile;
5074
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305075 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005077 int ret = 0;
5078 hdd_station_ctx_t *pHddStaCtx;
5079 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5080 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5081
5082 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5083 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5084 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 {
5086 /* Issue disconnect to CSR */
5087 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305088 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5090 pAdapter->sessionId,
5091 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5092 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005093 ret = wait_for_completion_interruptible_timeout(
5094 &pAdapter->disconnect_comp_var,
5095 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5096 if (0 == ret)
5097 {
5098 VOS_ASSERT(0);
5099 }
5100 }
5101 }
5102 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5103 {
5104 ret = wait_for_completion_interruptible_timeout(
5105 &pAdapter->disconnect_comp_var,
5106 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5107 if (0 == ret)
5108 {
5109 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005110 }
5111 }
5112
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305113 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5115 {
5116 /*QoS not enabled in cfg file*/
5117 pRoamProfile->uapsd_mask = 0;
5118 }
5119 else
5120 {
5121 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305122 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5124 }
5125
5126 pRoamProfile->SSIDs.numOfSSIDs = 1;
5127 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5128 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305129 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5131 ssid, ssid_len);
5132
5133 if (bssid)
5134 {
5135 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5136 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5137 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305138 /* Save BSSID in seperate variable as well, as RoamProfile
5139 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 case of join failure we should send valid BSSID to supplicant
5141 */
5142 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5143 WNI_CFG_BSSID_LEN);
5144 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005145 else
5146 {
5147 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005149
5150 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5151 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305152 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 /*set gen ie*/
5154 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5155 /*set auth*/
5156 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005158#ifdef FEATURE_WLAN_WAPI
5159 if (pAdapter->wapi_info.nWapiMode)
5160 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005161 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 switch (pAdapter->wapi_info.wapiAuthMode)
5163 {
5164 case WAPI_AUTH_MODE_PSK:
5165 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005166 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005167 pAdapter->wapi_info.wapiAuthMode);
5168 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5169 break;
5170 }
5171 case WAPI_AUTH_MODE_CERT:
5172 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005173 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 pAdapter->wapi_info.wapiAuthMode);
5175 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5176 break;
5177 }
5178 } // End of switch
5179 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5180 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5181 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005182 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005183 pRoamProfile->AuthType.numEntries = 1;
5184 pRoamProfile->EncryptionType.numEntries = 1;
5185 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5186 pRoamProfile->mcEncryptionType.numEntries = 1;
5187 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5188 }
5189 }
5190#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305191#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305192 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305193 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5194 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5195 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305196 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5197 sizeof (tSirGtkOffloadParams));
5198 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305199 }
5200#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005201 pRoamProfile->csrPersona = pAdapter->device_mode;
5202
Jeff Johnson32d95a32012-09-10 13:15:23 -07005203 if( operatingChannel )
5204 {
5205 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5206 pRoamProfile->ChannelInfo.numOfChannels = 1;
5207 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005208 else
5209 {
5210 pRoamProfile->ChannelInfo.ChannelList = NULL;
5211 pRoamProfile->ChannelInfo.numOfChannels = 0;
5212 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005213 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5214 {
5215 hdd_select_cbmode(pAdapter,operatingChannel);
5216 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005217 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5218 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305219 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005220 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005221 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5222 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305223 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5224 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005225 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5226 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305227
5228 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005229 pAdapter->sessionId, pRoamProfile, &roamId);
5230
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305231 if ((eHAL_STATUS_SUCCESS != status) &&
5232 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5233 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305234
5235 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005236 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5237 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5238 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305239 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005240 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305241 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005242
5243 pRoamProfile->ChannelInfo.ChannelList = NULL;
5244 pRoamProfile->ChannelInfo.numOfChannels = 0;
5245
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 }
5247 else
5248 {
5249 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5250 return -EINVAL;
5251 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005252 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 return status;
5254}
5255
5256/*
5257 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5258 * This function is used to set the authentication type (OPEN/SHARED).
5259 *
5260 */
5261static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5262 enum nl80211_auth_type auth_type)
5263{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305264 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5266
5267 ENTER();
5268
5269 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305270 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305273 hddLog(VOS_TRACE_LEVEL_INFO,
5274 "%s: set authentication type to AUTOSWITCH", __func__);
5275 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5276 break;
5277
5278 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005279#ifdef WLAN_FEATURE_VOWIFI_11R
5280 case NL80211_AUTHTYPE_FT:
5281#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305282 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005283 "%s: set authentication type to OPEN", __func__);
5284 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5285 break;
5286
5287 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305288 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005289 "%s: set authentication type to SHARED", __func__);
5290 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5291 break;
5292#ifdef FEATURE_WLAN_CCX
5293 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305294 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005295 "%s: set authentication type to CCKM WPA", __func__);
5296 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5297 break;
5298#endif
5299
5300
5301 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305302 hddLog(VOS_TRACE_LEVEL_ERROR,
5303 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 auth_type);
5305 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5306 return -EINVAL;
5307 }
5308
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305309 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005310 pHddStaCtx->conn_info.authType;
5311 return 0;
5312}
5313
5314/*
5315 * FUNCTION: wlan_hdd_set_akm_suite
5316 * This function is used to set the key mgmt type(PSK/8021x).
5317 *
5318 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305319static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 u32 key_mgmt
5321 )
5322{
5323 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5324 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305325
Jeff Johnson295189b2012-06-20 16:38:30 -07005326 /*set key mgmt type*/
5327 switch(key_mgmt)
5328 {
5329 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305330#ifdef WLAN_FEATURE_VOWIFI_11R
5331 case WLAN_AKM_SUITE_FT_PSK:
5332#endif
5333 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 __func__);
5335 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5336 break;
5337
5338 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305339#ifdef WLAN_FEATURE_VOWIFI_11R
5340 case WLAN_AKM_SUITE_FT_8021X:
5341#endif
5342 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005343 __func__);
5344 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5345 break;
5346#ifdef FEATURE_WLAN_CCX
5347#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5348#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5349 case WLAN_AKM_SUITE_CCKM:
5350 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5351 __func__);
5352 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5353 break;
5354#endif
5355
5356 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305357 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 __func__, key_mgmt);
5359 return -EINVAL;
5360
5361 }
5362 return 0;
5363}
5364
5365/*
5366 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305367 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005368 * (NONE/WEP40/WEP104/TKIP/CCMP).
5369 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305370static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5371 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005372 bool ucast
5373 )
5374{
5375 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305376 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5378
5379 ENTER();
5380
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305381 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305383 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 __func__, cipher);
5385 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5386 }
5387 else
5388 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305389
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305391 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 {
5393 case IW_AUTH_CIPHER_NONE:
5394 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5395 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305396
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305398 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305400
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305402 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305404
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 case WLAN_CIPHER_SUITE_TKIP:
5406 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5407 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305408
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 case WLAN_CIPHER_SUITE_CCMP:
5410 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5411 break;
5412#ifdef FEATURE_WLAN_WAPI
5413 case WLAN_CIPHER_SUITE_SMS4:
5414 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5415 break;
5416#endif
5417
5418#ifdef FEATURE_WLAN_CCX
5419 case WLAN_CIPHER_SUITE_KRK:
5420 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5421 break;
5422#endif
5423 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305424 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 __func__, cipher);
5426 return -EOPNOTSUPP;
5427 }
5428 }
5429
5430 if (ucast)
5431 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305432 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 __func__, encryptionType);
5434 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5435 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305436 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005437 encryptionType;
5438 }
5439 else
5440 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305441 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 __func__, encryptionType);
5443 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5444 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5445 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5446 }
5447
5448 return 0;
5449}
5450
5451
5452/*
5453 * FUNCTION: wlan_hdd_cfg80211_set_ie
5454 * This function is used to parse WPA/RSN IE's.
5455 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305456int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5457 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 size_t ie_len
5459 )
5460{
5461 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5462 u8 *genie = ie;
5463 v_U16_t remLen = ie_len;
5464#ifdef FEATURE_WLAN_WAPI
5465 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5466 u16 *tmp;
5467 v_U16_t akmsuiteCount;
5468 int *akmlist;
5469#endif
5470 ENTER();
5471
5472 /* clear previous assocAddIE */
5473 pWextState->assocAddIE.length = 0;
5474 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5475
5476 while (remLen >= 2)
5477 {
5478 v_U16_t eLen = 0;
5479 v_U8_t elementId;
5480 elementId = *genie++;
5481 eLen = *genie++;
5482 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305483
5484 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305486
5487 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005488 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305489 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005490 if (4 > eLen) /* should have at least OUI which is 4 bytes so extra 2 bytes not needed */
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305492 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 "%s: Invalid WPA IE", __func__);
5494 return -EINVAL;
5495 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305496 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 {
5498 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305499 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305501
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5503 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005504 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5505 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 VOS_ASSERT(0);
5507 return -ENOMEM;
5508 }
5509 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5510 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5511 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305512
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5514 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5515 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5516 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305517 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5518 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5520 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5521 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5522 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5523 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5524 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305525 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5526 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005527 /*Consider P2P IE, only for P2P Client */
5528 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5529 {
5530 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305531 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305533
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5535 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005536 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5537 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 VOS_ASSERT(0);
5539 return -ENOMEM;
5540 }
5541 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5542 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5543 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305544
Jeff Johnson295189b2012-06-20 16:38:30 -07005545 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5546 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005548#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305549 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5550 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 /*Consider WFD IE, only for P2P Client */
5552 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5553 {
5554 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305555 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305557
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5559 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005560 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5561 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005562 VOS_ASSERT(0);
5563 return -ENOMEM;
5564 }
5565 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5566 // WPS IE + P2P IE + WFD IE
5567 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5568 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305569
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5571 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5572 }
5573#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005574 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305575 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005576 HS20_OUI_TYPE_SIZE)) )
5577 {
5578 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305579 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005580 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005581
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005582 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5583 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005584 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5585 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005586 VOS_ASSERT(0);
5587 return -ENOMEM;
5588 }
5589 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5590 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005591
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005592 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5593 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5594 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005595
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005596 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5597
5598 /* populating as ADDIE in beacon frames */
5599 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5600 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5601 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5602 {
5603 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5604 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5605 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5606 {
5607 hddLog(LOGE,
5608 "Coldn't pass "
5609 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5610 }
5611 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5612 else
5613 hddLog(LOGE,
5614 "Could not pass on "
5615 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5616
5617 /* IBSS mode doesn't contain params->proberesp_ies still
5618 beaconIE's need to be populated in probe response frames */
5619 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5620 {
5621 u16 rem_probe_resp_ie_len = eLen + 2;
5622 u8 probe_rsp_ie_len[3] = {0};
5623 u8 counter = 0;
5624
5625 /* Check Probe Resp Length if it is greater then 255 then
5626 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5627 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5628 not able Store More then 255 bytes into One Variable */
5629
5630 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5631 {
5632 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5633 {
5634 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5635 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5636 }
5637 else
5638 {
5639 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5640 rem_probe_resp_ie_len = 0;
5641 }
5642 }
5643
5644 rem_probe_resp_ie_len = 0;
5645
5646 if (probe_rsp_ie_len[0] > 0)
5647 {
5648 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5649 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5650 (tANI_U8*)(genie - 2),
5651 probe_rsp_ie_len[0], NULL,
5652 eANI_BOOLEAN_FALSE)
5653 == eHAL_STATUS_FAILURE)
5654 {
5655 hddLog(LOGE,
5656 "Could not pass"
5657 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5658 }
5659 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5660 }
5661
5662 if (probe_rsp_ie_len[1] > 0)
5663 {
5664 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5665 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5666 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5667 probe_rsp_ie_len[1], NULL,
5668 eANI_BOOLEAN_FALSE)
5669 == eHAL_STATUS_FAILURE)
5670 {
5671 hddLog(LOGE,
5672 "Could not pass"
5673 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5674 }
5675 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5676 }
5677
5678 if (probe_rsp_ie_len[2] > 0)
5679 {
5680 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5681 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5682 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5683 probe_rsp_ie_len[2], NULL,
5684 eANI_BOOLEAN_FALSE)
5685 == eHAL_STATUS_FAILURE)
5686 {
5687 hddLog(LOGE,
5688 "Could not pass"
5689 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5690 }
5691 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5692 }
5693
5694 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5695 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5696 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5697 {
5698 hddLog(LOGE,
5699 "Could not pass"
5700 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5701 }
5702 }
5703 else
5704 {
5705 // Reset WNI_CFG_PROBE_RSP Flags
5706 wlan_hdd_reset_prob_rspies(pAdapter);
5707
5708 hddLog(VOS_TRACE_LEVEL_INFO,
5709 "%s: No Probe Response IE received in set beacon",
5710 __func__);
5711 }
5712 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005713 break;
5714 case DOT11F_EID_RSN:
5715 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5716 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5717 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5718 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5719 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5720 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005721 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5722 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305723 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005724 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305725 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005726 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305727
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005728 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5729 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005730 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5731 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005732 VOS_ASSERT(0);
5733 return -ENOMEM;
5734 }
5735 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5736 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305737
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005738 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5739 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5740 break;
5741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005742#ifdef FEATURE_WLAN_WAPI
5743 case WLAN_EID_WAPI:
5744 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5745 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5746 pAdapter->wapi_info.nWapiMode);
5747 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305748 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 akmsuiteCount = WPA_GET_LE16(tmp);
5750 tmp = tmp + 1;
5751 akmlist = (int *)(tmp);
5752 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5753 {
5754 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5755 }
5756 else
5757 {
5758 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5759 VOS_ASSERT(0);
5760 return -EINVAL;
5761 }
5762
5763 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5764 {
5765 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005766 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005767 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305770 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005771 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005772 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5774 }
5775 break;
5776#endif
5777 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305778 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005780 /* when Unknown IE is received we should break and continue
5781 * to the next IE in the buffer instead we were returning
5782 * so changing this to break */
5783 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 }
5785 genie += eLen;
5786 remLen -= eLen;
5787 }
5788 EXIT();
5789 return 0;
5790}
5791
5792/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305793 * FUNCTION: hdd_isWPAIEPresent
5794 * Parse the received IE to find the WPA IE
5795 *
5796 */
5797static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5798{
5799 v_U8_t eLen = 0;
5800 v_U16_t remLen = ie_len;
5801 v_U8_t elementId = 0;
5802
5803 while (remLen >= 2)
5804 {
5805 elementId = *ie++;
5806 eLen = *ie++;
5807 remLen -= 2;
5808 if (eLen > remLen)
5809 {
5810 hddLog(VOS_TRACE_LEVEL_ERROR,
5811 "%s: IE length is wrong %d", __func__, eLen);
5812 return FALSE;
5813 }
5814 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5815 {
5816 /* OUI - 0x00 0X50 0XF2
5817 WPA Information Element - 0x01
5818 WPA version - 0x01*/
5819 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5820 return TRUE;
5821 }
5822 ie += eLen;
5823 remLen -= eLen;
5824 }
5825 return FALSE;
5826}
5827
5828/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305830 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 * parameters during connect operation.
5832 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305833int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 struct cfg80211_connect_params *req
5835 )
5836{
5837 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305838 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 ENTER();
5840
5841 /*set wpa version*/
5842 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5843
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305844 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305846 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005847 {
5848 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5849 }
5850 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5851 {
5852 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5853 }
5854 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305855
5856 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 pWextState->wpaVersion);
5858
5859 /*set authentication type*/
5860 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5861
5862 if (0 > status)
5863 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305864 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 "%s: failed to set authentication type ", __func__);
5866 return status;
5867 }
5868
5869 /*set key mgmt type*/
5870 if (req->crypto.n_akm_suites)
5871 {
5872 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5873 if (0 > status)
5874 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305875 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 __func__);
5877 return status;
5878 }
5879 }
5880
5881 /*set pairwise cipher type*/
5882 if (req->crypto.n_ciphers_pairwise)
5883 {
5884 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5885 req->crypto.ciphers_pairwise[0], true);
5886 if (0 > status)
5887 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305888 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005889 "%s: failed to set unicast cipher type", __func__);
5890 return status;
5891 }
5892 }
5893 else
5894 {
5895 /*Reset previous cipher suite to none*/
5896 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5897 if (0 > status)
5898 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305899 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 "%s: failed to set unicast cipher type", __func__);
5901 return status;
5902 }
5903 }
5904
5905 /*set group cipher type*/
5906 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5907 false);
5908
5909 if (0 > status)
5910 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305911 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005912 __func__);
5913 return status;
5914 }
5915
Chet Lanctot186b5732013-03-18 10:26:30 -07005916#ifdef WLAN_FEATURE_11W
5917 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5918#endif
5919
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5921 if (req->ie_len)
5922 {
5923 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5924 if ( 0 > status)
5925 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305926 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 __func__);
5928 return status;
5929 }
5930 }
5931
5932 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305933 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 {
5935 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5936 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5937 )
5938 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305939 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5941 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305942 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005943 __func__);
5944 return -EOPNOTSUPP;
5945 }
5946 else
5947 {
5948 u8 key_len = req->key_len;
5949 u8 key_idx = req->key_idx;
5950
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305951 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 && (CSR_MAX_NUM_KEY > key_idx)
5953 )
5954 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305955 hddLog(VOS_TRACE_LEVEL_INFO,
5956 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005957 __func__, key_idx, key_len);
5958 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305959 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305961 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005962 (u8)key_len;
5963 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5964 }
5965 }
5966 }
5967 }
5968
5969 return status;
5970}
5971
5972/*
5973 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305974 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 * parameters during connect operation.
5976 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305977static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005978 struct net_device *ndev,
5979 struct cfg80211_connect_params *req
5980 )
5981{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305982 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305983 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5985 hdd_context_t *pHddCtx = NULL;
5986
5987 ENTER();
5988
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305989 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5991
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305992 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5993 status = wlan_hdd_validate_context(pHddCtx);
5994
5995 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305997 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5998 "%s: HDD context is not valid", __func__);
5999 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 }
6001
6002#ifdef WLAN_BTAMP_FEATURE
6003 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306004 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306006 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006007 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006008 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006009 }
6010#endif
6011 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306012 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006013
6014 if ( 0 > status)
6015 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306016 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006017 __func__);
6018 return status;
6019 }
6020
6021 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006022 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6024 (vos_concurrent_sessions_running()))
6025 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306026 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 }
6028
Mohit Khanna765234a2012-09-11 15:08:35 -07006029 if ( req->channel )
6030 {
6031 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6032 req->ssid_len, req->bssid,
6033 req->channel->hw_value);
6034 }
6035 else
6036 {
6037 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306038 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006040
6041 if (0 > status)
6042 {
6043 //ReEnable BMPS if disabled
6044 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6045 (NULL != pHddCtx))
6046 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306047 if (pHddCtx->hdd_wlan_suspended)
6048 {
6049 hdd_set_pwrparams(pHddCtx);
6050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 //ReEnable Bmps and Imps back
6052 hdd_enable_bmps_imps(pHddCtx);
6053 }
6054
6055 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6056 return status;
6057 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306058 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006059 EXIT();
6060 return status;
6061}
6062
6063
6064/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306065 * FUNCTION: wlan_hdd_disconnect
6066 * This function is used to issue a disconnect request to SME
6067 */
6068int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6069{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306070 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306071 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306072 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6073
6074 status = wlan_hdd_validate_context(pHddCtx);
6075
6076 if (0 != status)
6077 {
6078 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6079 "%s: HDD context is not valid", __func__);
6080 return status;
6081 }
6082
6083 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306084 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306085 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306086
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306087 /*issue disconnect*/
6088 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6089 pAdapter->sessionId, reason);
6090
6091 if ( 0 != status )
6092 {
6093 hddLog(VOS_TRACE_LEVEL_ERROR,
6094 "%s csrRoamDisconnect failure, returned %d \n",
6095 __func__, (int)status );
6096 return -EINVAL;
6097 }
6098 wait_for_completion_interruptible_timeout(
6099 &pAdapter->disconnect_comp_var,
6100 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6101 /*stop tx queues*/
6102 netif_tx_disable(pAdapter->dev);
6103 netif_carrier_off(pAdapter->dev);
6104 return status;
6105}
6106
6107
6108/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006109 * FUNCTION: wlan_hdd_cfg80211_disconnect
6110 * This function is used to issue a disconnect request to SME
6111 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306112static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006113 struct net_device *dev,
6114 u16 reason
6115 )
6116{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306117 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6118 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306120 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006122 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306123#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006124 tANI_U8 staIdx;
6125#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306126
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306128
6129 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 __func__,pAdapter->device_mode);
6131
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306132 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6133 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006134
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306135 status = wlan_hdd_validate_context(pHddCtx);
6136
6137 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306139 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6140 "%s: HDD context is not valid", __func__);
6141 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306143
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 if (NULL != pRoamProfile)
6145 {
6146 /*issue disconnect request to SME, if station is in connected state*/
6147 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6148 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306149 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306151 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 switch(reason)
6153 {
6154 case WLAN_REASON_MIC_FAILURE:
6155 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6156 break;
6157
6158 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6159 case WLAN_REASON_DISASSOC_AP_BUSY:
6160 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6161 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6162 break;
6163
6164 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6165 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6166 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6167 break;
6168
6169 case WLAN_REASON_DEAUTH_LEAVING:
6170 default:
6171 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6172 break;
6173 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306174 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6175 pScanInfo = &pHddCtx->scan_info;
6176 if (pScanInfo->mScanPending)
6177 {
6178 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6179 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306180 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006182
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006183#ifdef FEATURE_WLAN_TDLS
6184 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006185 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006186 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006187 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6188 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006189 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006190 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006191 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006192 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006193 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006194 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006195 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006196 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006197 pAdapter->sessionId,
6198 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006199 }
6200 }
6201#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306202 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6203 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 {
6205 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306206 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 __func__, (int)status );
6208 return -EINVAL;
6209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006210 }
6211 }
6212 else
6213 {
6214 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6215 }
6216
6217 return status;
6218}
6219
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306220
Jeff Johnson295189b2012-06-20 16:38:30 -07006221/*
6222 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306223 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 * settings in IBSS mode.
6225 */
6226static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306227 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 struct cfg80211_ibss_params *params
6229 )
6230{
6231 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306232 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6234 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306235
Jeff Johnson295189b2012-06-20 16:38:30 -07006236 ENTER();
6237
6238 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6239
6240 if (params->ie_len && ( NULL != params->ie) )
6241 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006242 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6243 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 {
6245 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6246 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6247 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006248 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006249 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006250 tDot11fIEWPA dot11WPAIE;
6251 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006252 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006253
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006254 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6255 params->ie_len, DOT11F_EID_WPA);
6256 if ( NULL != ie )
6257 {
6258 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6259 // Unpack the WPA IE
6260 //Skip past the EID byte and length byte - and four byte WiFi OUI
6261 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6262 &ie[2+4],
6263 ie[1] - 4,
6264 &dot11WPAIE);
6265 /*Extract the multicast cipher, the encType for unicast
6266 cipher for wpa-none is none*/
6267 encryptionType =
6268 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006270 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006271
Jeff Johnson295189b2012-06-20 16:38:30 -07006272 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6273
6274 if (0 > status)
6275 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306276 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 __func__);
6278 return status;
6279 }
6280 }
6281
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306282 pWextState->roamProfile.AuthType.authType[0] =
6283 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006284 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6285
6286 if (params->privacy)
6287 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306288 /* Security enabled IBSS, At this time there is no information available
6289 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306291 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306293 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 *enable privacy bit in beacons */
6295
6296 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6297 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006298 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6299 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6301 pWextState->roamProfile.EncryptionType.numEntries = 1;
6302 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 return status;
6304}
6305
6306/*
6307 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306308 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306310static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 struct net_device *dev,
6312 struct cfg80211_ibss_params *params
6313 )
6314{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306315 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006316 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6317 tCsrRoamProfile *pRoamProfile;
6318 int status;
6319 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306320 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006321
6322 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306323
6324 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006325 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6326
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306327 status = wlan_hdd_validate_context(pHddCtx);
6328
6329 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6332 "%s: HDD context is not valid", __func__);
6333 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 }
6335
6336 if (NULL == pWextState)
6337 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306338 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 __func__);
6340 return -EIO;
6341 }
6342
6343 pRoamProfile = &pWextState->roamProfile;
6344
6345 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6346 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306347 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 "%s Interface type is not set to IBSS \n", __func__);
6349 return -EINVAL;
6350 }
6351
6352 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006353 if (NULL !=
6354#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6355 params->chandef.chan)
6356#else
6357 params->channel)
6358#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006359 {
6360 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006361 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6362 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6363 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6364 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006365
6366 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306367 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006368 ieee80211_frequency_to_channel(
6369#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6370 params->chandef.chan->center_freq);
6371#else
6372 params->channel->center_freq);
6373#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006374
6375 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6376 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006378 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6379 __func__);
6380 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006381 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006382
6383 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006384 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006385 if (channelNum == validChan[indx])
6386 {
6387 break;
6388 }
6389 }
6390 if (indx >= numChans)
6391 {
6392 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 __func__, channelNum);
6394 return -EINVAL;
6395 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006396 /* Set the Operational Channel */
6397 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6398 channelNum);
6399 pRoamProfile->ChannelInfo.numOfChannels = 1;
6400 pHddStaCtx->conn_info.operationChannel = channelNum;
6401 pRoamProfile->ChannelInfo.ChannelList =
6402 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 }
6404
6405 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306406 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006407 if (status < 0)
6408 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306409 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006410 __func__);
6411 return status;
6412 }
6413
6414 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306415 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006416 params->ssid_len, params->bssid,
6417 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006418
6419 if (0 > status)
6420 {
6421 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6422 return status;
6423 }
6424
6425 return 0;
6426}
6427
6428/*
6429 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306430 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306432static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 struct net_device *dev
6434 )
6435{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306436 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6438 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306439 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6440 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006441
6442 ENTER();
6443
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306444 status = wlan_hdd_validate_context(pHddCtx);
6445
6446 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006447 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306448 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6449 "%s: HDD context is not valid", __func__);
6450 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006451 }
6452
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6454 if (NULL == pWextState)
6455 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306456 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 __func__);
6458 return -EIO;
6459 }
6460
6461 pRoamProfile = &pWextState->roamProfile;
6462
6463 /* Issue disconnect only if interface type is set to IBSS */
6464 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6465 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306466 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006467 __func__);
6468 return -EINVAL;
6469 }
6470
6471 /* Issue Disconnect request */
6472 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6473 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6474 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6475
6476 return 0;
6477}
6478
6479/*
6480 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6481 * This function is used to set the phy parameters
6482 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6483 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306484static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 u32 changed)
6486{
6487 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6488 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306489 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006490
6491 ENTER();
6492
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306493 status = wlan_hdd_validate_context(pHddCtx);
6494
6495 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006496 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306497 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6498 "%s: HDD context is not valid", __func__);
6499 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006500 }
6501
Jeff Johnson295189b2012-06-20 16:38:30 -07006502 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6503 {
6504 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6505 WNI_CFG_RTS_THRESHOLD_STAMAX :
6506 wiphy->rts_threshold;
6507
6508 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306509 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306511 hddLog(VOS_TRACE_LEVEL_ERROR,
6512 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 __func__, rts_threshold);
6514 return -EINVAL;
6515 }
6516
6517 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6518 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306519 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306521 hddLog(VOS_TRACE_LEVEL_ERROR,
6522 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 __func__, rts_threshold);
6524 return -EIO;
6525 }
6526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306527 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 rts_threshold);
6529 }
6530
6531 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6532 {
6533 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6534 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6535 wiphy->frag_threshold;
6536
6537 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306538 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006539 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306540 hddLog(VOS_TRACE_LEVEL_ERROR,
6541 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 frag_threshold);
6543 return -EINVAL;
6544 }
6545
6546 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6547 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306548 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306550 hddLog(VOS_TRACE_LEVEL_ERROR,
6551 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006552 __func__, frag_threshold);
6553 return -EIO;
6554 }
6555
6556 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6557 frag_threshold);
6558 }
6559
6560 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6561 || (changed & WIPHY_PARAM_RETRY_LONG))
6562 {
6563 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6564 wiphy->retry_short :
6565 wiphy->retry_long;
6566
6567 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6568 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6569 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306570 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 __func__, retry_value);
6572 return -EINVAL;
6573 }
6574
6575 if (changed & WIPHY_PARAM_RETRY_SHORT)
6576 {
6577 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6578 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306579 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306581 hddLog(VOS_TRACE_LEVEL_ERROR,
6582 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 __func__, retry_value);
6584 return -EIO;
6585 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306586 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006587 __func__, retry_value);
6588 }
6589 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6590 {
6591 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6592 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306593 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306595 hddLog(VOS_TRACE_LEVEL_ERROR,
6596 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 __func__, retry_value);
6598 return -EIO;
6599 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306600 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 __func__, retry_value);
6602 }
6603 }
6604
6605 return 0;
6606}
6607
6608/*
6609 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6610 * This function is used to set the txpower
6611 */
6612static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006613#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6614 struct wireless_dev *wdev,
6615#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006616#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306617 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006618#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306619 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006620#endif
6621 int dbm)
6622{
6623 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306624 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6626 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306627 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006628
6629 ENTER();
6630
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306631 status = wlan_hdd_validate_context(pHddCtx);
6632
6633 if (0 != status)
6634 {
6635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6636 "%s: HDD context is not valid", __func__);
6637 return status;
6638 }
6639
6640 hHal = pHddCtx->hHal;
6641
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306642 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6643 dbm, ccmCfgSetCallback,
6644 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306646 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6648 return -EIO;
6649 }
6650
6651 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6652 dbm);
6653
6654 switch(type)
6655 {
6656 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6657 /* Fall through */
6658 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6659 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6660 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306661 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6662 __func__);
6663 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 }
6665 break;
6666 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306667 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006668 __func__);
6669 return -EOPNOTSUPP;
6670 break;
6671 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306672 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6673 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 return -EIO;
6675 }
6676
6677 return 0;
6678}
6679
6680/*
6681 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6682 * This function is used to read the txpower
6683 */
Yue Maf49ba872013-08-19 12:04:25 -07006684static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6685#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6686 struct wireless_dev *wdev,
6687#endif
6688 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006689{
6690
6691 hdd_adapter_t *pAdapter;
6692 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306693 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006694
Jeff Johnsone7245742012-09-05 17:12:55 -07006695 ENTER();
6696
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306697 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006698
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306699 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006700 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306701 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6702 "%s: HDD context is not valid", __func__);
6703 *dbm = 0;
6704 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006705 }
6706
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6708 if (NULL == pAdapter)
6709 {
6710 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6711 return -ENOENT;
6712 }
6713
6714 wlan_hdd_get_classAstats(pAdapter);
6715 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6716
Jeff Johnsone7245742012-09-05 17:12:55 -07006717 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 return 0;
6719}
6720
6721static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6722 u8* mac, struct station_info *sinfo)
6723{
6724 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6725 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6726 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6727 tANI_U8 rate_flags;
6728
6729 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6730 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006731
6732 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6733 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6734 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6735 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6736 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6737 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6738 tANI_U16 maxRate = 0;
6739 tANI_U16 myRate;
6740 tANI_U16 currentRate = 0;
6741 tANI_U8 maxSpeedMCS = 0;
6742 tANI_U8 maxMCSIdx = 0;
6743 tANI_U8 rateFlag = 1;
6744 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006745 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306746 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006747
Leo Chang6f8870f2013-03-26 18:11:36 -07006748#ifdef WLAN_FEATURE_11AC
6749 tANI_U32 vht_mcs_map;
6750 eDataRate11ACMaxMcs vhtMaxMcs;
6751#endif /* WLAN_FEATURE_11AC */
6752
Jeff Johnsone7245742012-09-05 17:12:55 -07006753 ENTER();
6754
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6756 (0 == ssidlen))
6757 {
6758 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6759 " Invalid ssidlen, %d", __func__, ssidlen);
6760 /*To keep GUI happy*/
6761 return 0;
6762 }
6763
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306764 status = wlan_hdd_validate_context(pHddCtx);
6765
6766 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006767 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6769 "%s: HDD context is not valid", __func__);
6770 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006771 }
6772
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6774 sinfo->filled |= STATION_INFO_SIGNAL;
6775
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006776 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6778
6779 //convert to the UI units of 100kbps
6780 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6781
6782#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006783 pr_info("RSSI %d, RLMS %u, rate %d, rssi high %d, rssi mid %d, rssi low %d, rate_flags 0x%x, MCS %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 sinfo->signal,
6785 pCfg->reportMaxLinkSpeed,
6786 myRate,
6787 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006788 (int) pCfg->linkSpeedRssiMid,
6789 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006790 (int) rate_flags,
6791 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006792#endif //LINKSPEED_DEBUG_ENABLED
6793
6794 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6795 {
6796 // we do not want to necessarily report the current speed
6797 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6798 {
6799 // report the max possible speed
6800 rssidx = 0;
6801 }
6802 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6803 {
6804 // report the max possible speed with RSSI scaling
6805 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6806 {
6807 // report the max possible speed
6808 rssidx = 0;
6809 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006810 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 {
6812 // report middle speed
6813 rssidx = 1;
6814 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006815 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6816 {
6817 // report middle speed
6818 rssidx = 2;
6819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006820 else
6821 {
6822 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006823 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 }
6825 }
6826 else
6827 {
6828 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6829 hddLog(VOS_TRACE_LEVEL_ERROR,
6830 "%s: Invalid value for reportMaxLinkSpeed: %u",
6831 __func__, pCfg->reportMaxLinkSpeed);
6832 rssidx = 0;
6833 }
6834
6835 maxRate = 0;
6836
6837 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306838 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6839 OperationalRates, &ORLeng))
6840 {
6841 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6842 /*To keep GUI happy*/
6843 return 0;
6844 }
6845
Jeff Johnson295189b2012-06-20 16:38:30 -07006846 for (i = 0; i < ORLeng; i++)
6847 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006848 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006849 {
6850 /* Validate Rate Set */
6851 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6852 {
6853 currentRate = supported_data_rate[j].supported_rate[rssidx];
6854 break;
6855 }
6856 }
6857 /* Update MAX rate */
6858 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6859 }
6860
6861 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306862 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6863 ExtendedRates, &ERLeng))
6864 {
6865 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6866 /*To keep GUI happy*/
6867 return 0;
6868 }
6869
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 for (i = 0; i < ERLeng; i++)
6871 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006872 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 {
6874 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6875 {
6876 currentRate = supported_data_rate[j].supported_rate[rssidx];
6877 break;
6878 }
6879 }
6880 /* Update MAX rate */
6881 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006883 /* Get MCS Rate Set -- but only if we are connected at MCS
6884 rates or if we are always reporting max speed or if we have
6885 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006886 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006887 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306888 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6889 MCSRates, &MCSLeng))
6890 {
6891 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6892 /*To keep GUI happy*/
6893 return 0;
6894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006895 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006896#ifdef WLAN_FEATURE_11AC
6897 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306898 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006899 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006900 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306901 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006902 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006904 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006905 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006906 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006908 maxMCSIdx = 7;
6909 }
6910 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6911 {
6912 maxMCSIdx = 8;
6913 }
6914 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6915 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306916 //VHT20 is supporting 0~8
6917 if (rate_flags & eHAL_TX_RATE_VHT20)
6918 maxMCSIdx = 8;
6919 else
6920 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006921 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306922
6923 if (rate_flags & eHAL_TX_RATE_VHT80)
6924 {
6925 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6926 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6927 }
6928 else if (rate_flags & eHAL_TX_RATE_VHT40)
6929 {
6930 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6931 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6932 }
6933 else if (rate_flags & eHAL_TX_RATE_VHT20)
6934 {
6935 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6936 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6937 }
6938
Leo Chang6f8870f2013-03-26 18:11:36 -07006939 maxSpeedMCS = 1;
6940 if (currentRate > maxRate)
6941 {
6942 maxRate = currentRate;
6943 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306944
Leo Chang6f8870f2013-03-26 18:11:36 -07006945 }
6946 else
6947#endif /* WLAN_FEATURE_11AC */
6948 {
6949 if (rate_flags & eHAL_TX_RATE_HT40)
6950 {
6951 rateFlag |= 1;
6952 }
6953 if (rate_flags & eHAL_TX_RATE_SGI)
6954 {
6955 rateFlag |= 2;
6956 }
6957
6958 for (i = 0; i < MCSLeng; i++)
6959 {
6960 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6961 for (j = 0; j < temp; j++)
6962 {
6963 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6964 {
6965 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6966 break;
6967 }
6968 }
6969 if ((j < temp) && (currentRate > maxRate))
6970 {
6971 maxRate = currentRate;
6972 maxSpeedMCS = 1;
6973 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6974 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006975 }
6976 }
6977 }
6978
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306979 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6980 {
6981 maxRate = myRate;
6982 maxSpeedMCS = 1;
6983 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6984 }
6985
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006987 if (((maxRate < myRate) && (0 == rssidx)) ||
6988 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 {
6990 maxRate = myRate;
6991 if (rate_flags & eHAL_TX_RATE_LEGACY)
6992 {
6993 maxSpeedMCS = 0;
6994 }
6995 else
6996 {
6997 maxSpeedMCS = 1;
6998 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6999 }
7000 }
7001
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307002 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 {
7004 sinfo->txrate.legacy = maxRate;
7005#ifdef LINKSPEED_DEBUG_ENABLED
7006 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7007#endif //LINKSPEED_DEBUG_ENABLED
7008 }
7009 else
7010 {
7011 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007012#ifdef WLAN_FEATURE_11AC
7013 sinfo->txrate.nss = 1;
7014 if (rate_flags & eHAL_TX_RATE_VHT80)
7015 {
7016 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307017 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007018 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307019 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007020 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307021 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7022 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7023 }
7024 else if (rate_flags & eHAL_TX_RATE_VHT20)
7025 {
7026 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7027 }
7028#endif /* WLAN_FEATURE_11AC */
7029 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7030 {
7031 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7032 if (rate_flags & eHAL_TX_RATE_HT40)
7033 {
7034 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7035 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 if (rate_flags & eHAL_TX_RATE_SGI)
7038 {
7039 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7040 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307041
Jeff Johnson295189b2012-06-20 16:38:30 -07007042#ifdef LINKSPEED_DEBUG_ENABLED
7043 pr_info("Reporting MCS rate %d flags %x\n",
7044 sinfo->txrate.mcs,
7045 sinfo->txrate.flags );
7046#endif //LINKSPEED_DEBUG_ENABLED
7047 }
7048 }
7049 else
7050 {
7051 // report current rate instead of max rate
7052
7053 if (rate_flags & eHAL_TX_RATE_LEGACY)
7054 {
7055 //provide to the UI in units of 100kbps
7056 sinfo->txrate.legacy = myRate;
7057#ifdef LINKSPEED_DEBUG_ENABLED
7058 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7059#endif //LINKSPEED_DEBUG_ENABLED
7060 }
7061 else
7062 {
7063 //must be MCS
7064 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007065#ifdef WLAN_FEATURE_11AC
7066 sinfo->txrate.nss = 1;
7067 if (rate_flags & eHAL_TX_RATE_VHT80)
7068 {
7069 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7070 }
7071 else
7072#endif /* WLAN_FEATURE_11AC */
7073 {
7074 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 if (rate_flags & eHAL_TX_RATE_SGI)
7077 {
7078 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7079 }
7080 if (rate_flags & eHAL_TX_RATE_HT40)
7081 {
7082 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7083 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007084#ifdef WLAN_FEATURE_11AC
7085 else if (rate_flags & eHAL_TX_RATE_VHT80)
7086 {
7087 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7088 }
7089#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007090#ifdef LINKSPEED_DEBUG_ENABLED
7091 pr_info("Reporting actual MCS rate %d flags %x\n",
7092 sinfo->txrate.mcs,
7093 sinfo->txrate.flags );
7094#endif //LINKSPEED_DEBUG_ENABLED
7095 }
7096 }
7097 sinfo->filled |= STATION_INFO_TX_BITRATE;
7098
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007099 sinfo->tx_packets =
7100 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7101 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7102 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7103 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7104
7105 sinfo->tx_retries =
7106 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7107 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7108 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7109 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7110
7111 sinfo->tx_failed =
7112 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7113 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7114 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7115 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7116
7117 sinfo->filled |=
7118 STATION_INFO_TX_PACKETS |
7119 STATION_INFO_TX_RETRIES |
7120 STATION_INFO_TX_FAILED;
7121
7122 EXIT();
7123 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007124}
7125
7126static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007127 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007128{
7129 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307130 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307132 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007133
Jeff Johnsone7245742012-09-05 17:12:55 -07007134 ENTER();
7135
Jeff Johnson295189b2012-06-20 16:38:30 -07007136 if (NULL == pAdapter)
7137 {
7138 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7139 return -ENODEV;
7140 }
7141
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307142 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307143 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307144
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307145 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307146 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7148 "%s: HDD context is not valid", __func__);
7149 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307150 }
7151
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307152 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7153 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7154 (pHddCtx->cfg_ini->fhostArpOffload) &&
7155 (eConnectionState_Associated ==
7156 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7157 {
Amar Singhald53568e2013-09-26 11:03:45 -07007158
7159 hddLog(VOS_TRACE_LEVEL_INFO,
7160 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307161 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307162 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7163 {
7164 hddLog(VOS_TRACE_LEVEL_INFO,
7165 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7166 __func__, vos_status);
7167 }
7168 }
7169
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 /**The get power cmd from the supplicant gets updated by the nl only
7171 *on successful execution of the function call
7172 *we are oppositely mapped w.r.t mode in the driver
7173 **/
7174 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7175
Jeff Johnsone7245742012-09-05 17:12:55 -07007176 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007177 if (VOS_STATUS_E_FAILURE == vos_status)
7178 {
7179 return -EINVAL;
7180 }
7181 return 0;
7182}
7183
7184
7185#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7186static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7187 struct net_device *netdev,
7188 u8 key_index)
7189{
Jeff Johnsone7245742012-09-05 17:12:55 -07007190 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 return 0;
7192}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307193#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007194
7195#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7196static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7197 struct net_device *dev,
7198 struct ieee80211_txq_params *params)
7199{
Jeff Johnsone7245742012-09-05 17:12:55 -07007200 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 return 0;
7202}
7203#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7204static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7205 struct ieee80211_txq_params *params)
7206{
Jeff Johnsone7245742012-09-05 17:12:55 -07007207 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007208 return 0;
7209}
7210#endif //LINUX_VERSION_CODE
7211
7212static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7213 struct net_device *dev, u8 *mac)
7214{
7215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307216 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007217 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307218 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007219 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007220
Jeff Johnsone7245742012-09-05 17:12:55 -07007221 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307222 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307224 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007225 return -EINVAL;
7226 }
7227
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307228 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7229 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007230
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307231 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007232 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307233 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7234 "%s: HDD context is not valid", __func__);
7235 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007236 }
7237
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007239 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 )
7241 {
7242 if( NULL == mac )
7243 {
7244 v_U16_t i;
7245 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7246 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007247 if ((pAdapter->aStaInfo[i].isUsed) &&
7248 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 {
7250 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7251 hddLog(VOS_TRACE_LEVEL_INFO,
7252 "%s: Delete STA with MAC::"
7253 "%02x:%02x:%02x:%02x:%02x:%02x",
7254 __func__,
7255 macAddr[0], macAddr[1], macAddr[2],
7256 macAddr[3], macAddr[4], macAddr[5]);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007257 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7258 if (VOS_IS_STATUS_SUCCESS(vos_status))
7259 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007260 }
7261 }
7262 }
7263 else
7264 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007265
7266 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7267 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7268 {
7269 hddLog(VOS_TRACE_LEVEL_INFO,
7270 "%s: Skip this DEL STA as this is not used::"
7271 "%02x:%02x:%02x:%02x:%02x:%02x",
7272 __func__,
7273 mac[0], mac[1], mac[2],
7274 mac[3], mac[4], mac[5]);
7275 return -ENOENT;
7276 }
7277
7278 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7279 {
7280 hddLog(VOS_TRACE_LEVEL_INFO,
7281 "%s: Skip this DEL STA as deauth is in progress::"
7282 "%02x:%02x:%02x:%02x:%02x:%02x",
7283 __func__,
7284 mac[0], mac[1], mac[2],
7285 mac[3], mac[4], mac[5]);
7286 return -ENOENT;
7287 }
7288
7289 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7290
Jeff Johnson295189b2012-06-20 16:38:30 -07007291 hddLog(VOS_TRACE_LEVEL_INFO,
7292 "%s: Delete STA with MAC::"
7293 "%02x:%02x:%02x:%02x:%02x:%02x",
7294 __func__,
7295 mac[0], mac[1], mac[2],
7296 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007297
7298 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7299 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7300 {
7301 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7302 hddLog(VOS_TRACE_LEVEL_INFO,
7303 "%s: STA removal failed for ::"
7304 "%02x:%02x:%02x:%02x:%02x:%02x",
7305 __func__,
7306 mac[0], mac[1], mac[2],
7307 mac[3], mac[4], mac[5]);
7308 return -ENOENT;
7309 }
7310
Jeff Johnson295189b2012-06-20 16:38:30 -07007311 }
7312 }
7313
7314 EXIT();
7315
7316 return 0;
7317}
7318
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007319static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7320 struct net_device *dev, u8 *mac, struct station_parameters *params)
7321{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007322 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007323#ifdef FEATURE_WLAN_TDLS
7324 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007325 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007326 mask = params->sta_flags_mask;
7327
7328 set = params->sta_flags_set;
7329
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007330#ifdef WLAN_FEATURE_TDLS_DEBUG
7331 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7332 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7333 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7334#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007335
7336 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7337 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007338 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007339 }
7340 }
7341#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007342 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007343}
7344
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007345
7346#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007347#define MAX_PMKSAIDS_IN_CACHE 8
7348
7349static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7350static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7351
7352
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007353static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007354 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007355{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307356 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007357 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7358 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307359 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307360 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007361 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307362 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307363
Jeff Johnsone7245742012-09-05 17:12:55 -07007364 ENTER();
7365
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307366 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307367 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007368 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307369 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007370 return -EINVAL;
7371 }
7372
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307373 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7374 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007375
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307376 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007377 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307378 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7379 "%s: HDD context is not valid", __func__);
7380 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007381 }
7382
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307383 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007384 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7385
Wilson Yang6507c4e2013-10-01 20:11:19 -07007386 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007387 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307388 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007389 pmksa->bssid, WNI_CFG_BSSID_LEN))
7390 {
7391 /* BSSID matched previous entry. Overwrite it. */
7392 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307393 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007394 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307395 vos_mem_copy(PMKIDCache[j].PMKID,
7396 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007397 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307398 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007399 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007400 dump_bssid(pmksa->bssid);
7401 dump_pmkid(halHandle, pmksa->pmkid);
7402 break;
7403 }
7404 }
7405
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007406 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007407 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007408
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007409 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307410 {
7411 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007412 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307413 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007414 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307415 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007416 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307417 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007418 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007419 dump_bssid(pmksa->bssid);
7420 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307421 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007422 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007423 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007424 }
7425
7426
7427 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307428 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007429 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307430 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007431 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007432 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307433 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7434 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007435 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007436 return 0;
7437}
7438
7439
Wilson Yang6507c4e2013-10-01 20:11:19 -07007440
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007441static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007442 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007443{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007444 tANI_U32 j=0;
7445 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7446 tHalHandle halHandle;
7447 int status;
7448 tANI_U8 BSSIDMatched = 0;
7449 tANI_U8 *pBSSId;
7450 hdd_context_t *pHddCtx;
7451 int result = 0;
7452
7453 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA with PMKSA_ID %d .",
7454 __func__,pmksa->pmkid);
7455
7456 /* Validate pAdapter */
7457 if (NULL == pAdapter)
7458 {
7459 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7460 return -EINVAL;
7461 }
7462
7463 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7464 status = wlan_hdd_validate_context(pHddCtx);
7465
7466 if (0 != status)
7467 {
7468 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7469 "%s: HDD context is not valid", __func__);
7470 return status;
7471 }
7472
7473 /*Retrieve halHandle*/
7474 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7475
7476 /*in case index is 0,no entry to delete*/
7477 if (0 == PMKIDCacheIndex)
7478 {
7479 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7480 __func__);
7481 return -EINVAL;
7482 }
7483
7484 /*find the matching PMKSA entry from j=0 to (index-1),
7485 * and delete the matched one
7486 */
7487 for (j = 0; j<PMKIDCacheIndex; j++)
7488 {
7489 if (vos_mem_compare(PMKIDCache[j].BSSID,
7490 pmksa->bssid,
7491 WNI_CFG_BSSID_LEN))
7492 {
7493 /* BSSID matched entry */
7494 BSSIDMatched = 1;
7495
7496 if (j<PMKIDCacheIndex-1)
7497 {
7498 /*replace the matching entry with the last entry in HDD local cache*/
7499 vos_mem_copy(PMKIDCache[j].BSSID,
7500 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7501 WNI_CFG_BSSID_LEN);
7502 vos_mem_copy(PMKIDCache[j].PMKID,
7503 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7504 CSR_RSN_PMKID_SIZE);
7505 }
7506
7507 /*clear the last entry in HDD cache ---[index-1]*/
7508 pBSSId =(tANI_U8 *)(PMKIDCache[PMKIDCacheIndex-1].BSSID);
7509 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7510 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7511
7512 /*reduce the PMKID array index*/
7513 PMKIDCacheIndex--;
7514
7515 /*delete the last PMKID cache in CSR*/
7516 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7517 if (0 != result)
7518 {
7519 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7520 __func__,PMKIDCacheIndex);
7521 }
7522
7523 dump_bssid(pmksa->bssid);
7524 dump_pmkid(halHandle,pmksa->pmkid);
7525
7526 break;
7527 }
7528 }
7529
7530 /* we compare all entries,but cannot find matching entry */
7531 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7532 {
7533 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: No such PMKSA entry existed %d.",
7534 __func__,pmksa->bssid);
7535 dump_bssid(pmksa->bssid);
7536 dump_pmkid(halHandle, pmksa->pmkid);
7537 return -EINVAL;
7538 }
7539 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007540}
7541
Wilson Yang6507c4e2013-10-01 20:11:19 -07007542
7543
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007544static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7545{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007546 tANI_U32 j=0;
7547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7548 tHalHandle halHandle;
7549 hdd_context_t *pHddCtx;
7550 tANI_U8 *pBSSId;
7551 int status;
7552 int result;
7553
7554 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7555
7556 /* Validate pAdapter */
7557 if (NULL == pAdapter)
7558 {
7559 hddLog(VOS_TRACE_LEVEL_ERROR,
7560 "%s: Invalid Adapter" ,__func__);
7561 return -EINVAL;
7562 }
7563
7564 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7565 status = wlan_hdd_validate_context(pHddCtx);
7566
7567 if (0 != status)
7568 {
7569 hddLog(VOS_TRACE_LEVEL_ERROR,
7570 "%s: HDD context is not valid", __func__);
7571 return status;
7572 }
7573
7574 /*Retrieve halHandle*/
7575 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7576
7577 /*in case index is 0,no entry to delete*/
7578 if (0 == PMKIDCacheIndex)
7579 {
7580 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7581 __func__);
7582 return -EINVAL;
7583 }
7584
7585 /*delete all the PMKSA one by one */
7586 for (j = 0; j<PMKIDCacheIndex; j++)
7587 {
7588 /*clear the entry in HDD cache 0--index-1 */
7589 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
7590 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7591 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
7592
7593 /*delete the PMKID in CSR*/
7594 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7595
7596 if (0!= result)
7597 {
7598 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7599 __func__,j);
7600 }
7601 }
7602
7603 PMKIDCacheIndex = 0;
7604 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007605}
7606#endif
7607
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007608#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307609static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007610 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7611{
7612 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7613 hdd_station_ctx_t *pHddStaCtx;
7614
7615 if (NULL == pAdapter)
7616 {
7617 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7618 return -ENODEV;
7619 }
7620
7621 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7622
7623 // Added for debug on reception of Re-assoc Req.
7624 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7625 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307626 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007627 ftie->ie_len);
7628 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7629 }
7630
7631#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307632 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007633 ftie->ie_len);
7634#endif
7635
7636 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307637 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7638 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007639 ftie->ie_len);
7640 return 0;
7641}
7642#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007643
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307644#ifdef FEATURE_WLAN_SCAN_PNO
7645
7646void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7647 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7648{
7649 int ret;
7650 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7651 hdd_context_t *pHddCtx;
7652
7653 if (NULL == pAdapter)
7654 {
7655 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7656 "%s: HDD adapter is Null", __func__);
7657 return ;
7658 }
7659
7660 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7661 if (NULL == pHddCtx)
7662 {
7663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7664 "%s: HDD context is Null!!!", __func__);
7665 return ;
7666 }
7667
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307668 spin_lock(&pHddCtx->schedScan_lock);
7669 if (TRUE == pHddCtx->isWiphySuspended)
7670 {
7671 pHddCtx->isSchedScanUpdatePending = TRUE;
7672 spin_unlock(&pHddCtx->schedScan_lock);
7673 hddLog(VOS_TRACE_LEVEL_INFO,
7674 "%s: Update cfg80211 scan database after it resume", __func__);
7675 return ;
7676 }
7677 spin_unlock(&pHddCtx->schedScan_lock);
7678
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307679 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7680
7681 if (0 > ret)
7682 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7683
7684 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7686 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307687}
7688
7689/*
7690 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7691 * NL interface to enable PNO
7692 */
7693static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7694 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7695{
7696 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7697 tpSirPNOScanReq pPnoRequest = NULL;
7698 hdd_context_t *pHddCtx;
7699 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307700 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307701 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7702 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7703 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7704 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307705 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307706
7707 if (NULL == pAdapter)
7708 {
7709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7710 "%s: HDD adapter is Null", __func__);
7711 return -ENODEV;
7712 }
7713
7714 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307715 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307716
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307717 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307718 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307719 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7720 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307721 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307722 }
7723
7724 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7725 if (NULL == hHal)
7726 {
7727 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7728 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307729 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307730 }
7731
7732 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7733 if (NULL == pPnoRequest)
7734 {
7735 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7736 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307737 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307738 }
7739
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307740 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307741 pPnoRequest->enable = 1; /*Enable PNO */
7742 pPnoRequest->ucNetworksCount = request->n_match_sets;
7743
7744 if (( !pPnoRequest->ucNetworksCount ) ||
7745 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7746 {
7747 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7748 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307749 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307750 goto error;
7751 }
7752
7753 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7754 {
7755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7756 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307757 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307758 goto error;
7759 }
7760
7761 /* Framework provides one set of channels(all)
7762 * common for all saved profile */
7763 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7764 channels_allowed, &num_channels_allowed))
7765 {
7766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7767 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307768 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307769 goto error;
7770 }
7771 /* Checking each channel against allowed channel list */
7772 num_ch = 0;
7773 for (i = 0; i < request->n_channels; i++)
7774 {
7775 for (indx = 0; indx < num_channels_allowed; indx++)
7776 {
7777 if (request->channels[i]->hw_value == channels_allowed[indx])
7778 {
7779 valid_ch[num_ch++] = request->channels[i]->hw_value;
7780 break ;
7781 }
7782 }
7783 }
7784
7785 /* Filling per profile params */
7786 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7787 {
7788 pPnoRequest->aNetworks[i].ssId.length =
7789 request->match_sets[i].ssid.ssid_len;
7790
7791 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7792 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7793 {
7794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7795 "SSID Len %d is not correct for network %d",
7796 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307797 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307798 goto error;
7799 }
7800
7801 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7802 request->match_sets[i].ssid.ssid,
7803 request->match_sets[i].ssid.ssid_len);
7804 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7805 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7806 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7807
7808 /*Copying list of valid channel into request */
7809 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7810 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7811
7812 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7813 }
7814
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7816 "request->ie_len = %d", request->ie_len);
7817 if ((0 < request->ie_len) && (NULL != request->ie))
7818 {
7819 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7820 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7821 pPnoRequest->us24GProbeTemplateLen);
7822
7823 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7824 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7825 pPnoRequest->us5GProbeTemplateLen);
7826 }
7827
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307828 /* Driver gets only one time interval which is hardcoded in
7829 * supplicant for 10000ms. Taking power consumption into account 6 timers
7830 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7831 * 80,160,320 secs. And number of scan cycle for each timer
7832 * is configurable through INI param gPNOScanTimerRepeatValue.
7833 * If it is set to 0 only one timer will be used and PNO scan cycle
7834 * will be repeated after each interval specified by supplicant
7835 * till PNO is disabled.
7836 */
7837 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7838 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7839 else
7840 pPnoRequest->scanTimers.ucScanTimersCount =
7841 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7842
7843 tempInterval = (request->interval)/1000;
7844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7845 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7846 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7847 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7848 {
7849 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7850 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7851 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7852 tempInterval *= 2;
7853 }
7854 //Repeat last timer until pno disabled.
7855 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7856
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307857 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307858
7859 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7860 pPnoRequest, pAdapter->sessionId,
7861 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7862 if (eHAL_STATUS_SUCCESS != status)
7863 {
7864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7865 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307866 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307867 goto error;
7868 }
7869
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7871 "PNO scanRequest offloaded");
7872
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307873error:
7874 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307875 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307876}
7877
7878/*
7879 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7880 * NL interface to disable PNO
7881 */
7882static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7883 struct net_device *dev)
7884{
7885 eHalStatus status = eHAL_STATUS_FAILURE;
7886 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7887 hdd_context_t *pHddCtx;
7888 tHalHandle hHal;
7889 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307890 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307891
7892 ENTER();
7893
7894 if (NULL == pAdapter)
7895 {
7896 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7897 "%s: HDD adapter is Null", __func__);
7898 return -ENODEV;
7899 }
7900
7901 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307902
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307903 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307904 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307905 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307906 "%s: HDD context is Null", __func__);
7907 return -ENODEV;
7908 }
7909
7910 /* The return 0 is intentional when isLogpInProgress and
7911 * isLoadUnloadInProgress. We did observe a crash due to a return of
7912 * failure in sched_scan_stop , especially for a case where the unload
7913 * of the happens at the same time. The function __cfg80211_stop_sched_scan
7914 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
7915 * success. If it returns a failure , then its next invocation due to the
7916 * clean up of the second interface will have the dev pointer corresponding
7917 * to the first one leading to a crash.
7918 */
7919 if (pHddCtx->isLogpInProgress)
7920 {
7921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7922 "%s: LOGP in Progress. Ignore!!!", __func__);
7923 return ret;
7924 }
7925
7926 if (pHddCtx->isLoadUnloadInProgress)
7927 {
7928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7929 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7930 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307931 }
7932
7933 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7934 if (NULL == hHal)
7935 {
7936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7937 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307938 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307939 }
7940
7941 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7942 if (NULL == pPnoRequest)
7943 {
7944 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7945 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307946 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307947 }
7948
7949 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7950 pPnoRequest->enable = 0; /* Disable PNO */
7951 pPnoRequest->ucNetworksCount = 0;
7952
7953 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7954 pAdapter->sessionId,
7955 NULL, pAdapter);
7956 if (eHAL_STATUS_SUCCESS != status)
7957 {
7958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7959 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307960 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307961 }
7962
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7964 "%s: PNO scan disabled", __func__);
7965
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307966 vos_mem_free(pPnoRequest);
7967
7968 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307969 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307970}
7971
7972#endif /*FEATURE_WLAN_SCAN_PNO*/
7973
7974
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007975#ifdef FEATURE_WLAN_TDLS
7976static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7977 u8 *peer, u8 action_code, u8 dialog_token,
7978 u16 status_code, const u8 *buf, size_t len)
7979{
7980
7981 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7982 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007983 u8 peerMac[6];
7984 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007985 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007986 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007987 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007988
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007989 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007990 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007992 "Invalid arguments");
7993 return -EINVAL;
7994 }
7995
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007996 if (pHddCtx->isLogpInProgress)
7997 {
7998 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7999 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008000 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008001 return -EBUSY;
8002 }
8003
Hoonki Lee27511902013-03-14 18:19:06 -07008004 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008005 {
Hoonki Lee27511902013-03-14 18:19:06 -07008006 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8007 "%s: TDLS mode is disabled OR not enabled in FW."
8008 MAC_ADDRESS_STR " action %d declined.",
8009 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008010 return -ENOTSUPP;
8011 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008012
Hoonki Lee27511902013-03-14 18:19:06 -07008013 /* other than teardown frame, other mgmt frames are not sent if disabled */
8014 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8015 {
8016 /* if tdls_mode is disabled to respond to peer's request */
8017 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8018 {
8019 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8020 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008021 " TDLS mode is disabled. action %d declined.",
8022 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008023
8024 return -ENOTSUPP;
8025 }
8026 }
8027
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008028 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8029 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308030 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008031 {
8032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008033 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008034 " TDLS setup is ongoing. action %d declined.",
8035 __func__, MAC_ADDR_ARRAY(peer), action_code);
8036 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008037 }
8038 }
8039
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008040 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8041 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008042 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008043 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008044 {
8045 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8046 we return error code at 'add_station()'. Hence we have this
8047 check again in addtion to add_station().
8048 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008049 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008050 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008051 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8052 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008053 " TDLS Max peer already connected. action %d declined.",
8054 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008055 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008056 }
8057 else
8058 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008059 /* maximum reached. tweak to send error code to peer and return
8060 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008061 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008062 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8063 "%s: " MAC_ADDRESS_STR
8064 " TDLS Max peer already connected send response status %d",
8065 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008066 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008067 /* fall through to send setup resp with failure status
8068 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008069 }
8070 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008071 else
8072 {
8073 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308074 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008075 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008076 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008078 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8079 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008080 return -EPERM;
8081 }
8082 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008083 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008084 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008085
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008086#ifdef WLAN_FEATURE_TDLS_DEBUG
8087 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008088 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8089 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8090 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008091#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008092
Hoonki Leea34dd892013-02-05 22:56:02 -08008093 /*Except teardown responder will not be used so just make 0*/
8094 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008095 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008096 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008097
8098 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308099 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008100
8101 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8102 responder = pTdlsPeer->is_responder;
8103 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008104 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008105 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8106 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8107 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8108 dialog_token, status_code, len);
8109 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008110 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008111 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008112
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308113 /* For explicit trigger of DIS_REQ come out of BMPS for
8114 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008115 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308116 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8117 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008118 {
8119 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8120 {
8121 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308122 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008123 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8124 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308125 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8126 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008127 }
8128
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008129 /* make sure doesn't call send_mgmt() while it is pending */
8130 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8131 {
8132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8133 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8134 __func__, MAC_ADDR_ARRAY(peer), action_code);
8135 return -EBUSY;
8136 }
8137
8138 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008139 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8140
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008141 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008142 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008143
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008144 if (VOS_STATUS_SUCCESS != status)
8145 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008146 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8147 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008148 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008149 wlan_hdd_tdls_check_bmps(pAdapter);
8150 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008151 }
8152
Hoonki Leed37cbb32013-04-20 00:31:14 -07008153 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8154 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8155
8156 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008157 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8159 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
8160 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008161 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008162 wlan_hdd_tdls_check_bmps(pAdapter);
8163 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008164 }
8165
Gopichand Nakkala05922802013-03-14 12:23:19 -07008166 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008167 {
8168 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008169 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008170 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008171
Hoonki Leea34dd892013-02-05 22:56:02 -08008172 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8173 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008174 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008175 }
8176 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8177 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008178 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008179 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008180
8181 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008182error:
8183 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8184 because we already know that this transaction will be failed,
8185 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8186 to be safe, do not change the state mahine.
8187 */
8188 if(max_sta_failed == 0 &&
8189 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8190 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8191 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008192}
8193
8194static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8195 u8 *peer, enum nl80211_tdls_operation oper)
8196{
8197 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8198 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308199 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008200#ifdef WLAN_FEATURE_TDLS_DEBUG
8201 const char *tdls_oper_str[]= {
8202 "NL80211_TDLS_DISCOVERY_REQ",
8203 "NL80211_TDLS_SETUP",
8204 "NL80211_TDLS_TEARDOWN",
8205 "NL80211_TDLS_ENABLE_LINK",
8206 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308207 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008208#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008209 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008210
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308211 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008212 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008214 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008215 return -EINVAL;
8216 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008217
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308218 status = wlan_hdd_validate_context(pHddCtx);
8219
8220 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008221 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308222 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8223 "%s: HDD context is not valid", __func__);
8224 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008225 }
8226
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308227 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008228
8229 if ( NULL == pTdlsPeer ) {
8230 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8231 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8232 return -EINVAL;
8233 }
8234
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008235#ifdef WLAN_FEATURE_TDLS_DEBUG
8236 if((int)oper > 4)
8237 oper = 5;
8238
8239 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008240 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8241 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008242 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008243#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008244
8245 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008246 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008247 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008248 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008249 "TDLS Disabled in INI OR not enabled in FW. "
8250 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008251 return -ENOTSUPP;
8252 }
8253
8254 switch (oper) {
8255 case NL80211_TDLS_ENABLE_LINK:
8256 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008257 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308258 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008259
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008260 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8261 {
8262 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8263 MAC_ADDRESS_STR " failed",
8264 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8265 return -EINVAL;
8266 }
8267
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008268 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008269 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308270 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308271 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308272
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308273 if (0 != wlan_hdd_tdls_get_link_establish_params(
8274 pAdapter, peer,&tdlsLinkEstablishParams)) {
8275 return -EINVAL;
8276 }
8277 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308278
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308279 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8280 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8281 /* Send TDLS peer UAPSD capabilities to the firmware and
8282 * register with the TL on after the response for this operation
8283 * is received .
8284 */
8285 ret = wait_for_completion_interruptible_timeout(
8286 &pAdapter->tdls_link_establish_req_comp,
8287 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8288 if (ret <= 0)
8289 {
8290 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8291 "%s: Link Establish Request Faled Status %ld",
8292 __func__, ret);
8293 return -EINVAL;
8294 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308295 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008296 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308297 /* Mark TDLS client Authenticated .*/
8298 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8299 pTdlsPeer->staId,
8300 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008301 if (VOS_STATUS_SUCCESS == status)
8302 {
Hoonki Lee14621352013-04-16 17:51:19 -07008303 if (pTdlsPeer->is_responder == 0)
8304 {
8305 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8306
8307 wlan_hdd_tdls_timer_restart(pAdapter,
8308 &pTdlsPeer->initiatorWaitTimeoutTimer,
8309 WAIT_TIME_TDLS_INITIATOR);
8310 /* suspend initiator TX until it receives direct packet from the
8311 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8312 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8313 &staId, NULL);
8314 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008315 wlan_hdd_tdls_increment_peer_count(pAdapter);
8316 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008317 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308318
8319 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308320 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8321 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308322 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308323 int ac;
8324 uint8 ucAc[4] = { WLANTL_AC_VO,
8325 WLANTL_AC_VI,
8326 WLANTL_AC_BK,
8327 WLANTL_AC_BE };
8328 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8329 for(ac=0; ac < 4; ac++)
8330 {
8331 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8332 pTdlsPeer->staId, ucAc[ac],
8333 tlTid[ac], tlTid[ac], 0, 0,
8334 WLANTL_BI_DIR );
8335 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308336 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008337 }
8338
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008339 }
8340 break;
8341 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008342 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008343 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008344 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008345 long status;
8346
8347 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8348
Lee Hoonkic1262f22013-01-24 21:59:00 -08008349 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8350 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008351
8352 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8353 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8354 if (status <= 0)
8355 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008356 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008357 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8358 "%s: Del station failed status %ld",
8359 __func__, status);
8360 return -EPERM;
8361 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008362 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008363 }
8364 else
8365 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8367 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008368 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008369 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008370 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008371 case NL80211_TDLS_TEARDOWN:
8372 case NL80211_TDLS_SETUP:
8373 case NL80211_TDLS_DISCOVERY_REQ:
8374 /* We don't support in-driver setup/teardown/discovery */
8375 return -ENOTSUPP;
8376 default:
8377 return -ENOTSUPP;
8378 }
8379 return 0;
8380}
Chilam NG571c65a2013-01-19 12:27:36 +05308381
8382int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8383 struct net_device *dev, u8 *peer)
8384{
8385 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8386 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8387
8388 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8389 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8390}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008391#endif
8392
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308393#ifdef WLAN_FEATURE_GTK_OFFLOAD
8394/*
8395 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8396 * Callback rountine called upon receiving response for
8397 * get offload info
8398 */
8399void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8400 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8401{
8402
8403 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308404 tANI_U8 tempReplayCounter[8];
8405 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308406
8407 ENTER();
8408
8409 if (NULL == pAdapter)
8410 {
8411 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8412 "%s: HDD adapter is Null", __func__);
8413 return ;
8414 }
8415
8416 if (NULL == pGtkOffloadGetInfoRsp)
8417 {
8418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8419 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8420 return ;
8421 }
8422
8423 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8424 {
8425 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8426 "%s: wlan Failed to get replay counter value",
8427 __func__);
8428 return ;
8429 }
8430
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308431 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8432 /* Update replay counter */
8433 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8434 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8435
8436 {
8437 /* changing from little to big endian since supplicant
8438 * works on big endian format
8439 */
8440 int i;
8441 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8442
8443 for (i = 0; i < 8; i++)
8444 {
8445 tempReplayCounter[7-i] = (tANI_U8)p[i];
8446 }
8447 }
8448
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308449 /* Update replay counter to NL */
8450 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308451 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308452}
8453
8454/*
8455 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8456 * This function is used to offload GTK rekeying job to the firmware.
8457 */
8458int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8459 struct cfg80211_gtk_rekey_data *data)
8460{
8461 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8462 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8463 hdd_station_ctx_t *pHddStaCtx;
8464 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308465 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308466 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308467 eHalStatus status = eHAL_STATUS_FAILURE;
8468
8469 ENTER();
8470
8471 if (NULL == pAdapter)
8472 {
8473 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8474 "%s: HDD adapter is Null", __func__);
8475 return -ENODEV;
8476 }
8477
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308478 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308479
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308480 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308481 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308482 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8483 "%s: HDD context is not valid", __func__);
8484 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308485 }
8486
8487 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8488 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8489 if (NULL == hHal)
8490 {
8491 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8492 "%s: HAL context is Null!!!", __func__);
8493 return -EAGAIN;
8494 }
8495
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308496 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8497 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8498 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8499 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308500 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308501 {
8502 /* changing from big to little endian since driver
8503 * works on little endian format
8504 */
8505 tANI_U8 *p =
8506 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8507 int i;
8508
8509 for (i = 0; i < 8; i++)
8510 {
8511 p[7-i] = data->replay_ctr[i];
8512 }
8513 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308514
8515 if (TRUE == pHddCtx->hdd_wlan_suspended)
8516 {
8517 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308518 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8519 sizeof (tSirGtkOffloadParams));
8520 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308521 pAdapter->sessionId);
8522
8523 if (eHAL_STATUS_SUCCESS != status)
8524 {
8525 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8526 "%s: sme_SetGTKOffload failed, returned %d",
8527 __func__, status);
8528 return status;
8529 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8531 "%s: sme_SetGTKOffload successfull", __func__);
8532 }
8533 else
8534 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8536 "%s: wlan not suspended GTKOffload request is stored",
8537 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308538 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308539
8540 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308541}
8542#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8543
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308544/*
8545 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8546 * This function is used to set access control policy
8547 */
8548static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8549 struct net_device *dev, const struct cfg80211_acl_data *params)
8550{
8551 int i;
8552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8553 hdd_hostapd_state_t *pHostapdState;
8554 tsap_Config_t *pConfig;
8555 v_CONTEXT_t pVosContext = NULL;
8556 hdd_context_t *pHddCtx;
8557 int status;
8558
8559 ENTER();
8560
8561 if (NULL == pAdapter)
8562 {
8563 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8564 "%s: HDD adapter is Null", __func__);
8565 return -ENODEV;
8566 }
8567
8568 if (NULL == params)
8569 {
8570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8571 "%s: params is Null", __func__);
8572 return -EINVAL;
8573 }
8574
8575 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8576 status = wlan_hdd_validate_context(pHddCtx);
8577
8578 if (0 != status)
8579 {
8580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8581 "%s: HDD context is not valid", __func__);
8582 return status;
8583 }
8584
8585 pVosContext = pHddCtx->pvosContext;
8586 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8587
8588 if (NULL == pHostapdState)
8589 {
8590 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8591 "%s: pHostapdState is Null", __func__);
8592 return -EINVAL;
8593 }
8594
8595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8596 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8597
8598 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8599 {
8600 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8601
8602 /* default value */
8603 pConfig->num_accept_mac = 0;
8604 pConfig->num_deny_mac = 0;
8605
8606 /**
8607 * access control policy
8608 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8609 * listed in hostapd.deny file.
8610 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8611 * listed in hostapd.accept file.
8612 */
8613 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8614 {
8615 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8616 }
8617 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8618 {
8619 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8620 }
8621 else
8622 {
8623 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8624 "%s:Acl Policy : %d is not supported",
8625 __func__, params->acl_policy);
8626 return -ENOTSUPP;
8627 }
8628
8629 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8630 {
8631 pConfig->num_accept_mac = params->n_acl_entries;
8632 for (i = 0; i < params->n_acl_entries; i++)
8633 {
8634 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8635 "** Add ACL MAC entry %i in WhiletList :"
8636 MAC_ADDRESS_STR, i,
8637 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8638
8639 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8640 sizeof(qcmacaddr));
8641 }
8642 }
8643 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8644 {
8645 pConfig->num_deny_mac = params->n_acl_entries;
8646 for (i = 0; i < params->n_acl_entries; i++)
8647 {
8648 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8649 "** Add ACL MAC entry %i in BlackList :"
8650 MAC_ADDRESS_STR, i,
8651 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8652
8653 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8654 sizeof(qcmacaddr));
8655 }
8656 }
8657
8658 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8659 {
8660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8661 "%s: SAP Set Mac Acl fail", __func__);
8662 return -EINVAL;
8663 }
8664 }
8665 else
8666 {
8667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8668 "%s: Invalid device_mode = %d",
8669 __func__, pAdapter->device_mode);
8670 return -EINVAL;
8671 }
8672
8673 return 0;
8674}
8675
Leo Chang9056f462013-08-01 19:21:11 -07008676#ifdef WLAN_NL80211_TESTMODE
8677#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008678void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008679(
8680 void *pAdapter,
8681 void *indCont
8682)
8683{
Leo Changd9df8aa2013-09-26 13:32:26 -07008684 tSirLPHBInd *lphbInd;
8685 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008686
8687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008688 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008689
8690 if (NULL == indCont)
8691 {
8692 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008693 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008694 return;
8695 }
8696
Leo Changd9df8aa2013-09-26 13:32:26 -07008697 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008698 skb = cfg80211_testmode_alloc_event_skb(
8699 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008700 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008701 GFP_ATOMIC);
8702 if (!skb)
8703 {
8704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8705 "LPHB timeout, NL buffer alloc fail");
8706 return;
8707 }
8708
Leo Changd9df8aa2013-09-26 13:32:26 -07008709 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
8710 {
8711 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8712 "WLAN_HDD_TM_ATTR_CMD put fail");
8713 goto nla_put_failure;
8714 }
8715 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
8716 {
8717 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8718 "WLAN_HDD_TM_ATTR_TYPE put fail");
8719 goto nla_put_failure;
8720 }
8721 if(!nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
8722 sizeof(tSirLPHBInd), lphbInd))
8723 {
8724 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8725 "WLAN_HDD_TM_ATTR_DATA put fail");
8726 goto nla_put_failure;
8727 }
Leo Chang9056f462013-08-01 19:21:11 -07008728 cfg80211_testmode_event(skb, GFP_ATOMIC);
8729 return;
8730
8731nla_put_failure:
8732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8733 "NLA Put fail");
8734 kfree_skb(skb);
8735
8736 return;
8737}
8738#endif /* FEATURE_WLAN_LPHB */
8739
8740static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8741{
8742 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8743 int err = 0;
8744#ifdef FEATURE_WLAN_LPHB
8745 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008746 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008747#endif /* FEATURE_WLAN_LPHB */
8748
8749 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8750 if (err)
8751 {
8752 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8753 "%s Testmode INV ATTR", __func__);
8754 return err;
8755 }
8756
8757 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8758 {
8759 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8760 "%s Testmode INV CMD", __func__);
8761 return -EINVAL;
8762 }
8763
8764 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8765 {
8766#ifdef FEATURE_WLAN_LPHB
8767 /* Low Power Heartbeat configuration request */
8768 case WLAN_HDD_TM_CMD_WLAN_HB:
8769 {
8770 int buf_len;
8771 void *buf;
8772 tSirLPHBReq *hb_params = NULL;
8773
8774 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8775 {
8776 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8777 "%s Testmode INV DATA", __func__);
8778 return -EINVAL;
8779 }
8780
8781 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8782 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8783 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8784 if (NULL == hb_params)
8785 {
8786 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8787 "%s Request Buffer Alloc Fail", __func__);
8788 return -EINVAL;
8789 }
8790
8791 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008792 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8793 hb_params,
8794 wlan_hdd_cfg80211_lphb_ind_handler);
8795 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008796 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008797 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8798 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008799 vos_mem_free(hb_params);
8800 }
Leo Chang9056f462013-08-01 19:21:11 -07008801 return 0;
8802 }
8803#endif /* FEATURE_WLAN_LPHB */
8804 default:
8805 return -EOPNOTSUPP;
8806 }
8807
8808 return err;
8809}
8810#endif /* CONFIG_NL80211_TESTMODE */
8811
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308812static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8813 struct net_device *dev,
8814 int idx, struct survey_info *survey)
8815{
8816 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8817 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308818 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308819 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308820 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308821 v_S7_t snr,rssi;
8822 int status, i, j, filled = 0;
8823
8824 ENTER();
8825
8826
8827 if (NULL == pAdapter)
8828 {
8829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8830 "%s: HDD adapter is Null", __func__);
8831 return -ENODEV;
8832 }
8833
8834 if (NULL == wiphy)
8835 {
8836 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8837 "%s: wiphy is Null", __func__);
8838 return -ENODEV;
8839 }
8840
8841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8842 status = wlan_hdd_validate_context(pHddCtx);
8843
8844 if (0 != status)
8845 {
8846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8847 "%s: HDD context is not valid", __func__);
8848 return status;
8849 }
8850
Mihir Sheted9072e02013-08-21 17:02:29 +05308851 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8852
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308853 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308854 0 != pAdapter->survey_idx ||
8855 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308856 {
8857 /* The survey dump ops when implemented completely is expected to
8858 * return a survey of all channels and the ops is called by the
8859 * kernel with incremental values of the argument 'idx' till it
8860 * returns -ENONET. But we can only support the survey for the
8861 * operating channel for now. survey_idx is used to track
8862 * that the ops is called only once and then return -ENONET for
8863 * the next iteration
8864 */
8865 pAdapter->survey_idx = 0;
8866 return -ENONET;
8867 }
8868
8869 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8870
8871 wlan_hdd_get_snr(pAdapter, &snr);
8872 wlan_hdd_get_rssi(pAdapter, &rssi);
8873
8874 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8875 hdd_wlan_get_freq(channel, &freq);
8876
8877
8878 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8879 {
8880 if (NULL == wiphy->bands[i])
8881 {
8882 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8883 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8884 continue;
8885 }
8886
8887 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8888 {
8889 struct ieee80211_supported_band *band = wiphy->bands[i];
8890
8891 if (band->channels[j].center_freq == (v_U16_t)freq)
8892 {
8893 survey->channel = &band->channels[j];
8894 /* The Rx BDs contain SNR values in dB for the received frames
8895 * while the supplicant expects noise. So we calculate and
8896 * return the value of noise (dBm)
8897 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8898 */
8899 survey->noise = rssi - snr;
8900 survey->filled = SURVEY_INFO_NOISE_DBM;
8901 filled = 1;
8902 }
8903 }
8904 }
8905
8906 if (filled)
8907 pAdapter->survey_idx = 1;
8908 else
8909 {
8910 pAdapter->survey_idx = 0;
8911 return -ENONET;
8912 }
8913
8914 return 0;
8915}
8916
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308917/*
8918 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
8919 * this is called when cfg80211 driver resume
8920 * driver updates latest sched_scan scan result(if any) to cfg80211 database
8921 */
8922int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
8923{
8924 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8925 hdd_adapter_t *pAdapter;
8926 hdd_adapter_list_node_t *pAdapterNode, *pNext;
8927 VOS_STATUS status = VOS_STATUS_SUCCESS;
8928
8929 ENTER();
8930
8931 if ( NULL == pHddCtx )
8932 {
8933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8934 "%s: HddCtx validation failed", __func__);
8935 return 0;
8936 }
8937
8938 if (pHddCtx->isLogpInProgress)
8939 {
8940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8941 "%s: LOGP in Progress. Ignore!!!", __func__);
8942 return 0;
8943 }
8944
8945 if (pHddCtx->isLoadUnloadInProgress)
8946 {
8947 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8948 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8949 return 0;
8950 }
8951
8952 spin_lock(&pHddCtx->schedScan_lock);
8953 pHddCtx->isWiphySuspended = FALSE;
8954 if (TRUE != pHddCtx->isSchedScanUpdatePending)
8955 {
8956 spin_unlock(&pHddCtx->schedScan_lock);
8957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8958 "%s: Return resume is not due to PNO indication", __func__);
8959 return 0;
8960 }
8961 // Reset flag to avoid updatating cfg80211 data old results again
8962 pHddCtx->isSchedScanUpdatePending = FALSE;
8963 spin_unlock(&pHddCtx->schedScan_lock);
8964
8965 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8966
8967 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8968 {
8969 pAdapter = pAdapterNode->pAdapter;
8970 if ( (NULL != pAdapter) &&
8971 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
8972 {
8973 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
8974 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8975 "%s: NO SCAN result", __func__);
8976 else
8977 cfg80211_sched_scan_results(pHddCtx->wiphy);
8978
8979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8980 "%s : cfg80211 scan result database updated", __func__);
8981
8982 return 0;
8983
8984 }
8985 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8986 pAdapterNode = pNext;
8987 }
8988
8989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8990 "%s: Failed to find Adapter", __func__);
8991 return 0;
8992}
8993
8994/*
8995 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
8996 * this is called when cfg80211 driver suspends
8997 */
8998int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
8999 struct cfg80211_wowlan *wow)
9000{
9001 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9002
9003 ENTER();
9004 if (NULL == pHddCtx)
9005 {
9006 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9007 "%s: HddCtx validation failed", __func__);
9008 return 0;
9009 }
9010
9011 pHddCtx->isWiphySuspended = TRUE;
9012
9013 EXIT();
9014
9015 return 0;
9016}
9017
Jeff Johnson295189b2012-06-20 16:38:30 -07009018/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309019static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009020{
9021 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9022 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9023 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9024 .change_station = wlan_hdd_change_station,
9025#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9026 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9027 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9028 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009029#else
9030 .start_ap = wlan_hdd_cfg80211_start_ap,
9031 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9032 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009033#endif
9034 .change_bss = wlan_hdd_cfg80211_change_bss,
9035 .add_key = wlan_hdd_cfg80211_add_key,
9036 .get_key = wlan_hdd_cfg80211_get_key,
9037 .del_key = wlan_hdd_cfg80211_del_key,
9038 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009039#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009040 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009041#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009042 .scan = wlan_hdd_cfg80211_scan,
9043 .connect = wlan_hdd_cfg80211_connect,
9044 .disconnect = wlan_hdd_cfg80211_disconnect,
9045 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9046 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9047 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9048 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9049 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009050 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9051 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9052 .mgmt_tx = wlan_hdd_action,
9053#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9054 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9055 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9056 .set_txq_params = wlan_hdd_set_txq_params,
9057#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 .get_station = wlan_hdd_cfg80211_get_station,
9059 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9060 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009061 .add_station = wlan_hdd_cfg80211_add_station,
9062#ifdef FEATURE_WLAN_LFR
9063 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9064 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9065 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9066#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009067#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9068 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9069#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009070#ifdef FEATURE_WLAN_TDLS
9071 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9072 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9073#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309074#ifdef WLAN_FEATURE_GTK_OFFLOAD
9075 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9076#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309077#ifdef FEATURE_WLAN_SCAN_PNO
9078 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9079 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9080#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309081 .resume = wlan_hdd_cfg80211_resume_wlan,
9082 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309083 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009084#ifdef WLAN_NL80211_TESTMODE
9085 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9086#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309087 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009088};
9089