blob: a02e96e982df66fb5598bcc8a2c8ccc99b7bc187 [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 }
2713
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 //De-init the adapter.
2715 hdd_stop_adapter( pHddCtx, pAdapter );
2716 hdd_deinit_adapter( pHddCtx, pAdapter );
2717 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2719 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002720
2721 //Disable BMPS and IMPS if enabled
2722 //before starting Go
2723 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2724 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302725 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002726 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2727 {
2728 //Fail to Exit BMPS
2729 VOS_ASSERT(0);
2730 }
2731 }
2732
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002733 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2734 (pConfig->apRandomBssidEnabled))
2735 {
2736 /* To meet Android requirements create a randomized
2737 MAC address of the form 02:1A:11:Fx:xx:xx */
2738 get_random_bytes(&ndev->dev_addr[3], 3);
2739 ndev->dev_addr[0] = 0x02;
2740 ndev->dev_addr[1] = 0x1A;
2741 ndev->dev_addr[2] = 0x11;
2742 ndev->dev_addr[3] |= 0xF0;
2743 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2744 VOS_MAC_ADDR_SIZE);
2745 pr_info("wlan: Generated HotSpot BSSID "
2746 "%02x:%02x:%02x:%02x:%02x:%02x\n",
2747 ndev->dev_addr[0],
2748 ndev->dev_addr[1],
2749 ndev->dev_addr[2],
2750 ndev->dev_addr[3],
2751 ndev->dev_addr[4],
2752 ndev->dev_addr[5]);
2753 }
2754
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 hdd_set_ap_ops( pAdapter->dev );
2756
2757 status = hdd_init_ap_mode(pAdapter);
2758 if(status != VOS_STATUS_SUCCESS)
2759 {
2760 hddLog(VOS_TRACE_LEVEL_FATAL,
2761 "%s: Error initializing the ap mode", __func__);
2762 return -EINVAL;
2763 }
2764 hdd_set_conparam(1);
2765
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 /*interface type changed update in wiphy structure*/
2767 if(wdev)
2768 {
2769 wdev->iftype = type;
2770 pHddCtx->change_iface = type;
2771 }
2772 else
2773 {
2774 hddLog(VOS_TRACE_LEVEL_ERROR,
2775 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2776 return -EINVAL;
2777 }
2778 goto done;
2779 }
2780
2781 default:
2782 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2783 __func__);
2784 return -EOPNOTSUPP;
2785 }
2786 }
2787 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 )
2790 {
2791 switch(type)
2792 {
2793 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 case NL80211_IFTYPE_ADHOC:
Jeff Johnson32d95a32012-09-10 13:15:23 -07002796 hdd_stop_adapter( pHddCtx, pAdapter );
2797 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002799 //Check for sub-string p2p to confirm its a p2p interface
2800 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002801 {
2802 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2803 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2804 }
2805 else
2806 {
2807 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 hdd_set_conparam(0);
2811 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2813 hdd_set_station_ops( pAdapter->dev );
2814 status = hdd_init_station_mode( pAdapter );
2815 if( VOS_STATUS_SUCCESS != status )
2816 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002817 /* In case of JB, for P2P-GO, only change interface will be called,
2818 * This is the right place to enable back bmps_imps()
2819 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302820 if (pHddCtx->hdd_wlan_suspended)
2821 {
2822 hdd_set_pwrparams(pHddCtx);
2823 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002824 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 goto done;
2826 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2830 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 goto done;
2832 default:
2833 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2834 __func__);
2835 return -EOPNOTSUPP;
2836
2837 }
2838
2839 }
2840 else
2841 {
2842 return -EOPNOTSUPP;
2843 }
2844
2845
2846 if(pRoamProfile)
2847 {
2848 if ( LastBSSType != pRoamProfile->BSSType )
2849 {
2850 /*interface type changed update in wiphy structure*/
2851 wdev->iftype = type;
2852
2853 /*the BSS mode changed, We need to issue disconnect
2854 if connected or in IBSS disconnect state*/
2855 if ( hdd_connGetConnectedBssType(
2856 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2857 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2858 {
2859 /*need to issue a disconnect to CSR.*/
2860 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2861 if( eHAL_STATUS_SUCCESS ==
2862 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2863 pAdapter->sessionId,
2864 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2865 {
2866 wait_for_completion_interruptible_timeout(
2867 &pAdapter->disconnect_comp_var,
2868 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2869 }
2870 }
2871 }
2872 }
2873
2874done:
2875 /*set bitmask based on updated value*/
2876 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002877
2878 /* Only STA mode support TM now
2879 * all other mode, TM feature should be disabled */
2880 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2881 (~VOS_STA & pHddCtx->concurrency_mode) )
2882 {
2883 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2884 }
2885
Jeff Johnson295189b2012-06-20 16:38:30 -07002886#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302887 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2889 {
2890 //we are ok to do AMP
2891 pHddCtx->isAmpAllowed = VOS_TRUE;
2892 }
2893#endif //WLAN_BTAMP_FEATURE
2894 EXIT();
2895 return 0;
2896}
2897
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002898#ifdef FEATURE_WLAN_TDLS
2899static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2900 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2901{
2902 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2903 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2904 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002905 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002906
2907 ENTER();
2908
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302909 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002910 {
2911 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2912 "Invalid arguments");
2913 return -EINVAL;
2914 }
Hoonki Lee27511902013-03-14 18:19:06 -07002915
2916 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
2917 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
2918 {
2919 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2920 "%s: TDLS mode is disabled OR not enabled in FW."
2921 MAC_ADDRESS_STR " Request declined.",
2922 __func__, MAC_ADDR_ARRAY(mac));
2923 return -ENOTSUPP;
2924 }
2925
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002926 if (pHddCtx->isLogpInProgress)
2927 {
2928 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2929 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07002930 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002931 return -EBUSY;
2932 }
2933
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002934 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
2935
2936 if ( NULL == pTdlsPeer ) {
2937 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2938 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
2939 __func__, MAC_ADDR_ARRAY(mac), update);
2940 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002941 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002942
2943 /* in add station, we accept existing valid staId if there is */
2944 if ((0 == update) &&
2945 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
2946 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002947 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002948 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002949 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002950 " link_status %d. staId %d. add station ignored.",
2951 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
2952 return 0;
2953 }
2954 /* in change station, we accept only when staId is valid */
2955 if ((1 == update) &&
2956 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
2957 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
2958 {
2959 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
2960 "%s: " MAC_ADDRESS_STR
2961 " link status %d. staId %d. change station %s.",
2962 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
2963 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
2964 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002965 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07002966
2967 /* when others are on-going, we want to change link_status to idle */
Hoonki Leefb8df672013-04-10 18:20:34 -07002968 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002969 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2971 "%s: " MAC_ADDRESS_STR
2972 " TDLS setup is ongoing. Request declined.",
2973 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002974 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002975 }
2976
2977 /* first to check if we reached to maximum supported TDLS peer.
2978 TODO: for now, return -EPERM looks working fine,
2979 but need to check if any other errno fit into this category.*/
2980 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
2981 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002982 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2983 "%s: " MAC_ADDRESS_STR
2984 " TDLS Max peer already connected. Request declined.",
2985 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07002986 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002987 }
2988 else
2989 {
2990 hddTdlsPeer_t *pTdlsPeer;
2991 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002992 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002993 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07002994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2995 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
2996 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002997 return -EPERM;
2998 }
2999 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003000 if (0 == update)
3001 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003002
Jeff Johnsond75fe012013-04-06 10:53:06 -07003003 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303004 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003005 {
3006 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3007 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003008 if(StaParams->htcap_present)
3009 {
3010 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3011 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3012 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3013 "ht_capa->extended_capabilities: %0x",
3014 StaParams->HTCap.extendedHtCapInfo);
3015 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003016 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3017 "params->capability: %0x",StaParams->capability);
3018 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3019 "params->ext_capab_len: %0x",StaParams->extn_capability);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003020 if(StaParams->vhtcap_present)
3021 {
3022 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3023 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3024 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3025 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3026 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003027 {
3028 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003029 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003030 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3031 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3032 "[%d]: %x ", i, StaParams->supported_rates[i]);
3033 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003034 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303035 else if ((1 == update) && (NULL == StaParams))
3036 {
3037 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3038 "%s : update is true, but staParams is NULL. Error!", __func__);
3039 return -EPERM;
3040 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003041
3042 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3043
3044 if (!update)
3045 {
3046 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3047 pAdapter->sessionId, mac);
3048 }
3049 else
3050 {
3051 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3052 pAdapter->sessionId, mac, StaParams);
3053 }
3054
3055 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3056 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3057
3058 if (!status)
3059 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003061 "%s: timeout waiting for tdls add station indication",
3062 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003063 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003064 }
3065 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3066 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003068 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003069 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003070 }
3071
3072 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003073
3074error:
3075 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3076 return -EPERM;
3077
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003078}
3079#endif
3080
Jeff Johnson295189b2012-06-20 16:38:30 -07003081static int wlan_hdd_change_station(struct wiphy *wiphy,
3082 struct net_device *dev,
3083 u8 *mac,
3084 struct station_parameters *params)
3085{
3086 VOS_STATUS status = VOS_STATUS_SUCCESS;
3087 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303088 hdd_context_t *pHddCtx;
3089 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003091#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003092 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003093 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003094#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003095 ENTER();
3096
Gopichand Nakkala29149562013-05-10 21:43:41 +05303097 if ((NULL == pAdapter))
3098 {
3099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3100 "invalid adapter ");
3101 return -EINVAL;
3102 }
3103
3104 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3105 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3106
3107 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3108 {
3109 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3110 "invalid HDD state or HDD station context");
3111 return -EINVAL;
3112 }
3113
3114 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003115 {
3116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3117 "%s:LOGP in Progress. Ignore!!!", __func__);
3118 return -EAGAIN;
3119 }
3120
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3122
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003123 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3124 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003126 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303128 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 WLANTL_STA_AUTHENTICATED);
3130
Gopichand Nakkala29149562013-05-10 21:43:41 +05303131 if (status != VOS_STATUS_SUCCESS)
3132 {
3133 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3134 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3135 return -EINVAL;
3136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 }
3138 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003139 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3140 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303141#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003142 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3143 StaParams.capability = params->capability;
3144 StaParams.uapsd_queues = params->uapsd_queues;
3145 StaParams.max_sp = params->max_sp;
3146
3147 if (0 != params->ext_capab_len)
3148 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3149 sizeof(StaParams.extn_capability));
3150
3151 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003152 {
3153 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003154 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003155 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003156
3157 StaParams.supported_rates_len = params->supported_rates_len;
3158
3159 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3160 * The supported_rates array , for all the structures propogating till Add Sta
3161 * to the firmware has to be modified , if the supplicant (ieee80211) is
3162 * modified to send more rates.
3163 */
3164
3165 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3166 */
3167 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3168 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3169
3170 if (0 != StaParams.supported_rates_len) {
3171 int i = 0;
3172 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3173 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003174 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003175 "Supported Rates with Length %d", StaParams.supported_rates_len);
3176 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003177 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003178 "[%d]: %0x", i, StaParams.supported_rates[i]);
3179 }
3180
3181 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003182 {
3183 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003184 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003185 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003186
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003187 if (0 != params->ext_capab_len ) {
3188 /*Define A Macro : TODO Sunil*/
3189 if ((1<<4) & StaParams.extn_capability[3]) {
3190 isBufSta = 1;
3191 }
3192 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303193 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3194 params->max_sp, isBufSta);
3195 if (VOS_STATUS_SUCCESS != status) {
3196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3197 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3198 return -EINVAL;
3199 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003200 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3201
3202 if (VOS_STATUS_SUCCESS != status) {
3203 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3204 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3205 return -EINVAL;
3206 }
3207 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003208#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303209 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003210 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 return status;
3212}
3213
3214/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 * FUNCTION: wlan_hdd_cfg80211_add_key
3216 * This function is used to initialize the key information
3217 */
3218#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003219static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 struct net_device *ndev,
3221 u8 key_index, bool pairwise,
3222 const u8 *mac_addr,
3223 struct key_params *params
3224 )
3225#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003226static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 struct net_device *ndev,
3228 u8 key_index, const u8 *mac_addr,
3229 struct key_params *params
3230 )
3231#endif
3232{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003233 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 tCsrRoamSetKey setKey;
3235 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303236 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003237 v_U32_t roamId= 0xFF;
3238 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 hdd_hostapd_state_t *pHostapdState;
3240 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003241 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303242 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003243
3244 ENTER();
3245
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303246 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3247 status = wlan_hdd_validate_context(pHddCtx);
3248
3249 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003250 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3252 "%s: HDD context is not valid", __func__);
3253 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003254 }
3255
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003256 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3257 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003258
3259 if (CSR_MAX_NUM_KEY <= key_index)
3260 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003261 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003262 key_index);
3263
3264 return -EINVAL;
3265 }
3266
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003267 if (CSR_MAX_KEY_LEN < params->key_len)
3268 {
3269 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3270 params->key_len);
3271
3272 return -EINVAL;
3273 }
3274
3275 hddLog(VOS_TRACE_LEVEL_INFO,
3276 "%s: called with key index = %d & key length %d",
3277 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003278
3279 /*extract key idx, key len and key*/
3280 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3281 setKey.keyId = key_index;
3282 setKey.keyLength = params->key_len;
3283 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3284
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003285 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 {
3287 case WLAN_CIPHER_SUITE_WEP40:
3288 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3289 break;
3290
3291 case WLAN_CIPHER_SUITE_WEP104:
3292 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3293 break;
3294
3295 case WLAN_CIPHER_SUITE_TKIP:
3296 {
3297 u8 *pKey = &setKey.Key[0];
3298 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3299
3300 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3301
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003302 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003303
3304 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003305 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 |--------------|----------|----------|
3307 <---16bytes---><--8bytes--><--8bytes-->
3308
3309 */
3310 /*Sme expects the 32 bytes key to be in the below order
3311
3312 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003313 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 |--------------|----------|----------|
3315 <---16bytes---><--8bytes--><--8bytes-->
3316 */
3317 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003318 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003319
3320 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003321 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003322
3323 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003324 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003325
3326
3327 break;
3328 }
3329
3330 case WLAN_CIPHER_SUITE_CCMP:
3331 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3332 break;
3333
3334#ifdef FEATURE_WLAN_WAPI
3335 case WLAN_CIPHER_SUITE_SMS4:
3336 {
3337 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3338 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3339 params->key, params->key_len);
3340 return 0;
3341 }
3342#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003343
Jeff Johnson295189b2012-06-20 16:38:30 -07003344#ifdef FEATURE_WLAN_CCX
3345 case WLAN_CIPHER_SUITE_KRK:
3346 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3347 break;
3348#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003349
3350#ifdef WLAN_FEATURE_11W
3351 case WLAN_CIPHER_SUITE_AES_CMAC:
3352 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003353 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003354#endif
3355
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 default:
3357 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %lu",
3358 __func__, params->cipher);
3359 return -EOPNOTSUPP;
3360 }
3361
3362 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3363 __func__, setKey.encType);
3364
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003365 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003366#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3367 (!pairwise)
3368#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003369 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003370#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003371 )
3372 {
3373 /* set group key*/
3374 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3375 "%s- %d: setting Broadcast key",
3376 __func__, __LINE__);
3377 setKey.keyDirection = eSIR_RX_ONLY;
3378 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3379 }
3380 else
3381 {
3382 /* set pairwise key*/
3383 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3384 "%s- %d: setting pairwise key",
3385 __func__, __LINE__);
3386 setKey.keyDirection = eSIR_TX_RX;
3387 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3388 }
3389 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3390 {
3391 setKey.keyDirection = eSIR_TX_RX;
3392 /*Set the group key*/
3393 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3394 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003395
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003396 if ( 0 != status )
3397 {
3398 hddLog(VOS_TRACE_LEVEL_ERROR,
3399 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3400 return -EINVAL;
3401 }
3402 /*Save the keys here and call sme_RoamSetKey for setting
3403 the PTK after peer joins the IBSS network*/
3404 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3405 &setKey, sizeof(tCsrRoamSetKey));
3406 return status;
3407 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303408 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3409 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3410 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003412 if( pHostapdState->bssState == BSS_START )
3413 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3415
3416 if ( status != eHAL_STATUS_SUCCESS )
3417 {
3418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3419 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3420 __LINE__, status );
3421 }
3422 }
3423
3424 /* Saving WEP keys */
3425 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3426 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3427 {
3428 //Save the wep key in ap context. Issue setkey after the BSS is started.
3429 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3430 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3431 }
3432 else
3433 {
3434 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003435 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3437 }
3438 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003439 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3440 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 {
3442 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3443 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3444
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303445#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3446 if (!pairwise)
3447#else
3448 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3449#endif
3450 {
3451 /* set group key*/
3452 if (pHddStaCtx->roam_info.deferKeyComplete)
3453 {
3454 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3455 "%s- %d: Perform Set key Complete",
3456 __func__, __LINE__);
3457 hdd_PerformRoamSetKeyComplete(pAdapter);
3458 }
3459 }
3460
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3462
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003463 pWextState->roamProfile.Keys.defaultIndex = key_index;
3464
3465
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003466 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 params->key, params->key_len);
3468
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303469
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3471
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303472 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003473 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303474 __func__, setKey.peerMac[0], setKey.peerMac[1],
3475 setKey.peerMac[2], setKey.peerMac[3],
3476 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 setKey.keyDirection);
3478
3479 vos_status = wlan_hdd_check_ula_done(pAdapter);
3480
3481 if ( vos_status != VOS_STATUS_SUCCESS )
3482 {
3483 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3484 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3485 __LINE__, vos_status );
3486
3487 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3488
3489 return -EINVAL;
3490
3491 }
3492
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003493#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303494 /* The supplicant may attempt to set the PTK once pre-authentication
3495 is done. Save the key in the UMAC and include it in the ADD BSS
3496 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003497 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303498 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003499 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303500 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3501 "%s: Update PreAuth Key success", __func__);
3502 return 0;
3503 }
3504 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3505 {
3506 hddLog(VOS_TRACE_LEVEL_ERROR,
3507 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303508 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003509 }
3510#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003511
3512 /* issue set key request to SME*/
3513 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3514 pAdapter->sessionId, &setKey, &roamId );
3515
3516 if ( 0 != status )
3517 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303518 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3520 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3521 return -EINVAL;
3522 }
3523
3524
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303525 /* in case of IBSS as there was no information available about WEP keys during
3526 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003527 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303528 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3529 !( ( IW_AUTH_KEY_MGMT_802_1X
3530 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3532 )
3533 &&
3534 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3535 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3536 )
3537 )
3538 {
3539 setKey.keyDirection = eSIR_RX_ONLY;
3540 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3541
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303542 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303544 __func__, setKey.peerMac[0], setKey.peerMac[1],
3545 setKey.peerMac[2], setKey.peerMac[3],
3546 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 setKey.keyDirection);
3548
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303549 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 pAdapter->sessionId, &setKey, &roamId );
3551
3552 if ( 0 != status )
3553 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303554 hddLog(VOS_TRACE_LEVEL_ERROR,
3555 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 __func__, status);
3557 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3558 return -EINVAL;
3559 }
3560 }
3561 }
3562
3563 return 0;
3564}
3565
3566/*
3567 * FUNCTION: wlan_hdd_cfg80211_get_key
3568 * This function is used to get the key information
3569 */
3570#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303571static int wlan_hdd_cfg80211_get_key(
3572 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303574 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 const u8 *mac_addr, void *cookie,
3576 void (*callback)(void *cookie, struct key_params*)
3577 )
3578#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303579static int wlan_hdd_cfg80211_get_key(
3580 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 struct net_device *ndev,
3582 u8 key_index, const u8 *mac_addr, void *cookie,
3583 void (*callback)(void *cookie, struct key_params*)
3584 )
3585#endif
3586{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303587 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003588 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3589 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3590 struct key_params params;
3591
3592 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303593
Jeff Johnson295189b2012-06-20 16:38:30 -07003594 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3595 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303596
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 memset(&params, 0, sizeof(params));
3598
3599 if (CSR_MAX_NUM_KEY <= key_index)
3600 {
3601 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003603
3604 switch(pRoamProfile->EncryptionType.encryptionType[0])
3605 {
3606 case eCSR_ENCRYPT_TYPE_NONE:
3607 params.cipher = IW_AUTH_CIPHER_NONE;
3608 break;
3609
3610 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3611 case eCSR_ENCRYPT_TYPE_WEP40:
3612 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3613 break;
3614
3615 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3616 case eCSR_ENCRYPT_TYPE_WEP104:
3617 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3618 break;
3619
3620 case eCSR_ENCRYPT_TYPE_TKIP:
3621 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3622 break;
3623
3624 case eCSR_ENCRYPT_TYPE_AES:
3625 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3626 break;
3627
3628 default:
3629 params.cipher = IW_AUTH_CIPHER_NONE;
3630 break;
3631 }
3632
3633 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3634 params.seq_len = 0;
3635 params.seq = NULL;
3636 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3637 callback(cookie, &params);
3638 return 0;
3639}
3640
3641/*
3642 * FUNCTION: wlan_hdd_cfg80211_del_key
3643 * This function is used to delete the key information
3644 */
3645#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303646static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303648 u8 key_index,
3649 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 const u8 *mac_addr
3651 )
3652#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303653static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 struct net_device *ndev,
3655 u8 key_index,
3656 const u8 *mac_addr
3657 )
3658#endif
3659{
3660 int status = 0;
3661
3662 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303663 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 //it is observed that this is invalidating peer
3665 //key index whenever re-key is done. This is affecting data link.
3666 //It should be ok to ignore del_key.
3667#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303668 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3669 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3671 tCsrRoamSetKey setKey;
3672 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303673
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 ENTER();
3675
3676 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3677 __func__,pAdapter->device_mode);
3678
3679 if (CSR_MAX_NUM_KEY <= key_index)
3680 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303681 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 key_index);
3683
3684 return -EINVAL;
3685 }
3686
3687 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3688 setKey.keyId = key_index;
3689
3690 if (mac_addr)
3691 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3692 else
3693 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3694
3695 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3696
3697 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303699 )
3700 {
3701
3702 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3704 if( pHostapdState->bssState == BSS_START)
3705 {
3706 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303707
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 if ( status != eHAL_STATUS_SUCCESS )
3709 {
3710 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3711 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3712 __LINE__, status );
3713 }
3714 }
3715 }
3716 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303717 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 )
3719 {
3720 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3721
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303722 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3723
3724 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303726 __func__, setKey.peerMac[0], setKey.peerMac[1],
3727 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303729 if(pAdapter->sessionCtx.station.conn_info.connState ==
3730 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303732 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303734
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 if ( 0 != status )
3736 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303737 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 "%s: sme_RoamSetKey failure, returned %d",
3739 __func__, status);
3740 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3741 return -EINVAL;
3742 }
3743 }
3744 }
3745#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003746 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 return status;
3748}
3749
3750/*
3751 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3752 * This function is used to set the default tx key index
3753 */
3754#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3755static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3756 struct net_device *ndev,
3757 u8 key_index,
3758 bool unicast, bool multicast)
3759#else
3760static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3761 struct net_device *ndev,
3762 u8 key_index)
3763#endif
3764{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303765 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303766 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303767 hdd_wext_state_t *pWextState;
3768 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303769 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003770
3771 ENTER();
3772
Gopichand Nakkala29149562013-05-10 21:43:41 +05303773 if ((NULL == pAdapter))
3774 {
3775 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3776 "invalid adapter");
3777 return -EINVAL;
3778 }
3779
3780 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3781 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3782
3783 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3784 {
3785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3786 "invalid Wext state or HDD context");
3787 return -EINVAL;
3788 }
3789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3791 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303792
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 if (CSR_MAX_NUM_KEY <= key_index)
3794 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303795 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 key_index);
3797
3798 return -EINVAL;
3799 }
3800
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303801 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3802 status = wlan_hdd_validate_context(pHddCtx);
3803
3804 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003805 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303806 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3807 "%s: HDD context is not valid", __func__);
3808 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003809 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303810
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303813 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303815 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303817 (eCSR_ENCRYPT_TYPE_AES !=
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 pWextState->roamProfile.EncryptionType.encryptionType[0])
3819 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303820 {
3821 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003822 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303823
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 tCsrRoamSetKey setKey;
3825 v_U32_t roamId= 0xFF;
3826 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303827
3828 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303830
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 Keys->defaultIndex = (u8)key_index;
3832 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3833 setKey.keyId = key_index;
3834 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303835
3836 vos_mem_copy(&setKey.Key[0],
3837 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303839
Gopichand Nakkala29149562013-05-10 21:43:41 +05303840 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303841
3842 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 &pHddStaCtx->conn_info.bssId[0],
3844 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303845
Gopichand Nakkala29149562013-05-10 21:43:41 +05303846 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3847 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3848 eCSR_ENCRYPT_TYPE_WEP104)
3849 {
3850 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3851 even though ap is configured for WEP-40 encryption. In this canse the key length
3852 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3853 type(104) and switching encryption type to 40*/
3854 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3855 eCSR_ENCRYPT_TYPE_WEP40;
3856 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3857 eCSR_ENCRYPT_TYPE_WEP40;
3858 }
3859
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303860 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303862
Jeff Johnson295189b2012-06-20 16:38:30 -07003863 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303864 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303866
Jeff Johnson295189b2012-06-20 16:38:30 -07003867 if ( 0 != status )
3868 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303869 hddLog(VOS_TRACE_LEVEL_ERROR,
3870 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 status);
3872 return -EINVAL;
3873 }
3874 }
3875 }
3876
3877 /* In SoftAp mode setting key direction for default mode */
3878 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3879 {
3880 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3881 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3882 (eCSR_ENCRYPT_TYPE_AES !=
3883 pWextState->roamProfile.EncryptionType.encryptionType[0])
3884 )
3885 {
3886 /* Saving key direction for default key index to TX default */
3887 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3888 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3889 }
3890 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303891
Jeff Johnson295189b2012-06-20 16:38:30 -07003892 return status;
3893}
3894
Jeff Johnson295189b2012-06-20 16:38:30 -07003895/*
3896 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3897 * This function is used to inform the BSS details to nl80211 interface.
3898 */
3899static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3900 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3901{
3902 struct net_device *dev = pAdapter->dev;
3903 struct wireless_dev *wdev = dev->ieee80211_ptr;
3904 struct wiphy *wiphy = wdev->wiphy;
3905 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3906 int chan_no;
3907 int ie_length;
3908 const char *ie;
3909 unsigned int freq;
3910 struct ieee80211_channel *chan;
3911 int rssi = 0;
3912 struct cfg80211_bss *bss = NULL;
3913
3914 ENTER();
3915
3916 if( NULL == pBssDesc )
3917 {
3918 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
3919 return bss;
3920 }
3921
3922 chan_no = pBssDesc->channelId;
3923 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
3924 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
3925
3926 if( NULL == ie )
3927 {
3928 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
3929 return bss;
3930 }
3931
3932#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
3933 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
3934 {
3935 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
3936 }
3937 else
3938 {
3939 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
3940 }
3941#else
3942 freq = ieee80211_channel_to_frequency(chan_no);
3943#endif
3944
3945 chan = __ieee80211_get_channel(wiphy, freq);
3946
3947 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
3948 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
3949 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
3950 if (bss == NULL)
3951 {
3952 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
3953
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303954 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
3955 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 pBssDesc->capabilityInfo,
3957 pBssDesc->beaconInterval, ie, ie_length,
3958 rssi, GFP_KERNEL ));
3959}
3960 else
3961 {
3962 return bss;
3963 }
3964}
3965
3966
3967
3968/*
3969 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
3970 * This function is used to inform the BSS details to nl80211 interface.
3971 */
3972struct cfg80211_bss*
3973wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
3974 tSirBssDescription *bss_desc
3975 )
3976{
3977 /*
3978 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
3979 already exists in bss data base of cfg80211 for that particular BSS ID.
3980 Using cfg80211_inform_bss_frame to update the bss entry instead of
3981 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
3982 now there is no possibility to get the mgmt(probe response) frame from PE,
3983 converting bss_desc to ieee80211_mgmt(probe response) and passing to
3984 cfg80211_inform_bss_frame.
3985 */
3986 struct net_device *dev = pAdapter->dev;
3987 struct wireless_dev *wdev = dev->ieee80211_ptr;
3988 struct wiphy *wiphy = wdev->wiphy;
3989 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003990#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
3991 qcom_ie_age *qie_age = NULL;
3992 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
3993#else
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08003995#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 const char *ie =
3997 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
3998 unsigned int freq;
3999 struct ieee80211_channel *chan;
4000 struct ieee80211_mgmt *mgmt =
4001 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4002 struct cfg80211_bss *bss_status = NULL;
4003 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4004 int rssi = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07004005#ifdef WLAN_OPEN_SOURCE
4006 struct timespec ts;
4007#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004008
4009 ENTER();
4010
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004011 if (!mgmt)
4012 return NULL;
4013
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004015
4016#ifdef WLAN_OPEN_SOURCE
4017 /* Android does not want the timestamp from the frame.
4018 Instead it wants a monotonic increasing value */
4019 get_monotonic_boottime(&ts);
4020 mgmt->u.probe_resp.timestamp =
4021 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4022#else
4023 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4025 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004026
4027#endif
4028
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4030 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004031
4032#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4033 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4034 /* Assuming this is the last IE, copy at the end */
4035 ie_length -=sizeof(qcom_ie_age);
4036 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4037 qie_age->element_id = QCOM_VENDOR_IE_ID;
4038 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4039 qie_age->oui_1 = QCOM_OUI1;
4040 qie_age->oui_2 = QCOM_OUI2;
4041 qie_age->oui_3 = QCOM_OUI3;
4042 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4043 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4044#endif
4045
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304047 if (bss_desc->fProbeRsp)
4048 {
4049 mgmt->frame_control |=
4050 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4051 }
4052 else
4053 {
4054 mgmt->frame_control |=
4055 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004057
4058#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304059 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4061 {
4062 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4063 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304064 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4066
4067 {
4068 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4069 }
4070 else
4071 {
4072 kfree(mgmt);
4073 return NULL;
4074 }
4075#else
4076 freq = ieee80211_channel_to_frequency(chan_no);
4077#endif
4078 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004079 /*when the band is changed on the fly using the GUI, three things are done
4080 * 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)
4081 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4082 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4083 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4084 * and discards the channels correponding to previous band and calls back with zero bss results.
4085 * 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
4086 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4087 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4088 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4089 * So drop the bss and continue to next bss.
4090 */
4091 if(chan == NULL)
4092 {
4093 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004094 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004095 return NULL;
4096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304098 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 * */
4100 if (( eConnectionState_Associated ==
4101 pAdapter->sessionCtx.station.conn_info.connState ) &&
4102 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4103 pAdapter->sessionCtx.station.conn_info.bssId,
4104 WNI_CFG_BSSID_LEN)))
4105 {
4106 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4107 rssi = (pAdapter->rssi * 100);
4108 }
4109 else
4110 {
4111 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4112 }
4113
4114 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4115 frame_len, rssi, GFP_KERNEL);
4116 kfree(mgmt);
4117 return bss_status;
4118}
4119
4120/*
4121 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4122 * This function is used to update the BSS data base of CFG8011
4123 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304124struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 tCsrRoamInfo *pRoamInfo
4126 )
4127{
4128 tCsrRoamConnectedProfile roamProfile;
4129 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4130 struct cfg80211_bss *bss = NULL;
4131
4132 ENTER();
4133
4134 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4135 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4136
4137 if (NULL != roamProfile.pBssDesc)
4138 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304139 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 &roamProfile);
4141
4142 if (NULL == bss)
4143 {
4144 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4145 __func__);
4146 }
4147
4148 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4149 }
4150 else
4151 {
4152 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4153 __func__);
4154 }
4155 return bss;
4156}
4157
4158/*
4159 * FUNCTION: wlan_hdd_cfg80211_update_bss
4160 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304161static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4162 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004163 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304164{
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4166 tCsrScanResultInfo *pScanResult;
4167 eHalStatus status = 0;
4168 tScanResultHandle pResult;
4169 struct cfg80211_bss *bss_status = NULL;
4170
4171 ENTER();
4172
4173 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4174 {
4175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, "%s:LOGP in Progress. Ignore!!!",__func__);
4176 return -EAGAIN;
4177 }
4178
4179 /*
4180 * start getting scan results and populate cgf80211 BSS database
4181 */
4182 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4183
4184 /* no scan results */
4185 if (NULL == pResult)
4186 {
4187 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4188 return status;
4189 }
4190
4191 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4192
4193 while (pScanResult)
4194 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304195 /*
4196 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4197 * entry already exists in bss data base of cfg80211 for that
4198 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4199 * bss entry instead of cfg80211_inform_bss, But this call expects
4200 * mgmt packet as input. As of now there is no possibility to get
4201 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 * ieee80211_mgmt(probe response) and passing to c
4203 * fg80211_inform_bss_frame.
4204 * */
4205
4206 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4207 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304208
Jeff Johnson295189b2012-06-20 16:38:30 -07004209
4210 if (NULL == bss_status)
4211 {
4212 hddLog(VOS_TRACE_LEVEL_INFO,
4213 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4214 }
4215 else
4216 {
Yue Maf49ba872013-08-19 12:04:25 -07004217 cfg80211_put_bss(
4218#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4219 wiphy,
4220#endif
4221 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 }
4223
4224 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4225 }
4226
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304227 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004228
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304229 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004230}
4231
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004232void
4233hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4234{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304235 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004236 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4237 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4238 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004239} /****** end hddPrintMacAddr() ******/
4240
4241void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004242hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004243{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304244 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004245 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4246 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4247 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4248 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004249} /****** end hddPrintPmkId() ******/
4250
4251//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4252//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4253
4254//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4255//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4256
4257#define dump_bssid(bssid) \
4258 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004259 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4260 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4261 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004262 }
4263
4264#define dump_pmkid(pMac, pmkid) \
4265 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004266 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4267 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4268 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004269 }
4270
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004271#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004272/*
4273 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4274 * This function is used to notify the supplicant of a new PMKSA candidate.
4275 */
4276int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304277 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004278 int index, bool preauth )
4279{
Jeff Johnsone7245742012-09-05 17:12:55 -07004280#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004281 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004282 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004283
4284 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004285 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004286
4287 if( NULL == pRoamInfo )
4288 {
4289 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4290 return -EINVAL;
4291 }
4292
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004293 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4294 {
4295 dump_bssid(pRoamInfo->bssid);
4296 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004297 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004298 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004299#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304300 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004301}
4302#endif //FEATURE_WLAN_LFR
4303
Jeff Johnson295189b2012-06-20 16:38:30 -07004304/*
4305 * FUNCTION: hdd_cfg80211_scan_done_callback
4306 * scanning callback function, called after finishing scan
4307 *
4308 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304309static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4311{
4312 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304313 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004315 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4316 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 struct cfg80211_scan_request *req = NULL;
4318 int ret = 0;
4319
4320 ENTER();
4321
4322 hddLog(VOS_TRACE_LEVEL_INFO,
4323 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304324 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 __func__, halHandle, pContext, (int) scanId, (int) status);
4326
4327 //Block on scan req completion variable. Can't wait forever though.
4328 ret = wait_for_completion_interruptible_timeout(
4329 &pScanInfo->scan_req_completion_event,
4330 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4331 if (!ret)
4332 {
4333 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004334 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 }
4336
4337 if(pScanInfo->mScanPending != VOS_TRUE)
4338 {
4339 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004340 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 }
4342
4343 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304344 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 {
4346 hddLog(VOS_TRACE_LEVEL_INFO,
4347 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304348 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 (int) scanId);
4350 }
4351
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304352 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 pAdapter);
4354
4355 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304356 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004357
4358
4359 /* If any client wait scan result through WEXT
4360 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004361 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 {
4363 /* The other scan request waiting for current scan finish
4364 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004365 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004367 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004368 }
4369 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004370 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 {
4372 struct net_device *dev = pAdapter->dev;
4373 union iwreq_data wrqu;
4374 int we_event;
4375 char *msg;
4376
4377 memset(&wrqu, '\0', sizeof(wrqu));
4378 we_event = SIOCGIWSCAN;
4379 msg = NULL;
4380 wireless_send_event(dev, we_event, &wrqu, msg);
4381 }
4382 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004383 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004384
4385 /* Get the Scan Req */
4386 req = pAdapter->request;
4387
4388 if (!req)
4389 {
4390 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004391 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004392 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 }
4394
4395 /*
4396 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304397 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 req->n_ssids = 0;
4399 req->n_channels = 0;
4400 req->ie = 0;
4401
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004403 /* Scan is no longer pending */
4404 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004405
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004406 /*
4407 * cfg80211_scan_done informing NL80211 about completion
4408 * of scanning
4409 */
4410 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004411 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004412
Jeff Johnsone7245742012-09-05 17:12:55 -07004413allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004414 /* release the wake lock at the end of the scan*/
4415 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004416
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004417 /* Acquire wakelock to handle the case where APP's tries to suspend
4418 * immediatly after the driver gets connect request(i.e after scan)
4419 * from supplicant, this result in app's is suspending and not able
4420 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004421 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004422
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004423#ifdef FEATURE_WLAN_TDLS
4424 wlan_hdd_tdls_scan_done_callback(pAdapter);
4425#endif
4426
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 EXIT();
4428 return 0;
4429}
4430
4431/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004432 * FUNCTION: hdd_isScanAllowed
4433 * Go through each adapter and check if scan allowed
4434 *
4435 */
4436v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4437{
4438 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4439 hdd_station_ctx_t *pHddStaCtx = NULL;
4440 hdd_adapter_t *pAdapter = NULL;
4441 VOS_STATUS status = 0;
4442 v_U8_t staId = 0;
4443 v_U8_t *staMac = NULL;
4444
4445 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4446
4447 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4448 {
4449 pAdapter = pAdapterNode->pAdapter;
4450
4451 if( pAdapter )
4452 {
4453 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304454 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004455 __func__, pAdapter->device_mode);
4456 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4457 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4458 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4459 {
4460 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4461 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4462 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4463 {
4464 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4465 hddLog(VOS_TRACE_LEVEL_ERROR,
4466 "%s: client %02x:%02x:%02x:%02x:%02x:%02x is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304467 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004468 staMac[0], staMac[1], staMac[2],
4469 staMac[3], staMac[4], staMac[5]);
4470 return VOS_FALSE;
4471 }
4472 }
4473 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4474 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4475 {
4476 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4477 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304478 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004479 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4480 {
4481 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4482
4483 hddLog(VOS_TRACE_LEVEL_ERROR,
4484 "%s: client %02x:%02x:%02x:%02x:%02x:%02x of SoftAP/P2P-GO is in the "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304485 "middle of WPS/EAPOL exchange.", __func__,
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004486 staMac[0], staMac[1], staMac[2],
4487 staMac[3], staMac[4], staMac[5]);
4488 return VOS_FALSE;
4489 }
4490 }
4491 }
4492 }
4493 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4494 pAdapterNode = pNext;
4495 }
4496 hddLog(VOS_TRACE_LEVEL_INFO,
4497 "%s: Scan allowed", __func__);
4498 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304499}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004500
4501/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 * FUNCTION: wlan_hdd_cfg80211_scan
4503 * this scan respond to scan trigger and update cfg80211 scan database
4504 * later, scan dump command can be used to recieve scan results
4505 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004506int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4507#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4508 struct net_device *dev,
4509#endif
4510 struct cfg80211_scan_request *request)
4511{
4512#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4513 struct net_device *dev = request->wdev->netdev;
4514#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4517 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304518 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 tCsrScanRequest scanRequest;
4520 tANI_U8 *channelList = NULL, i;
4521 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304522 int status;
4523 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004525
4526 ENTER();
4527
4528 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4529 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004530
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304531 status = wlan_hdd_validate_context(pHddCtx);
4532
4533 if (0 != status)
4534 {
4535 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4536 "%s: HDD context is not valid", __func__);
4537 return status;
4538 }
4539
4540 cfg_param = pHddCtx->cfg_ini;
4541 pScanInfo = &pHddCtx->scan_info;
4542
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004543 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004544 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004545 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004546 {
4547 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004548 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4549 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004550 return -EBUSY;
4551 }
4552
Jeff Johnson295189b2012-06-20 16:38:30 -07004553#ifdef WLAN_BTAMP_FEATURE
4554 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004555 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004557 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 "%s: No scanning when AMP is on", __func__);
4559 return -EOPNOTSUPP;
4560 }
4561#endif
4562 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004563 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004565 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 "%s: Not scanning on device_mode = %d",
4567 __func__, pAdapter->device_mode);
4568 return -EOPNOTSUPP;
4569 }
4570
4571 if (TRUE == pScanInfo->mScanPending)
4572 {
4573 hddLog(VOS_TRACE_LEVEL_INFO, "%s: mScanPending is TRUE", __func__);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004574 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 }
4576
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304577 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004578 //Channel and action frame is pending
4579 //Otherwise Cancel Remain On Channel and allow Scan
4580 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004581 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004582 {
4583 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Remain On Channel Pending", __func__);
4584 return -EBUSY;
4585 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004586#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004587 /* if tdls disagree scan right now, return immediately.
4588 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4589 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4590 */
4591 status = wlan_hdd_tdls_scan_callback (pAdapter,
4592 wiphy,
4593#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4594 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004595#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004596 request);
4597 if(status <= 0)
4598 {
4599 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4600 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004601 }
4602#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004603
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4605 {
4606 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004607 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304609 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4611 {
4612 hddLog(VOS_TRACE_LEVEL_WARN,
4613 "%s: MAX TM Level Scan not allowed", __func__);
4614 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304615 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 }
4617 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4618
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004619 /* Check if scan is allowed at this point of time.
4620 */
4621 if (!hdd_isScanAllowed(pHddCtx))
4622 {
4623 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4624 return -EBUSY;
4625 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304626
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4628
4629 if (NULL != request)
4630 {
4631 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304632 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004633
4634 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4635 * Becasue of this, driver is assuming that this is not wildcard scan and so
4636 * is not aging out the scan results.
4637 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004638 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 {
4640 request->n_ssids = 0;
4641 }
4642
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004643 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 {
4645 tCsrSSIDInfo *SsidInfo;
4646 int j;
4647 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4648 /* Allocate num_ssid tCsrSSIDInfo structure */
4649 SsidInfo = scanRequest.SSIDs.SSIDList =
4650 ( tCsrSSIDInfo *)vos_mem_malloc(
4651 request->n_ssids*sizeof(tCsrSSIDInfo));
4652
4653 if(NULL == scanRequest.SSIDs.SSIDList)
4654 {
4655 hddLog(VOS_TRACE_LEVEL_ERROR,
4656 "memory alloc failed SSIDInfo buffer");
4657 return -ENOMEM;
4658 }
4659
4660 /* copy all the ssid's and their length */
4661 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4662 {
4663 /* get the ssid length */
4664 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4665 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4666 SsidInfo->SSID.length);
4667 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4668 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4669 j, SsidInfo->SSID.ssId);
4670 }
4671 /* set the scan type to active */
4672 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4673 }
4674 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4675 {
4676 /* set the scan type to active */
4677 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4678 }
4679 else
4680 {
4681 /*Set the scan type to default type, in this case it is ACTIVE*/
4682 scanRequest.scanType = pScanInfo->scan_mode;
4683 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304684 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4686 }
4687 else
4688 {
4689 /* set the scan type to active */
4690 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4691 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4692
4693 /* set min and max channel time to zero */
4694 scanRequest.minChnTime = 0;
4695 scanRequest.maxChnTime = 0;
4696 }
4697
4698 /* set BSSType to default type */
4699 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4700
4701 /*TODO: scan the requested channels only*/
4702
4703 /*Right now scanning all the channels */
4704 if( request )
4705 {
4706 if( request->n_channels )
4707 {
4708 channelList = vos_mem_malloc( request->n_channels );
4709 if( NULL == channelList )
4710 {
4711 status = -ENOMEM;
4712 goto free_mem;
4713 }
4714
4715 for( i = 0 ; i < request->n_channels ; i++ )
4716 channelList[i] = request->channels[i]->hw_value;
4717 }
4718
4719 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4720 scanRequest.ChannelInfo.ChannelList = channelList;
4721
4722 /* set requestType to full scan */
4723 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304724
4725 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004726 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304727 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004728 */
4729
4730 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304731 * and in that case driver shoudnt flush scan results. If
4732 * driver flushes the scan results here and unfortunately if
4733 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004734 * fails which is not desired
4735 */
4736
4737 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4738 {
4739 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4740 pAdapter->sessionId );
4741 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004742
4743 if( request->ie_len )
4744 {
4745 /* save this for future association (join requires this) */
4746 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4747 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4748 pScanInfo->scanAddIE.length = request->ie_len;
4749
4750 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004751 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4752 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004753 )
4754 {
4755 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4756 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4757 }
4758
4759 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
4760 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
4761
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
4763 request->ie_len);
4764 if (pP2pIe != NULL)
4765 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07004766#ifdef WLAN_FEATURE_P2P_DEBUG
4767 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
4768 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
4769 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4770 {
4771 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
4772 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4773 "Go nego completed to Connection is started");
4774 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4775 "for 8way Handshake");
4776 }
4777 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
4778 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4779 {
4780 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
4781 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
4782 "Disconnected state to Connection is started");
4783 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
4784 "for 4way Handshake");
4785 }
4786#endif
4787
Jeff Johnsone7245742012-09-05 17:12:55 -07004788 /* no_cck will be set during p2p find to disable 11b rates */
4789 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004791 hddLog(VOS_TRACE_LEVEL_INFO,
4792 "%s: This is a P2P Search", __func__);
4793 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07004794
Jeff Johnsone7245742012-09-05 17:12:55 -07004795 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
4796 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07004797 /* set requestType to P2P Discovery */
4798 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07004799 }
4800
4801 /*
4802 Skip Dfs Channel in case of P2P Search
4803 if it is set in ini file
4804 */
4805 if(cfg_param->skipDfsChnlInP2pSearch)
4806 {
4807 scanRequest.skipDfsChnlInP2pSearch = 1;
4808 }
4809 else
4810 {
4811 scanRequest.skipDfsChnlInP2pSearch = 0;
4812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004813
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 }
4815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 }
4817 }
4818
4819 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
4820
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004821 /* acquire the wakelock to avoid the apps suspend during the scan. To
4822 * address the following issues.
4823 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
4824 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
4825 * for long time, this result in apps running at full power for long time.
4826 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
4827 * be stuck in full power because of resume BMPS
4828 */
4829 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004830
4831 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07004832 pAdapter->sessionId, &scanRequest, &scanId,
4833 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07004834
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 if (eHAL_STATUS_SUCCESS != status)
4836 {
4837 hddLog(VOS_TRACE_LEVEL_ERROR,
4838 "%s: sme_ScanRequest returned error %d", __func__, status);
4839 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07004840 if(eHAL_STATUS_RESOURCES == status)
4841 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07004842 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 -07004843 status = -EBUSY;
4844 } else {
4845 status = -EIO;
4846 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004847 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 goto free_mem;
4849 }
4850
4851 pScanInfo->mScanPending = TRUE;
4852 pAdapter->request = request;
4853 pScanInfo->scanId = scanId;
4854
4855 complete(&pScanInfo->scan_req_completion_event);
4856
4857free_mem:
4858 if( scanRequest.SSIDs.SSIDList )
4859 {
4860 vos_mem_free(scanRequest.SSIDs.SSIDList);
4861 }
4862
4863 if( channelList )
4864 vos_mem_free( channelList );
4865
4866 EXIT();
4867
4868 return status;
4869}
4870
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004871
4872void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
4873{
4874 v_U8_t iniDot11Mode =
4875 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
4876 eHddDot11Mode hddDot11Mode = iniDot11Mode;
4877
4878 switch ( iniDot11Mode )
4879 {
4880 case eHDD_DOT11_MODE_AUTO:
4881 case eHDD_DOT11_MODE_11ac:
4882 case eHDD_DOT11_MODE_11ac_ONLY:
4883#ifdef WLAN_FEATURE_11AC
4884 hddDot11Mode = eHDD_DOT11_MODE_11ac;
4885#else
4886 hddDot11Mode = eHDD_DOT11_MODE_11n;
4887#endif
4888 break;
4889 case eHDD_DOT11_MODE_11n:
4890 case eHDD_DOT11_MODE_11n_ONLY:
4891 hddDot11Mode = eHDD_DOT11_MODE_11n;
4892 break;
4893 default:
4894 hddDot11Mode = iniDot11Mode;
4895 break;
4896 }
4897 /* This call decides required channel bonding mode */
4898 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
4899 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
4900 operationChannel);
4901}
4902
Jeff Johnson295189b2012-06-20 16:38:30 -07004903/*
4904 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304905 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304907int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07004908 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07004909{
4910 int status = 0;
4911 hdd_wext_state_t *pWextState;
4912 v_U32_t roamId;
4913 tCsrRoamProfile *pRoamProfile;
4914 eMib_dot11DesiredBssType connectedBssType;
4915 eCsrAuthType RSNAuthType;
4916
4917 ENTER();
4918
4919 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304920
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
4922 {
4923 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
4924 return -EINVAL;
4925 }
4926
4927 pRoamProfile = &pWextState->roamProfile;
4928
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304929 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004930 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004931 int ret = 0;
4932 hdd_station_ctx_t *pHddStaCtx;
4933 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4934 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
4935
4936 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
4937 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
4938 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 {
4940 /* Issue disconnect to CSR */
4941 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304942 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004943 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
4944 pAdapter->sessionId,
4945 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
4946 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004947 ret = wait_for_completion_interruptible_timeout(
4948 &pAdapter->disconnect_comp_var,
4949 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4950 if (0 == ret)
4951 {
4952 VOS_ASSERT(0);
4953 }
4954 }
4955 }
4956 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
4957 {
4958 ret = wait_for_completion_interruptible_timeout(
4959 &pAdapter->disconnect_comp_var,
4960 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4961 if (0 == ret)
4962 {
4963 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 }
4965 }
4966
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304967 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07004968 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
4969 {
4970 /*QoS not enabled in cfg file*/
4971 pRoamProfile->uapsd_mask = 0;
4972 }
4973 else
4974 {
4975 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304976 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
4978 }
4979
4980 pRoamProfile->SSIDs.numOfSSIDs = 1;
4981 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
4982 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304983 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
4985 ssid, ssid_len);
4986
4987 if (bssid)
4988 {
4989 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
4990 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
4991 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304992 /* Save BSSID in seperate variable as well, as RoamProfile
4993 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 case of join failure we should send valid BSSID to supplicant
4995 */
4996 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
4997 WNI_CFG_BSSID_LEN);
4998 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004999 else
5000 {
5001 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5002 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005003
5004 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5005 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305006 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005007 /*set gen ie*/
5008 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5009 /*set auth*/
5010 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5011 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005012#ifdef FEATURE_WLAN_WAPI
5013 if (pAdapter->wapi_info.nWapiMode)
5014 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005015 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 switch (pAdapter->wapi_info.wapiAuthMode)
5017 {
5018 case WAPI_AUTH_MODE_PSK:
5019 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005020 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 pAdapter->wapi_info.wapiAuthMode);
5022 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5023 break;
5024 }
5025 case WAPI_AUTH_MODE_CERT:
5026 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005027 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 pAdapter->wapi_info.wapiAuthMode);
5029 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5030 break;
5031 }
5032 } // End of switch
5033 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5034 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5035 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005036 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005037 pRoamProfile->AuthType.numEntries = 1;
5038 pRoamProfile->EncryptionType.numEntries = 1;
5039 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5040 pRoamProfile->mcEncryptionType.numEntries = 1;
5041 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5042 }
5043 }
5044#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305045#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305046 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305047 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5048 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5049 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305050 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5051 sizeof (tSirGtkOffloadParams));
5052 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305053 }
5054#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 pRoamProfile->csrPersona = pAdapter->device_mode;
5056
Jeff Johnson32d95a32012-09-10 13:15:23 -07005057 if( operatingChannel )
5058 {
5059 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5060 pRoamProfile->ChannelInfo.numOfChannels = 1;
5061 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005062 else
5063 {
5064 pRoamProfile->ChannelInfo.ChannelList = NULL;
5065 pRoamProfile->ChannelInfo.numOfChannels = 0;
5066 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005067 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5068 {
5069 hdd_select_cbmode(pAdapter,operatingChannel);
5070 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005071 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5072 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305073 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005074 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005075 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5076 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305077 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5078 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005079 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5080 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305081
5082 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 pAdapter->sessionId, pRoamProfile, &roamId);
5084
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305085 if ((eHAL_STATUS_SUCCESS != status) &&
5086 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5087 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305088
5089 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005090 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5091 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5092 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305093 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005094 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305095 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005096
5097 pRoamProfile->ChannelInfo.ChannelList = NULL;
5098 pRoamProfile->ChannelInfo.numOfChannels = 0;
5099
Jeff Johnson295189b2012-06-20 16:38:30 -07005100 }
5101 else
5102 {
5103 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5104 return -EINVAL;
5105 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005106 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 return status;
5108}
5109
5110/*
5111 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5112 * This function is used to set the authentication type (OPEN/SHARED).
5113 *
5114 */
5115static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5116 enum nl80211_auth_type auth_type)
5117{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305118 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5120
5121 ENTER();
5122
5123 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305124 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005126 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305127 hddLog(VOS_TRACE_LEVEL_INFO,
5128 "%s: set authentication type to AUTOSWITCH", __func__);
5129 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5130 break;
5131
5132 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005133#ifdef WLAN_FEATURE_VOWIFI_11R
5134 case NL80211_AUTHTYPE_FT:
5135#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305136 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 "%s: set authentication type to OPEN", __func__);
5138 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5139 break;
5140
5141 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305142 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 "%s: set authentication type to SHARED", __func__);
5144 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5145 break;
5146#ifdef FEATURE_WLAN_CCX
5147 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305148 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005149 "%s: set authentication type to CCKM WPA", __func__);
5150 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5151 break;
5152#endif
5153
5154
5155 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305156 hddLog(VOS_TRACE_LEVEL_ERROR,
5157 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005158 auth_type);
5159 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5160 return -EINVAL;
5161 }
5162
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305163 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 pHddStaCtx->conn_info.authType;
5165 return 0;
5166}
5167
5168/*
5169 * FUNCTION: wlan_hdd_set_akm_suite
5170 * This function is used to set the key mgmt type(PSK/8021x).
5171 *
5172 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305173static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005174 u32 key_mgmt
5175 )
5176{
5177 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5178 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305179
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 /*set key mgmt type*/
5181 switch(key_mgmt)
5182 {
5183 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305184#ifdef WLAN_FEATURE_VOWIFI_11R
5185 case WLAN_AKM_SUITE_FT_PSK:
5186#endif
5187 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 __func__);
5189 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5190 break;
5191
5192 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305193#ifdef WLAN_FEATURE_VOWIFI_11R
5194 case WLAN_AKM_SUITE_FT_8021X:
5195#endif
5196 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005197 __func__);
5198 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5199 break;
5200#ifdef FEATURE_WLAN_CCX
5201#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5202#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5203 case WLAN_AKM_SUITE_CCKM:
5204 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5205 __func__);
5206 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5207 break;
5208#endif
5209
5210 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305211 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 __func__, key_mgmt);
5213 return -EINVAL;
5214
5215 }
5216 return 0;
5217}
5218
5219/*
5220 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305221 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 * (NONE/WEP40/WEP104/TKIP/CCMP).
5223 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305224static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5225 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005226 bool ucast
5227 )
5228{
5229 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305230 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005231 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5232
5233 ENTER();
5234
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305235 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305237 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 __func__, cipher);
5239 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5240 }
5241 else
5242 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305243
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305245 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005246 {
5247 case IW_AUTH_CIPHER_NONE:
5248 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5249 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305250
Jeff Johnson295189b2012-06-20 16:38:30 -07005251 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305252 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005253 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305254
Jeff Johnson295189b2012-06-20 16:38:30 -07005255 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305256 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305258
Jeff Johnson295189b2012-06-20 16:38:30 -07005259 case WLAN_CIPHER_SUITE_TKIP:
5260 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5261 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305262
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 case WLAN_CIPHER_SUITE_CCMP:
5264 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5265 break;
5266#ifdef FEATURE_WLAN_WAPI
5267 case WLAN_CIPHER_SUITE_SMS4:
5268 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5269 break;
5270#endif
5271
5272#ifdef FEATURE_WLAN_CCX
5273 case WLAN_CIPHER_SUITE_KRK:
5274 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5275 break;
5276#endif
5277 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305278 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 __func__, cipher);
5280 return -EOPNOTSUPP;
5281 }
5282 }
5283
5284 if (ucast)
5285 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305286 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005287 __func__, encryptionType);
5288 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5289 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305290 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 encryptionType;
5292 }
5293 else
5294 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305295 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 __func__, encryptionType);
5297 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5298 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5299 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5300 }
5301
5302 return 0;
5303}
5304
5305
5306/*
5307 * FUNCTION: wlan_hdd_cfg80211_set_ie
5308 * This function is used to parse WPA/RSN IE's.
5309 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305310int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5311 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 size_t ie_len
5313 )
5314{
5315 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5316 u8 *genie = ie;
5317 v_U16_t remLen = ie_len;
5318#ifdef FEATURE_WLAN_WAPI
5319 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5320 u16 *tmp;
5321 v_U16_t akmsuiteCount;
5322 int *akmlist;
5323#endif
5324 ENTER();
5325
5326 /* clear previous assocAddIE */
5327 pWextState->assocAddIE.length = 0;
5328 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5329
5330 while (remLen >= 2)
5331 {
5332 v_U16_t eLen = 0;
5333 v_U8_t elementId;
5334 elementId = *genie++;
5335 eLen = *genie++;
5336 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305337
5338 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005339 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305340
5341 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305343 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005344 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 -07005345 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305346 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 "%s: Invalid WPA IE", __func__);
5348 return -EINVAL;
5349 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305350 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 {
5352 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305353 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005354 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305355
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5357 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005358 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5359 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 VOS_ASSERT(0);
5361 return -ENOMEM;
5362 }
5363 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5364 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5365 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305366
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5368 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5369 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5370 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305371 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5372 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5374 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5375 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5376 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5377 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5378 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305379 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
5380 P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 /*Consider P2P IE, only for P2P Client */
5382 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5383 {
5384 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305385 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005386 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305387
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5389 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005390 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5391 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005392 VOS_ASSERT(0);
5393 return -ENOMEM;
5394 }
5395 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5396 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5397 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305398
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5400 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005402#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305403 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5404 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 /*Consider WFD IE, only for P2P Client */
5406 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5407 {
5408 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305409 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005410 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305411
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5413 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005414 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5415 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 VOS_ASSERT(0);
5417 return -ENOMEM;
5418 }
5419 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5420 // WPS IE + P2P IE + WFD IE
5421 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5422 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305423
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5425 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5426 }
5427#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005428 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305429 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005430 HS20_OUI_TYPE_SIZE)) )
5431 {
5432 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305433 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005434 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005435
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005436 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5437 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005438 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5439 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005440 VOS_ASSERT(0);
5441 return -ENOMEM;
5442 }
5443 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5444 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005445
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005446 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5447 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5448 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005449
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005450 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5451
5452 /* populating as ADDIE in beacon frames */
5453 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5454 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5455 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5456 {
5457 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5458 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5459 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5460 {
5461 hddLog(LOGE,
5462 "Coldn't pass "
5463 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5464 }
5465 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5466 else
5467 hddLog(LOGE,
5468 "Could not pass on "
5469 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5470
5471 /* IBSS mode doesn't contain params->proberesp_ies still
5472 beaconIE's need to be populated in probe response frames */
5473 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5474 {
5475 u16 rem_probe_resp_ie_len = eLen + 2;
5476 u8 probe_rsp_ie_len[3] = {0};
5477 u8 counter = 0;
5478
5479 /* Check Probe Resp Length if it is greater then 255 then
5480 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5481 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5482 not able Store More then 255 bytes into One Variable */
5483
5484 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5485 {
5486 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5487 {
5488 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5489 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5490 }
5491 else
5492 {
5493 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5494 rem_probe_resp_ie_len = 0;
5495 }
5496 }
5497
5498 rem_probe_resp_ie_len = 0;
5499
5500 if (probe_rsp_ie_len[0] > 0)
5501 {
5502 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5503 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5504 (tANI_U8*)(genie - 2),
5505 probe_rsp_ie_len[0], NULL,
5506 eANI_BOOLEAN_FALSE)
5507 == eHAL_STATUS_FAILURE)
5508 {
5509 hddLog(LOGE,
5510 "Could not pass"
5511 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5512 }
5513 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5514 }
5515
5516 if (probe_rsp_ie_len[1] > 0)
5517 {
5518 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5519 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5520 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5521 probe_rsp_ie_len[1], NULL,
5522 eANI_BOOLEAN_FALSE)
5523 == eHAL_STATUS_FAILURE)
5524 {
5525 hddLog(LOGE,
5526 "Could not pass"
5527 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5528 }
5529 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5530 }
5531
5532 if (probe_rsp_ie_len[2] > 0)
5533 {
5534 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5535 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5536 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5537 probe_rsp_ie_len[2], NULL,
5538 eANI_BOOLEAN_FALSE)
5539 == eHAL_STATUS_FAILURE)
5540 {
5541 hddLog(LOGE,
5542 "Could not pass"
5543 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5544 }
5545 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5546 }
5547
5548 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5549 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5550 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5551 {
5552 hddLog(LOGE,
5553 "Could not pass"
5554 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5555 }
5556 }
5557 else
5558 {
5559 // Reset WNI_CFG_PROBE_RSP Flags
5560 wlan_hdd_reset_prob_rspies(pAdapter);
5561
5562 hddLog(VOS_TRACE_LEVEL_INFO,
5563 "%s: No Probe Response IE received in set beacon",
5564 __func__);
5565 }
5566 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 break;
5568 case DOT11F_EID_RSN:
5569 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5570 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5571 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5572 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5573 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5574 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005575 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5576 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305577 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005578 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305579 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005580 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305581
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -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 Koyyalamudief3b66e2012-10-11 14:29:42 -07005586 VOS_ASSERT(0);
5587 return -ENOMEM;
5588 }
5589 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5590 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305591
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005592 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5593 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5594 break;
5595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005596#ifdef FEATURE_WLAN_WAPI
5597 case WLAN_EID_WAPI:
5598 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
5599 hddLog(VOS_TRACE_LEVEL_INFO,"WAPI MODE IS %lu \n",
5600 pAdapter->wapi_info.nWapiMode);
5601 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305602 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005603 akmsuiteCount = WPA_GET_LE16(tmp);
5604 tmp = tmp + 1;
5605 akmlist = (int *)(tmp);
5606 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5607 {
5608 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5609 }
5610 else
5611 {
5612 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5613 VOS_ASSERT(0);
5614 return -EINVAL;
5615 }
5616
5617 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5618 {
5619 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005620 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005621 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305624 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005626 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5628 }
5629 break;
5630#endif
5631 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305632 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005634 /* when Unknown IE is received we should break and continue
5635 * to the next IE in the buffer instead we were returning
5636 * so changing this to break */
5637 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 }
5639 genie += eLen;
5640 remLen -= eLen;
5641 }
5642 EXIT();
5643 return 0;
5644}
5645
5646/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305647 * FUNCTION: hdd_isWPAIEPresent
5648 * Parse the received IE to find the WPA IE
5649 *
5650 */
5651static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5652{
5653 v_U8_t eLen = 0;
5654 v_U16_t remLen = ie_len;
5655 v_U8_t elementId = 0;
5656
5657 while (remLen >= 2)
5658 {
5659 elementId = *ie++;
5660 eLen = *ie++;
5661 remLen -= 2;
5662 if (eLen > remLen)
5663 {
5664 hddLog(VOS_TRACE_LEVEL_ERROR,
5665 "%s: IE length is wrong %d", __func__, eLen);
5666 return FALSE;
5667 }
5668 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5669 {
5670 /* OUI - 0x00 0X50 0XF2
5671 WPA Information Element - 0x01
5672 WPA version - 0x01*/
5673 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5674 return TRUE;
5675 }
5676 ie += eLen;
5677 remLen -= eLen;
5678 }
5679 return FALSE;
5680}
5681
5682/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305684 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 * parameters during connect operation.
5686 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305687int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005688 struct cfg80211_connect_params *req
5689 )
5690{
5691 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305692 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 ENTER();
5694
5695 /*set wpa version*/
5696 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5697
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305698 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305700 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 {
5702 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5703 }
5704 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5705 {
5706 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5707 }
5708 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305709
5710 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 pWextState->wpaVersion);
5712
5713 /*set authentication type*/
5714 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5715
5716 if (0 > status)
5717 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305718 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 "%s: failed to set authentication type ", __func__);
5720 return status;
5721 }
5722
5723 /*set key mgmt type*/
5724 if (req->crypto.n_akm_suites)
5725 {
5726 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5727 if (0 > status)
5728 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305729 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 __func__);
5731 return status;
5732 }
5733 }
5734
5735 /*set pairwise cipher type*/
5736 if (req->crypto.n_ciphers_pairwise)
5737 {
5738 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5739 req->crypto.ciphers_pairwise[0], true);
5740 if (0 > status)
5741 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305742 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 "%s: failed to set unicast cipher type", __func__);
5744 return status;
5745 }
5746 }
5747 else
5748 {
5749 /*Reset previous cipher suite to none*/
5750 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5751 if (0 > status)
5752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305753 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 "%s: failed to set unicast cipher type", __func__);
5755 return status;
5756 }
5757 }
5758
5759 /*set group cipher type*/
5760 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
5761 false);
5762
5763 if (0 > status)
5764 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305765 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 __func__);
5767 return status;
5768 }
5769
Chet Lanctot186b5732013-03-18 10:26:30 -07005770#ifdef WLAN_FEATURE_11W
5771 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
5772#endif
5773
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
5775 if (req->ie_len)
5776 {
5777 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
5778 if ( 0 > status)
5779 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305780 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 __func__);
5782 return status;
5783 }
5784 }
5785
5786 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305787 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 {
5789 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
5790 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
5791 )
5792 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305793 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07005794 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5795 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305796 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 __func__);
5798 return -EOPNOTSUPP;
5799 }
5800 else
5801 {
5802 u8 key_len = req->key_len;
5803 u8 key_idx = req->key_idx;
5804
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305805 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 && (CSR_MAX_NUM_KEY > key_idx)
5807 )
5808 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305809 hddLog(VOS_TRACE_LEVEL_INFO,
5810 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07005811 __func__, key_idx, key_len);
5812 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305813 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305815 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 (u8)key_len;
5817 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
5818 }
5819 }
5820 }
5821 }
5822
5823 return status;
5824}
5825
5826/*
5827 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305828 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 * parameters during connect operation.
5830 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305831static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 struct net_device *ndev,
5833 struct cfg80211_connect_params *req
5834 )
5835{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305836 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305837 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
5839 hdd_context_t *pHddCtx = NULL;
5840
5841 ENTER();
5842
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305843 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005844 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
5845
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305846 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5847 status = wlan_hdd_validate_context(pHddCtx);
5848
5849 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005850 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5852 "%s: HDD context is not valid", __func__);
5853 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 }
5855
5856#ifdef WLAN_BTAMP_FEATURE
5857 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305858 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305860 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08005862 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07005863 }
5864#endif
5865 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305866 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07005867
5868 if ( 0 > status)
5869 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305870 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07005871 __func__);
5872 return status;
5873 }
5874
5875 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08005876 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
5878 (vos_concurrent_sessions_running()))
5879 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305880 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 }
5882
Mohit Khanna765234a2012-09-11 15:08:35 -07005883 if ( req->channel )
5884 {
5885 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
5886 req->ssid_len, req->bssid,
5887 req->channel->hw_value);
5888 }
5889 else
5890 {
5891 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305892 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07005893 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005894
5895 if (0 > status)
5896 {
5897 //ReEnable BMPS if disabled
5898 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
5899 (NULL != pHddCtx))
5900 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05305901 if (pHddCtx->hdd_wlan_suspended)
5902 {
5903 hdd_set_pwrparams(pHddCtx);
5904 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 //ReEnable Bmps and Imps back
5906 hdd_enable_bmps_imps(pHddCtx);
5907 }
5908
5909 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
5910 return status;
5911 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305912 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 EXIT();
5914 return status;
5915}
5916
5917
5918/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305919 * FUNCTION: wlan_hdd_disconnect
5920 * This function is used to issue a disconnect request to SME
5921 */
5922int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
5923{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305924 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305925 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305926 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5927
5928 status = wlan_hdd_validate_context(pHddCtx);
5929
5930 if (0 != status)
5931 {
5932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5933 "%s: HDD context is not valid", __func__);
5934 return status;
5935 }
5936
5937 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305938 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305939 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305940
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05305941 /*issue disconnect*/
5942 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5943 pAdapter->sessionId, reason);
5944
5945 if ( 0 != status )
5946 {
5947 hddLog(VOS_TRACE_LEVEL_ERROR,
5948 "%s csrRoamDisconnect failure, returned %d \n",
5949 __func__, (int)status );
5950 return -EINVAL;
5951 }
5952 wait_for_completion_interruptible_timeout(
5953 &pAdapter->disconnect_comp_var,
5954 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5955 /*stop tx queues*/
5956 netif_tx_disable(pAdapter->dev);
5957 netif_carrier_off(pAdapter->dev);
5958 return status;
5959}
5960
5961
5962/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005963 * FUNCTION: wlan_hdd_cfg80211_disconnect
5964 * This function is used to issue a disconnect request to SME
5965 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305966static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 struct net_device *dev,
5968 u16 reason
5969 )
5970{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305971 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
5972 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305974 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08005976 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05305977#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08005978 tANI_U8 staIdx;
5979#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305980
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305982
5983 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 __func__,pAdapter->device_mode);
5985
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305986 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
5987 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005988
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305989 status = wlan_hdd_validate_context(pHddCtx);
5990
5991 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305993 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5994 "%s: HDD context is not valid", __func__);
5995 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05305997
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 if (NULL != pRoamProfile)
5999 {
6000 /*issue disconnect request to SME, if station is in connected state*/
6001 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6002 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306003 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006004 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306005 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 switch(reason)
6007 {
6008 case WLAN_REASON_MIC_FAILURE:
6009 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6010 break;
6011
6012 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6013 case WLAN_REASON_DISASSOC_AP_BUSY:
6014 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6015 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6016 break;
6017
6018 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6019 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6020 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6021 break;
6022
6023 case WLAN_REASON_DEAUTH_LEAVING:
6024 default:
6025 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6026 break;
6027 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306028 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6029 pScanInfo = &pHddCtx->scan_info;
6030 if (pScanInfo->mScanPending)
6031 {
6032 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6033 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306034 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006036
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006037#ifdef FEATURE_WLAN_TDLS
6038 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006039 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006040 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006041 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6042 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006043 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006044 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006045 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006046 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006047 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006048 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006049 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006050 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006051 pAdapter->sessionId,
6052 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006053 }
6054 }
6055#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306056 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6057 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 {
6059 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306060 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006061 __func__, (int)status );
6062 return -EINVAL;
6063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 }
6065 }
6066 else
6067 {
6068 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6069 }
6070
6071 return status;
6072}
6073
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306074
Jeff Johnson295189b2012-06-20 16:38:30 -07006075/*
6076 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306077 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 * settings in IBSS mode.
6079 */
6080static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306081 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 struct cfg80211_ibss_params *params
6083 )
6084{
6085 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306086 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6088 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306089
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 ENTER();
6091
6092 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
6093
6094 if (params->ie_len && ( NULL != params->ie) )
6095 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006096 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6097 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 {
6099 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6100 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6101 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006102 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006104 tDot11fIEWPA dot11WPAIE;
6105 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006106 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006107
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006108 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6109 params->ie_len, DOT11F_EID_WPA);
6110 if ( NULL != ie )
6111 {
6112 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6113 // Unpack the WPA IE
6114 //Skip past the EID byte and length byte - and four byte WiFi OUI
6115 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6116 &ie[2+4],
6117 ie[1] - 4,
6118 &dot11WPAIE);
6119 /*Extract the multicast cipher, the encType for unicast
6120 cipher for wpa-none is none*/
6121 encryptionType =
6122 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6123 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006125
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6127
6128 if (0 > status)
6129 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306130 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 __func__);
6132 return status;
6133 }
6134 }
6135
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306136 pWextState->roamProfile.AuthType.authType[0] =
6137 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6139
6140 if (params->privacy)
6141 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306142 /* Security enabled IBSS, At this time there is no information available
6143 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306145 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006146 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306147 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 *enable privacy bit in beacons */
6149
6150 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6151 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006152 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6153 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6155 pWextState->roamProfile.EncryptionType.numEntries = 1;
6156 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 return status;
6158}
6159
6160/*
6161 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306162 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306164static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 struct net_device *dev,
6166 struct cfg80211_ibss_params *params
6167 )
6168{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306169 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6171 tCsrRoamProfile *pRoamProfile;
6172 int status;
6173 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306174 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006175
6176 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306177
6178 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6180
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306181 status = wlan_hdd_validate_context(pHddCtx);
6182
6183 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006184 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6186 "%s: HDD context is not valid", __func__);
6187 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006188 }
6189
6190 if (NULL == pWextState)
6191 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306192 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006193 __func__);
6194 return -EIO;
6195 }
6196
6197 pRoamProfile = &pWextState->roamProfile;
6198
6199 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6200 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306201 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 "%s Interface type is not set to IBSS \n", __func__);
6203 return -EINVAL;
6204 }
6205
6206 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006207 if (NULL !=
6208#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6209 params->chandef.chan)
6210#else
6211 params->channel)
6212#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 {
6214 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006215 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6216 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6217 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6218 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006219
6220 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306221 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006222 ieee80211_frequency_to_channel(
6223#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6224 params->chandef.chan->center_freq);
6225#else
6226 params->channel->center_freq);
6227#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006228
6229 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6230 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006232 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6233 __func__);
6234 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006236
6237 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006238 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006239 if (channelNum == validChan[indx])
6240 {
6241 break;
6242 }
6243 }
6244 if (indx >= numChans)
6245 {
6246 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 __func__, channelNum);
6248 return -EINVAL;
6249 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006250 /* Set the Operational Channel */
6251 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6252 channelNum);
6253 pRoamProfile->ChannelInfo.numOfChannels = 1;
6254 pHddStaCtx->conn_info.operationChannel = channelNum;
6255 pRoamProfile->ChannelInfo.ChannelList =
6256 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 }
6258
6259 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306260 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 if (status < 0)
6262 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306263 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 __func__);
6265 return status;
6266 }
6267
6268 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306269 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006270 params->ssid_len, params->bssid,
6271 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006272
6273 if (0 > status)
6274 {
6275 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6276 return status;
6277 }
6278
6279 return 0;
6280}
6281
6282/*
6283 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306284 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006285 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306286static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006287 struct net_device *dev
6288 )
6289{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306290 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6292 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306293 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6294 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006295
6296 ENTER();
6297
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306298 status = wlan_hdd_validate_context(pHddCtx);
6299
6300 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006301 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306302 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6303 "%s: HDD context is not valid", __func__);
6304 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006305 }
6306
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6308 if (NULL == pWextState)
6309 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306310 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006311 __func__);
6312 return -EIO;
6313 }
6314
6315 pRoamProfile = &pWextState->roamProfile;
6316
6317 /* Issue disconnect only if interface type is set to IBSS */
6318 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6319 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306320 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 __func__);
6322 return -EINVAL;
6323 }
6324
6325 /* Issue Disconnect request */
6326 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6327 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6328 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6329
6330 return 0;
6331}
6332
6333/*
6334 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6335 * This function is used to set the phy parameters
6336 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6337 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306338static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 u32 changed)
6340{
6341 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6342 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306343 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006344
6345 ENTER();
6346
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306347 status = wlan_hdd_validate_context(pHddCtx);
6348
6349 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006350 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306351 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6352 "%s: HDD context is not valid", __func__);
6353 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006354 }
6355
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6357 {
6358 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6359 WNI_CFG_RTS_THRESHOLD_STAMAX :
6360 wiphy->rts_threshold;
6361
6362 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306363 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306365 hddLog(VOS_TRACE_LEVEL_ERROR,
6366 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 __func__, rts_threshold);
6368 return -EINVAL;
6369 }
6370
6371 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6372 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306373 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306375 hddLog(VOS_TRACE_LEVEL_ERROR,
6376 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 __func__, rts_threshold);
6378 return -EIO;
6379 }
6380
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306381 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 rts_threshold);
6383 }
6384
6385 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6386 {
6387 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6388 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6389 wiphy->frag_threshold;
6390
6391 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306392 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306394 hddLog(VOS_TRACE_LEVEL_ERROR,
6395 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 frag_threshold);
6397 return -EINVAL;
6398 }
6399
6400 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6401 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306402 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306404 hddLog(VOS_TRACE_LEVEL_ERROR,
6405 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 __func__, frag_threshold);
6407 return -EIO;
6408 }
6409
6410 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6411 frag_threshold);
6412 }
6413
6414 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6415 || (changed & WIPHY_PARAM_RETRY_LONG))
6416 {
6417 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6418 wiphy->retry_short :
6419 wiphy->retry_long;
6420
6421 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6422 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6423 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306424 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 __func__, retry_value);
6426 return -EINVAL;
6427 }
6428
6429 if (changed & WIPHY_PARAM_RETRY_SHORT)
6430 {
6431 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6432 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306433 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006434 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306435 hddLog(VOS_TRACE_LEVEL_ERROR,
6436 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006437 __func__, retry_value);
6438 return -EIO;
6439 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306440 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 __func__, retry_value);
6442 }
6443 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6444 {
6445 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6446 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306447 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006448 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306449 hddLog(VOS_TRACE_LEVEL_ERROR,
6450 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 __func__, retry_value);
6452 return -EIO;
6453 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306454 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006455 __func__, retry_value);
6456 }
6457 }
6458
6459 return 0;
6460}
6461
6462/*
6463 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6464 * This function is used to set the txpower
6465 */
6466static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006467#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6468 struct wireless_dev *wdev,
6469#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006470#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306471 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006472#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306473 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006474#endif
6475 int dbm)
6476{
6477 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306478 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6480 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306481 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006482
6483 ENTER();
6484
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306485 status = wlan_hdd_validate_context(pHddCtx);
6486
6487 if (0 != status)
6488 {
6489 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6490 "%s: HDD context is not valid", __func__);
6491 return status;
6492 }
6493
6494 hHal = pHddCtx->hHal;
6495
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306496 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6497 dbm, ccmCfgSetCallback,
6498 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306500 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006501 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6502 return -EIO;
6503 }
6504
6505 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6506 dbm);
6507
6508 switch(type)
6509 {
6510 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6511 /* Fall through */
6512 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6513 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6514 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306515 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6516 __func__);
6517 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 }
6519 break;
6520 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306521 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006522 __func__);
6523 return -EOPNOTSUPP;
6524 break;
6525 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306526 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6527 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006528 return -EIO;
6529 }
6530
6531 return 0;
6532}
6533
6534/*
6535 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6536 * This function is used to read the txpower
6537 */
Yue Maf49ba872013-08-19 12:04:25 -07006538static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6539#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6540 struct wireless_dev *wdev,
6541#endif
6542 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006543{
6544
6545 hdd_adapter_t *pAdapter;
6546 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306547 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006548
Jeff Johnsone7245742012-09-05 17:12:55 -07006549 ENTER();
6550
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306551 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006552
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306553 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006554 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306555 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6556 "%s: HDD context is not valid", __func__);
6557 *dbm = 0;
6558 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006559 }
6560
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6562 if (NULL == pAdapter)
6563 {
6564 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6565 return -ENOENT;
6566 }
6567
6568 wlan_hdd_get_classAstats(pAdapter);
6569 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6570
Jeff Johnsone7245742012-09-05 17:12:55 -07006571 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006572 return 0;
6573}
6574
6575static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6576 u8* mac, struct station_info *sinfo)
6577{
6578 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6579 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6580 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6581 tANI_U8 rate_flags;
6582
6583 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6584 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006585
6586 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6587 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6588 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6589 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6590 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6591 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6592 tANI_U16 maxRate = 0;
6593 tANI_U16 myRate;
6594 tANI_U16 currentRate = 0;
6595 tANI_U8 maxSpeedMCS = 0;
6596 tANI_U8 maxMCSIdx = 0;
6597 tANI_U8 rateFlag = 1;
6598 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006599 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306600 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006601
Leo Chang6f8870f2013-03-26 18:11:36 -07006602#ifdef WLAN_FEATURE_11AC
6603 tANI_U32 vht_mcs_map;
6604 eDataRate11ACMaxMcs vhtMaxMcs;
6605#endif /* WLAN_FEATURE_11AC */
6606
Jeff Johnsone7245742012-09-05 17:12:55 -07006607 ENTER();
6608
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6610 (0 == ssidlen))
6611 {
6612 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6613 " Invalid ssidlen, %d", __func__, ssidlen);
6614 /*To keep GUI happy*/
6615 return 0;
6616 }
6617
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306618 status = wlan_hdd_validate_context(pHddCtx);
6619
6620 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006621 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306622 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6623 "%s: HDD context is not valid", __func__);
6624 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006625 }
6626
Jeff Johnson295189b2012-06-20 16:38:30 -07006627 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6628 sinfo->filled |= STATION_INFO_SIGNAL;
6629
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006630 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6632
6633 //convert to the UI units of 100kbps
6634 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6635
6636#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006637 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 -07006638 sinfo->signal,
6639 pCfg->reportMaxLinkSpeed,
6640 myRate,
6641 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006642 (int) pCfg->linkSpeedRssiMid,
6643 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006644 (int) rate_flags,
6645 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006646#endif //LINKSPEED_DEBUG_ENABLED
6647
6648 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6649 {
6650 // we do not want to necessarily report the current speed
6651 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6652 {
6653 // report the max possible speed
6654 rssidx = 0;
6655 }
6656 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6657 {
6658 // report the max possible speed with RSSI scaling
6659 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6660 {
6661 // report the max possible speed
6662 rssidx = 0;
6663 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006664 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006665 {
6666 // report middle speed
6667 rssidx = 1;
6668 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006669 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6670 {
6671 // report middle speed
6672 rssidx = 2;
6673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 else
6675 {
6676 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006677 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006678 }
6679 }
6680 else
6681 {
6682 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6683 hddLog(VOS_TRACE_LEVEL_ERROR,
6684 "%s: Invalid value for reportMaxLinkSpeed: %u",
6685 __func__, pCfg->reportMaxLinkSpeed);
6686 rssidx = 0;
6687 }
6688
6689 maxRate = 0;
6690
6691 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306692 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6693 OperationalRates, &ORLeng))
6694 {
6695 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6696 /*To keep GUI happy*/
6697 return 0;
6698 }
6699
Jeff Johnson295189b2012-06-20 16:38:30 -07006700 for (i = 0; i < ORLeng; i++)
6701 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006702 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 {
6704 /* Validate Rate Set */
6705 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6706 {
6707 currentRate = supported_data_rate[j].supported_rate[rssidx];
6708 break;
6709 }
6710 }
6711 /* Update MAX rate */
6712 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6713 }
6714
6715 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306716 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6717 ExtendedRates, &ERLeng))
6718 {
6719 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6720 /*To keep GUI happy*/
6721 return 0;
6722 }
6723
Jeff Johnson295189b2012-06-20 16:38:30 -07006724 for (i = 0; i < ERLeng; i++)
6725 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006726 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 {
6728 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
6729 {
6730 currentRate = supported_data_rate[j].supported_rate[rssidx];
6731 break;
6732 }
6733 }
6734 /* Update MAX rate */
6735 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 /* Get MCS Rate Set -- but only if we are connected at MCS
6738 rates or if we are always reporting max speed or if we have
6739 good rssi */
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006740 if ((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY))
Jeff Johnson295189b2012-06-20 16:38:30 -07006741 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306742 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
6743 MCSRates, &MCSLeng))
6744 {
6745 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6746 /*To keep GUI happy*/
6747 return 0;
6748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07006750#ifdef WLAN_FEATURE_11AC
6751 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306752 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006754 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306755 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07006756 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006758 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006760 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 {
Leo Chang6f8870f2013-03-26 18:11:36 -07006762 maxMCSIdx = 7;
6763 }
6764 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
6765 {
6766 maxMCSIdx = 8;
6767 }
6768 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
6769 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306770 //VHT20 is supporting 0~8
6771 if (rate_flags & eHAL_TX_RATE_VHT20)
6772 maxMCSIdx = 8;
6773 else
6774 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07006775 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306776
6777 if (rate_flags & eHAL_TX_RATE_VHT80)
6778 {
6779 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
6780 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
6781 }
6782 else if (rate_flags & eHAL_TX_RATE_VHT40)
6783 {
6784 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
6785 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
6786 }
6787 else if (rate_flags & eHAL_TX_RATE_VHT20)
6788 {
6789 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
6790 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
6791 }
6792
Leo Chang6f8870f2013-03-26 18:11:36 -07006793 maxSpeedMCS = 1;
6794 if (currentRate > maxRate)
6795 {
6796 maxRate = currentRate;
6797 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306798
Leo Chang6f8870f2013-03-26 18:11:36 -07006799 }
6800 else
6801#endif /* WLAN_FEATURE_11AC */
6802 {
6803 if (rate_flags & eHAL_TX_RATE_HT40)
6804 {
6805 rateFlag |= 1;
6806 }
6807 if (rate_flags & eHAL_TX_RATE_SGI)
6808 {
6809 rateFlag |= 2;
6810 }
6811
6812 for (i = 0; i < MCSLeng; i++)
6813 {
6814 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
6815 for (j = 0; j < temp; j++)
6816 {
6817 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
6818 {
6819 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
6820 break;
6821 }
6822 }
6823 if ((j < temp) && (currentRate > maxRate))
6824 {
6825 maxRate = currentRate;
6826 maxSpeedMCS = 1;
6827 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
6828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 }
6830 }
6831 }
6832
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306833 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
6834 {
6835 maxRate = myRate;
6836 maxSpeedMCS = 1;
6837 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6838 }
6839
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006841 if (((maxRate < myRate) && (0 == rssidx)) ||
6842 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 {
6844 maxRate = myRate;
6845 if (rate_flags & eHAL_TX_RATE_LEGACY)
6846 {
6847 maxSpeedMCS = 0;
6848 }
6849 else
6850 {
6851 maxSpeedMCS = 1;
6852 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
6853 }
6854 }
6855
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306856 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 {
6858 sinfo->txrate.legacy = maxRate;
6859#ifdef LINKSPEED_DEBUG_ENABLED
6860 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
6861#endif //LINKSPEED_DEBUG_ENABLED
6862 }
6863 else
6864 {
6865 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07006866#ifdef WLAN_FEATURE_11AC
6867 sinfo->txrate.nss = 1;
6868 if (rate_flags & eHAL_TX_RATE_VHT80)
6869 {
6870 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306871 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07006872 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306873 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07006874 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306875 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6876 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6877 }
6878 else if (rate_flags & eHAL_TX_RATE_VHT20)
6879 {
6880 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6881 }
6882#endif /* WLAN_FEATURE_11AC */
6883 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
6884 {
6885 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6886 if (rate_flags & eHAL_TX_RATE_HT40)
6887 {
6888 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6889 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 if (rate_flags & eHAL_TX_RATE_SGI)
6892 {
6893 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6894 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05306895
Jeff Johnson295189b2012-06-20 16:38:30 -07006896#ifdef LINKSPEED_DEBUG_ENABLED
6897 pr_info("Reporting MCS rate %d flags %x\n",
6898 sinfo->txrate.mcs,
6899 sinfo->txrate.flags );
6900#endif //LINKSPEED_DEBUG_ENABLED
6901 }
6902 }
6903 else
6904 {
6905 // report current rate instead of max rate
6906
6907 if (rate_flags & eHAL_TX_RATE_LEGACY)
6908 {
6909 //provide to the UI in units of 100kbps
6910 sinfo->txrate.legacy = myRate;
6911#ifdef LINKSPEED_DEBUG_ENABLED
6912 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
6913#endif //LINKSPEED_DEBUG_ENABLED
6914 }
6915 else
6916 {
6917 //must be MCS
6918 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07006919#ifdef WLAN_FEATURE_11AC
6920 sinfo->txrate.nss = 1;
6921 if (rate_flags & eHAL_TX_RATE_VHT80)
6922 {
6923 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
6924 }
6925 else
6926#endif /* WLAN_FEATURE_11AC */
6927 {
6928 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
6929 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006930 if (rate_flags & eHAL_TX_RATE_SGI)
6931 {
6932 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
6933 }
6934 if (rate_flags & eHAL_TX_RATE_HT40)
6935 {
6936 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
6937 }
Leo Chang6f8870f2013-03-26 18:11:36 -07006938#ifdef WLAN_FEATURE_11AC
6939 else if (rate_flags & eHAL_TX_RATE_VHT80)
6940 {
6941 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
6942 }
6943#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07006944#ifdef LINKSPEED_DEBUG_ENABLED
6945 pr_info("Reporting actual MCS rate %d flags %x\n",
6946 sinfo->txrate.mcs,
6947 sinfo->txrate.flags );
6948#endif //LINKSPEED_DEBUG_ENABLED
6949 }
6950 }
6951 sinfo->filled |= STATION_INFO_TX_BITRATE;
6952
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006953 sinfo->tx_packets =
6954 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
6955 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
6956 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
6957 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
6958
6959 sinfo->tx_retries =
6960 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
6961 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
6962 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
6963 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
6964
6965 sinfo->tx_failed =
6966 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
6967 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
6968 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
6969 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
6970
6971 sinfo->filled |=
6972 STATION_INFO_TX_PACKETS |
6973 STATION_INFO_TX_RETRIES |
6974 STATION_INFO_TX_FAILED;
6975
6976 EXIT();
6977 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006978}
6979
6980static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07006981 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07006982{
6983 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306984 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006985 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306986 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006987
Jeff Johnsone7245742012-09-05 17:12:55 -07006988 ENTER();
6989
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 if (NULL == pAdapter)
6991 {
6992 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
6993 return -ENODEV;
6994 }
6995
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306996 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306997 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05306998
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306999 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307000 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7002 "%s: HDD context is not valid", __func__);
7003 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307004 }
7005
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307006 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7007 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7008 (pHddCtx->cfg_ini->fhostArpOffload) &&
7009 (eConnectionState_Associated ==
7010 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7011 {
Amar Singhald53568e2013-09-26 11:03:45 -07007012
7013 hddLog(VOS_TRACE_LEVEL_INFO,
7014 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307015 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307016 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7017 {
7018 hddLog(VOS_TRACE_LEVEL_INFO,
7019 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7020 __func__, vos_status);
7021 }
7022 }
7023
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 /**The get power cmd from the supplicant gets updated by the nl only
7025 *on successful execution of the function call
7026 *we are oppositely mapped w.r.t mode in the driver
7027 **/
7028 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7029
Jeff Johnsone7245742012-09-05 17:12:55 -07007030 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 if (VOS_STATUS_E_FAILURE == vos_status)
7032 {
7033 return -EINVAL;
7034 }
7035 return 0;
7036}
7037
7038
7039#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7040static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7041 struct net_device *netdev,
7042 u8 key_index)
7043{
Jeff Johnsone7245742012-09-05 17:12:55 -07007044 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 return 0;
7046}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307047#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007048
7049#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7050static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7051 struct net_device *dev,
7052 struct ieee80211_txq_params *params)
7053{
Jeff Johnsone7245742012-09-05 17:12:55 -07007054 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007055 return 0;
7056}
7057#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7058static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7059 struct ieee80211_txq_params *params)
7060{
Jeff Johnsone7245742012-09-05 17:12:55 -07007061 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 return 0;
7063}
7064#endif //LINUX_VERSION_CODE
7065
7066static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7067 struct net_device *dev, u8 *mac)
7068{
7069 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307070 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007071 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307072 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007073 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007074
Jeff Johnsone7245742012-09-05 17:12:55 -07007075 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307076 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007077 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307078 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 return -EINVAL;
7080 }
7081
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307082 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7083 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007084
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307085 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007086 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307087 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7088 "%s: HDD context is not valid", __func__);
7089 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007090 }
7091
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007094 )
7095 {
7096 if( NULL == mac )
7097 {
7098 v_U16_t i;
7099 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7100 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007101 if ((pAdapter->aStaInfo[i].isUsed) &&
7102 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007103 {
7104 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7105 hddLog(VOS_TRACE_LEVEL_INFO,
7106 "%s: Delete STA with MAC::"
7107 "%02x:%02x:%02x:%02x:%02x:%02x",
7108 __func__,
7109 macAddr[0], macAddr[1], macAddr[2],
7110 macAddr[3], macAddr[4], macAddr[5]);
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007111 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7112 if (VOS_IS_STATUS_SUCCESS(vos_status))
7113 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 }
7115 }
7116 }
7117 else
7118 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007119
7120 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7121 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7122 {
7123 hddLog(VOS_TRACE_LEVEL_INFO,
7124 "%s: Skip this DEL STA as this is not used::"
7125 "%02x:%02x:%02x:%02x:%02x:%02x",
7126 __func__,
7127 mac[0], mac[1], mac[2],
7128 mac[3], mac[4], mac[5]);
7129 return -ENOENT;
7130 }
7131
7132 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7133 {
7134 hddLog(VOS_TRACE_LEVEL_INFO,
7135 "%s: Skip this DEL STA as deauth is in progress::"
7136 "%02x:%02x:%02x:%02x:%02x:%02x",
7137 __func__,
7138 mac[0], mac[1], mac[2],
7139 mac[3], mac[4], mac[5]);
7140 return -ENOENT;
7141 }
7142
7143 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7144
Jeff Johnson295189b2012-06-20 16:38:30 -07007145 hddLog(VOS_TRACE_LEVEL_INFO,
7146 "%s: Delete STA with MAC::"
7147 "%02x:%02x:%02x:%02x:%02x:%02x",
7148 __func__,
7149 mac[0], mac[1], mac[2],
7150 mac[3], mac[4], mac[5]);
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007151
7152 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7153 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7154 {
7155 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7156 hddLog(VOS_TRACE_LEVEL_INFO,
7157 "%s: STA removal failed for ::"
7158 "%02x:%02x:%02x:%02x:%02x:%02x",
7159 __func__,
7160 mac[0], mac[1], mac[2],
7161 mac[3], mac[4], mac[5]);
7162 return -ENOENT;
7163 }
7164
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 }
7166 }
7167
7168 EXIT();
7169
7170 return 0;
7171}
7172
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007173static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7174 struct net_device *dev, u8 *mac, struct station_parameters *params)
7175{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007176 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007177#ifdef FEATURE_WLAN_TDLS
7178 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007179 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007180 mask = params->sta_flags_mask;
7181
7182 set = params->sta_flags_set;
7183
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007184#ifdef WLAN_FEATURE_TDLS_DEBUG
7185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7186 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7187 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7188#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007189
7190 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7191 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007192 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007193 }
7194 }
7195#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007196 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007197}
7198
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007199
7200#ifdef FEATURE_WLAN_LFR
7201static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007202 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007203{
7204#define MAX_PMKSAIDS_IN_CACHE 8
7205 static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD Local cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307206 static tANI_U32 i; // HDD Local Cache index
7207 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007208 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7209 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307210 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307211 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007212 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307213 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307214
Jeff Johnsone7245742012-09-05 17:12:55 -07007215 ENTER();
7216
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307217 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307218 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007219 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307220 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007221 return -EINVAL;
7222 }
7223
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7225 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007226
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307227 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007228 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307229 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7230 "%s: HDD context is not valid", __func__);
7231 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007232 }
7233
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307234 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007235 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7236
7237 for (j = 0; j < i; j++)
7238 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307239 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007240 pmksa->bssid, WNI_CFG_BSSID_LEN))
7241 {
7242 /* BSSID matched previous entry. Overwrite it. */
7243 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307244 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007245 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307246 vos_mem_copy(PMKIDCache[j].PMKID,
7247 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007248 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307249 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007250 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007251 dump_bssid(pmksa->bssid);
7252 dump_pmkid(halHandle, pmksa->pmkid);
7253 break;
7254 }
7255 }
7256
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007257 /* Check we compared all entries,if then take the first slot now */
7258 if(j == MAX_PMKSAIDS_IN_CACHE) i=0;
7259
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007260 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307261 {
7262 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
7263 vos_mem_copy(PMKIDCache[i].BSSID,
7264 pmksa->bssid, ETHER_ADDR_LEN);
7265 vos_mem_copy(PMKIDCache[i].PMKID,
7266 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007267 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307268 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007269 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007270 dump_bssid(pmksa->bssid);
7271 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307272 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007273 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307274 if (i<=(MAX_PMKSAIDS_IN_CACHE-1)) i++; else i=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007275 }
7276
7277
7278 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307279 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007280 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307281 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007282 __func__, i );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007283 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307284 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7285 PMKIDCache,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007286 i );
7287 return 0;
7288}
7289
7290
7291static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007292 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007293{
Jeff Johnsone7245742012-09-05 17:12:55 -07007294 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007295 // TODO: Implement this later.
7296 return 0;
7297}
7298
7299static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7300{
Jeff Johnsone7245742012-09-05 17:12:55 -07007301 ENTER();
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007302 // TODO: Implement this later.
7303 return 0;
7304}
7305#endif
7306
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007307#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307308static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007309 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7310{
7311 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7312 hdd_station_ctx_t *pHddStaCtx;
7313
7314 if (NULL == pAdapter)
7315 {
7316 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7317 return -ENODEV;
7318 }
7319
7320 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7321
7322 // Added for debug on reception of Re-assoc Req.
7323 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7324 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307325 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007326 ftie->ie_len);
7327 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7328 }
7329
7330#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307331 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007332 ftie->ie_len);
7333#endif
7334
7335 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307336 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7337 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007338 ftie->ie_len);
7339 return 0;
7340}
7341#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007342
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307343#ifdef FEATURE_WLAN_SCAN_PNO
7344
7345void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7346 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7347{
7348 int ret;
7349 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7350 hdd_context_t *pHddCtx;
7351
7352 if (NULL == pAdapter)
7353 {
7354 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7355 "%s: HDD adapter is Null", __func__);
7356 return ;
7357 }
7358
7359 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7360 if (NULL == pHddCtx)
7361 {
7362 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7363 "%s: HDD context is Null!!!", __func__);
7364 return ;
7365 }
7366
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307367 spin_lock(&pHddCtx->schedScan_lock);
7368 if (TRUE == pHddCtx->isWiphySuspended)
7369 {
7370 pHddCtx->isSchedScanUpdatePending = TRUE;
7371 spin_unlock(&pHddCtx->schedScan_lock);
7372 hddLog(VOS_TRACE_LEVEL_INFO,
7373 "%s: Update cfg80211 scan database after it resume", __func__);
7374 return ;
7375 }
7376 spin_unlock(&pHddCtx->schedScan_lock);
7377
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307378 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7379
7380 if (0 > ret)
7381 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7382
7383 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7385 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307386}
7387
7388/*
7389 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7390 * NL interface to enable PNO
7391 */
7392static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7393 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7394{
7395 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7396 tpSirPNOScanReq pPnoRequest = NULL;
7397 hdd_context_t *pHddCtx;
7398 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307399 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307400 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7401 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7402 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7403 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307404 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307405
7406 if (NULL == pAdapter)
7407 {
7408 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7409 "%s: HDD adapter is Null", __func__);
7410 return -ENODEV;
7411 }
7412
7413 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307414 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307415
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307416 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307417 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307418 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7419 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307420 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307421 }
7422
7423 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7424 if (NULL == hHal)
7425 {
7426 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7427 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307428 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307429 }
7430
7431 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7432 if (NULL == pPnoRequest)
7433 {
7434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7435 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307436 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307437 }
7438
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307439 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307440 pPnoRequest->enable = 1; /*Enable PNO */
7441 pPnoRequest->ucNetworksCount = request->n_match_sets;
7442
7443 if (( !pPnoRequest->ucNetworksCount ) ||
7444 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7445 {
7446 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7447 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307448 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307449 goto error;
7450 }
7451
7452 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7453 {
7454 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7455 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307456 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307457 goto error;
7458 }
7459
7460 /* Framework provides one set of channels(all)
7461 * common for all saved profile */
7462 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7463 channels_allowed, &num_channels_allowed))
7464 {
7465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7466 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307467 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307468 goto error;
7469 }
7470 /* Checking each channel against allowed channel list */
7471 num_ch = 0;
7472 for (i = 0; i < request->n_channels; i++)
7473 {
7474 for (indx = 0; indx < num_channels_allowed; indx++)
7475 {
7476 if (request->channels[i]->hw_value == channels_allowed[indx])
7477 {
7478 valid_ch[num_ch++] = request->channels[i]->hw_value;
7479 break ;
7480 }
7481 }
7482 }
7483
7484 /* Filling per profile params */
7485 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7486 {
7487 pPnoRequest->aNetworks[i].ssId.length =
7488 request->match_sets[i].ssid.ssid_len;
7489
7490 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7491 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7492 {
7493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7494 "SSID Len %d is not correct for network %d",
7495 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307496 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307497 goto error;
7498 }
7499
7500 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7501 request->match_sets[i].ssid.ssid,
7502 request->match_sets[i].ssid.ssid_len);
7503 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7504 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7505 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7506
7507 /*Copying list of valid channel into request */
7508 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7509 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7510
7511 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7512 }
7513
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7515 "request->ie_len = %d", request->ie_len);
7516 if ((0 < request->ie_len) && (NULL != request->ie))
7517 {
7518 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7519 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7520 pPnoRequest->us24GProbeTemplateLen);
7521
7522 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7523 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7524 pPnoRequest->us5GProbeTemplateLen);
7525 }
7526
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307527 /* Driver gets only one time interval which is hardcoded in
7528 * supplicant for 10000ms. Taking power consumption into account 6 timers
7529 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7530 * 80,160,320 secs. And number of scan cycle for each timer
7531 * is configurable through INI param gPNOScanTimerRepeatValue.
7532 * If it is set to 0 only one timer will be used and PNO scan cycle
7533 * will be repeated after each interval specified by supplicant
7534 * till PNO is disabled.
7535 */
7536 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7537 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7538 else
7539 pPnoRequest->scanTimers.ucScanTimersCount =
7540 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7541
7542 tempInterval = (request->interval)/1000;
7543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7544 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7545 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7546 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7547 {
7548 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7549 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7550 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7551 tempInterval *= 2;
7552 }
7553 //Repeat last timer until pno disabled.
7554 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7555
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307556 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307557
7558 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7559 pPnoRequest, pAdapter->sessionId,
7560 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7561 if (eHAL_STATUS_SUCCESS != status)
7562 {
7563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7564 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307565 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307566 goto error;
7567 }
7568
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307569 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7570 "PNO scanRequest offloaded");
7571
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307572error:
7573 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307574 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307575}
7576
7577/*
7578 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
7579 * NL interface to disable PNO
7580 */
7581static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
7582 struct net_device *dev)
7583{
7584 eHalStatus status = eHAL_STATUS_FAILURE;
7585 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7586 hdd_context_t *pHddCtx;
7587 tHalHandle hHal;
7588 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307589 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307590
7591 ENTER();
7592
7593 if (NULL == pAdapter)
7594 {
7595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7596 "%s: HDD adapter is Null", __func__);
7597 return -ENODEV;
7598 }
7599
7600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307601
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307602 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307603 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307604 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307605 "%s: HDD context is Null", __func__);
7606 return -ENODEV;
7607 }
7608
7609 /* The return 0 is intentional when isLogpInProgress and
7610 * isLoadUnloadInProgress. We did observe a crash due to a return of
7611 * failure in sched_scan_stop , especially for a case where the unload
7612 * of the happens at the same time. The function __cfg80211_stop_sched_scan
7613 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
7614 * success. If it returns a failure , then its next invocation due to the
7615 * clean up of the second interface will have the dev pointer corresponding
7616 * to the first one leading to a crash.
7617 */
7618 if (pHddCtx->isLogpInProgress)
7619 {
7620 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7621 "%s: LOGP in Progress. Ignore!!!", __func__);
7622 return ret;
7623 }
7624
7625 if (pHddCtx->isLoadUnloadInProgress)
7626 {
7627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7628 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
7629 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307630 }
7631
7632 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7633 if (NULL == hHal)
7634 {
7635 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7636 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307637 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307638 }
7639
7640 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7641 if (NULL == pPnoRequest)
7642 {
7643 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7644 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307645 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307646 }
7647
7648 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
7649 pPnoRequest->enable = 0; /* Disable PNO */
7650 pPnoRequest->ucNetworksCount = 0;
7651
7652 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
7653 pAdapter->sessionId,
7654 NULL, pAdapter);
7655 if (eHAL_STATUS_SUCCESS != status)
7656 {
7657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7658 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307659 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307660 }
7661
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307662 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7663 "%s: PNO scan disabled", __func__);
7664
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307665 vos_mem_free(pPnoRequest);
7666
7667 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307668 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307669}
7670
7671#endif /*FEATURE_WLAN_SCAN_PNO*/
7672
7673
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007674#ifdef FEATURE_WLAN_TDLS
7675static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
7676 u8 *peer, u8 action_code, u8 dialog_token,
7677 u16 status_code, const u8 *buf, size_t len)
7678{
7679
7680 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7681 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007682 u8 peerMac[6];
7683 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007684 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08007685 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007686 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007687
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007688 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007689 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307690 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007691 "Invalid arguments");
7692 return -EINVAL;
7693 }
7694
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007695 if (pHddCtx->isLogpInProgress)
7696 {
7697 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7698 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007699 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007700 return -EBUSY;
7701 }
7702
Hoonki Lee27511902013-03-14 18:19:06 -07007703 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007704 {
Hoonki Lee27511902013-03-14 18:19:06 -07007705 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7706 "%s: TDLS mode is disabled OR not enabled in FW."
7707 MAC_ADDRESS_STR " action %d declined.",
7708 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007709 return -ENOTSUPP;
7710 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007711
Hoonki Lee27511902013-03-14 18:19:06 -07007712 /* other than teardown frame, other mgmt frames are not sent if disabled */
7713 if (SIR_MAC_TDLS_TEARDOWN != action_code)
7714 {
7715 /* if tdls_mode is disabled to respond to peer's request */
7716 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
7717 {
7718 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
7719 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007720 " TDLS mode is disabled. action %d declined.",
7721 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07007722
7723 return -ENOTSUPP;
7724 }
7725 }
7726
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007727 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
7728 {
Hoonki Leefb8df672013-04-10 18:20:34 -07007729 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007730 {
7731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007732 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007733 " TDLS setup is ongoing. action %d declined.",
7734 __func__, MAC_ADDR_ARRAY(peer), action_code);
7735 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007736 }
7737 }
7738
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007739 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
7740 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08007741 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007742 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08007743 {
7744 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
7745 we return error code at 'add_station()'. Hence we have this
7746 check again in addtion to add_station().
7747 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007748 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08007749 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007750 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7751 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007752 " TDLS Max peer already connected. action %d declined.",
7753 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007754 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08007755 }
7756 else
7757 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007758 /* maximum reached. tweak to send error code to peer and return
7759 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007760 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7762 "%s: " MAC_ADDRESS_STR
7763 " TDLS Max peer already connected send response status %d",
7764 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007765 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007766 /* fall through to send setup resp with failure status
7767 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08007768 }
7769 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007770 else
7771 {
7772 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007773 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07007774 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007775 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007776 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07007777 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
7778 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007779 return -EPERM;
7780 }
7781 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08007782 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007783 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007784
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007785#ifdef WLAN_FEATURE_TDLS_DEBUG
7786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007787 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
7788 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
7789 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007790#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007791
Hoonki Leea34dd892013-02-05 22:56:02 -08007792 /*Except teardown responder will not be used so just make 0*/
7793 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007794 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08007795 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007796
7797 hddTdlsPeer_t *pTdlsPeer;
7798 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac);
7799
7800 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
7801 responder = pTdlsPeer->is_responder;
7802 else
Hoonki Leea34dd892013-02-05 22:56:02 -08007803 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07007804 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7805 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
7806 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
7807 dialog_token, status_code, len);
7808 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08007809 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007810 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007811
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307812 /* For explicit trigger of DIS_REQ come out of BMPS for
7813 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07007814 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307815 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
7816 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07007817 {
7818 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
7819 {
7820 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307821 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07007822 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
7823 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05307824 if (SIR_MAC_TDLS_DIS_REQ != action_code)
7825 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07007826 }
7827
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007828 /* make sure doesn't call send_mgmt() while it is pending */
7829 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
7830 {
7831 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7832 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
7833 __func__, MAC_ADDR_ARRAY(peer), action_code);
7834 return -EBUSY;
7835 }
7836
7837 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007838 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
7839
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007840 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08007841 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007842
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007843 if (VOS_STATUS_SUCCESS != status)
7844 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7846 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007847 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07007848 wlan_hdd_tdls_check_bmps(pAdapter);
7849 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007850 }
7851
Hoonki Leed37cbb32013-04-20 00:31:14 -07007852 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
7853 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
7854
7855 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007856 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07007857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7858 "%s: Mgmt Tx Completion failed status %ld TxCompletion %lu",
7859 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007860 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07007861 wlan_hdd_tdls_check_bmps(pAdapter);
7862 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007863 }
7864
Gopichand Nakkala05922802013-03-14 12:23:19 -07007865 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07007866 {
7867 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07007868 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07007869 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007870
Hoonki Leea34dd892013-02-05 22:56:02 -08007871 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
7872 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007873 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007874 }
7875 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
7876 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08007877 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08007878 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007879
7880 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07007881error:
7882 /* max_sta_failed ; we didn't set to CONNECTING for this case,
7883 because we already know that this transaction will be failed,
7884 but we weren't sure if supplicant call DISABLE_LINK or not. So,
7885 to be safe, do not change the state mahine.
7886 */
7887 if(max_sta_failed == 0 &&
7888 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
7889 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
7890 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007891}
7892
7893static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
7894 u8 *peer, enum nl80211_tdls_operation oper)
7895{
7896 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7897 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307898 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007899#ifdef WLAN_FEATURE_TDLS_DEBUG
7900 const char *tdls_oper_str[]= {
7901 "NL80211_TDLS_DISCOVERY_REQ",
7902 "NL80211_TDLS_SETUP",
7903 "NL80211_TDLS_TEARDOWN",
7904 "NL80211_TDLS_ENABLE_LINK",
7905 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05307906 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007907#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007908 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007909
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307910 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007911 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007912 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007913 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007914 return -EINVAL;
7915 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007916
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307917 status = wlan_hdd_validate_context(pHddCtx);
7918
7919 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007920 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307921 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7922 "%s: HDD context is not valid", __func__);
7923 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08007924 }
7925
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007926 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer);
7927
7928 if ( NULL == pTdlsPeer ) {
7929 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
7930 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
7931 return -EINVAL;
7932 }
7933
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007934#ifdef WLAN_FEATURE_TDLS_DEBUG
7935 if((int)oper > 4)
7936 oper = 5;
7937
7938 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007939 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
7940 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007941 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007942#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007943
7944 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007945 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007946 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08007947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07007948 "TDLS Disabled in INI OR not enabled in FW. "
7949 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007950 return -ENOTSUPP;
7951 }
7952
7953 switch (oper) {
7954 case NL80211_TDLS_ENABLE_LINK:
7955 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007956 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307957 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007958
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07007959 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
7960 {
7961 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
7962 MAC_ADDRESS_STR " failed",
7963 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
7964 return -EINVAL;
7965 }
7966
Hoonki Lee5305c3a2013-04-29 23:28:59 -07007967 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007968 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307969 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05307970 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05307971
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05307972 if (0 != wlan_hdd_tdls_get_link_establish_params(
7973 pAdapter, peer,&tdlsLinkEstablishParams)) {
7974 return -EINVAL;
7975 }
7976 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307977
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05307978 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
7979 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
7980 /* Send TDLS peer UAPSD capabilities to the firmware and
7981 * register with the TL on after the response for this operation
7982 * is received .
7983 */
7984 ret = wait_for_completion_interruptible_timeout(
7985 &pAdapter->tdls_link_establish_req_comp,
7986 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
7987 if (ret <= 0)
7988 {
7989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7990 "%s: Link Establish Request Faled Status %ld",
7991 __func__, ret);
7992 return -EINVAL;
7993 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05307994 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07007995 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05307996 /* Mark TDLS client Authenticated .*/
7997 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
7998 pTdlsPeer->staId,
7999 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008000 if (VOS_STATUS_SUCCESS == status)
8001 {
Hoonki Lee14621352013-04-16 17:51:19 -07008002 if (pTdlsPeer->is_responder == 0)
8003 {
8004 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8005
8006 wlan_hdd_tdls_timer_restart(pAdapter,
8007 &pTdlsPeer->initiatorWaitTimeoutTimer,
8008 WAIT_TIME_TDLS_INITIATOR);
8009 /* suspend initiator TX until it receives direct packet from the
8010 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8011 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8012 &staId, NULL);
8013 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008014 wlan_hdd_tdls_increment_peer_count(pAdapter);
8015 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008016 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308017
8018 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308019 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8020 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308021 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308022 int ac;
8023 uint8 ucAc[4] = { WLANTL_AC_VO,
8024 WLANTL_AC_VI,
8025 WLANTL_AC_BK,
8026 WLANTL_AC_BE };
8027 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8028 for(ac=0; ac < 4; ac++)
8029 {
8030 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8031 pTdlsPeer->staId, ucAc[ac],
8032 tlTid[ac], tlTid[ac], 0, 0,
8033 WLANTL_BI_DIR );
8034 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308035 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008036 }
8037
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008038 }
8039 break;
8040 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008041 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008042 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008043 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008044 long status;
8045
8046 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8047
Lee Hoonkic1262f22013-01-24 21:59:00 -08008048 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8049 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008050
8051 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8052 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8053 if (status <= 0)
8054 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008055 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008056 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8057 "%s: Del station failed status %ld",
8058 __func__, status);
8059 return -EPERM;
8060 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008061 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008062 }
8063 else
8064 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8066 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008067 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008068 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008069 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008070 case NL80211_TDLS_TEARDOWN:
8071 case NL80211_TDLS_SETUP:
8072 case NL80211_TDLS_DISCOVERY_REQ:
8073 /* We don't support in-driver setup/teardown/discovery */
8074 return -ENOTSUPP;
8075 default:
8076 return -ENOTSUPP;
8077 }
8078 return 0;
8079}
Chilam NG571c65a2013-01-19 12:27:36 +05308080
8081int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8082 struct net_device *dev, u8 *peer)
8083{
8084 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8085 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8086
8087 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8088 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8089}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008090#endif
8091
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308092#ifdef WLAN_FEATURE_GTK_OFFLOAD
8093/*
8094 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8095 * Callback rountine called upon receiving response for
8096 * get offload info
8097 */
8098void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8099 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8100{
8101
8102 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308103 tANI_U8 tempReplayCounter[8];
8104 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308105
8106 ENTER();
8107
8108 if (NULL == pAdapter)
8109 {
8110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8111 "%s: HDD adapter is Null", __func__);
8112 return ;
8113 }
8114
8115 if (NULL == pGtkOffloadGetInfoRsp)
8116 {
8117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8118 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8119 return ;
8120 }
8121
8122 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8123 {
8124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8125 "%s: wlan Failed to get replay counter value",
8126 __func__);
8127 return ;
8128 }
8129
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308130 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8131 /* Update replay counter */
8132 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8133 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8134
8135 {
8136 /* changing from little to big endian since supplicant
8137 * works on big endian format
8138 */
8139 int i;
8140 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8141
8142 for (i = 0; i < 8; i++)
8143 {
8144 tempReplayCounter[7-i] = (tANI_U8)p[i];
8145 }
8146 }
8147
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308148 /* Update replay counter to NL */
8149 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308150 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308151}
8152
8153/*
8154 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8155 * This function is used to offload GTK rekeying job to the firmware.
8156 */
8157int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8158 struct cfg80211_gtk_rekey_data *data)
8159{
8160 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8161 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8162 hdd_station_ctx_t *pHddStaCtx;
8163 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308164 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308165 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308166 eHalStatus status = eHAL_STATUS_FAILURE;
8167
8168 ENTER();
8169
8170 if (NULL == pAdapter)
8171 {
8172 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8173 "%s: HDD adapter is Null", __func__);
8174 return -ENODEV;
8175 }
8176
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308177 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308178
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308179 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308180 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308181 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8182 "%s: HDD context is not valid", __func__);
8183 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308184 }
8185
8186 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8187 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8188 if (NULL == hHal)
8189 {
8190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8191 "%s: HAL context is Null!!!", __func__);
8192 return -EAGAIN;
8193 }
8194
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308195 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8196 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8197 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8198 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308199 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308200 {
8201 /* changing from big to little endian since driver
8202 * works on little endian format
8203 */
8204 tANI_U8 *p =
8205 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8206 int i;
8207
8208 for (i = 0; i < 8; i++)
8209 {
8210 p[7-i] = data->replay_ctr[i];
8211 }
8212 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308213
8214 if (TRUE == pHddCtx->hdd_wlan_suspended)
8215 {
8216 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308217 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8218 sizeof (tSirGtkOffloadParams));
8219 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308220 pAdapter->sessionId);
8221
8222 if (eHAL_STATUS_SUCCESS != status)
8223 {
8224 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8225 "%s: sme_SetGTKOffload failed, returned %d",
8226 __func__, status);
8227 return status;
8228 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8230 "%s: sme_SetGTKOffload successfull", __func__);
8231 }
8232 else
8233 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308234 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8235 "%s: wlan not suspended GTKOffload request is stored",
8236 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308237 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308238
8239 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308240}
8241#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8242
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308243/*
8244 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8245 * This function is used to set access control policy
8246 */
8247static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8248 struct net_device *dev, const struct cfg80211_acl_data *params)
8249{
8250 int i;
8251 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8252 hdd_hostapd_state_t *pHostapdState;
8253 tsap_Config_t *pConfig;
8254 v_CONTEXT_t pVosContext = NULL;
8255 hdd_context_t *pHddCtx;
8256 int status;
8257
8258 ENTER();
8259
8260 if (NULL == pAdapter)
8261 {
8262 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8263 "%s: HDD adapter is Null", __func__);
8264 return -ENODEV;
8265 }
8266
8267 if (NULL == params)
8268 {
8269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8270 "%s: params is Null", __func__);
8271 return -EINVAL;
8272 }
8273
8274 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8275 status = wlan_hdd_validate_context(pHddCtx);
8276
8277 if (0 != status)
8278 {
8279 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8280 "%s: HDD context is not valid", __func__);
8281 return status;
8282 }
8283
8284 pVosContext = pHddCtx->pvosContext;
8285 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8286
8287 if (NULL == pHostapdState)
8288 {
8289 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8290 "%s: pHostapdState is Null", __func__);
8291 return -EINVAL;
8292 }
8293
8294 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8295 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8296
8297 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8298 {
8299 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8300
8301 /* default value */
8302 pConfig->num_accept_mac = 0;
8303 pConfig->num_deny_mac = 0;
8304
8305 /**
8306 * access control policy
8307 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8308 * listed in hostapd.deny file.
8309 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8310 * listed in hostapd.accept file.
8311 */
8312 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8313 {
8314 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8315 }
8316 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8317 {
8318 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8319 }
8320 else
8321 {
8322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8323 "%s:Acl Policy : %d is not supported",
8324 __func__, params->acl_policy);
8325 return -ENOTSUPP;
8326 }
8327
8328 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8329 {
8330 pConfig->num_accept_mac = params->n_acl_entries;
8331 for (i = 0; i < params->n_acl_entries; i++)
8332 {
8333 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8334 "** Add ACL MAC entry %i in WhiletList :"
8335 MAC_ADDRESS_STR, i,
8336 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8337
8338 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8339 sizeof(qcmacaddr));
8340 }
8341 }
8342 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8343 {
8344 pConfig->num_deny_mac = params->n_acl_entries;
8345 for (i = 0; i < params->n_acl_entries; i++)
8346 {
8347 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8348 "** Add ACL MAC entry %i in BlackList :"
8349 MAC_ADDRESS_STR, i,
8350 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8351
8352 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8353 sizeof(qcmacaddr));
8354 }
8355 }
8356
8357 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8358 {
8359 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8360 "%s: SAP Set Mac Acl fail", __func__);
8361 return -EINVAL;
8362 }
8363 }
8364 else
8365 {
8366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8367 "%s: Invalid device_mode = %d",
8368 __func__, pAdapter->device_mode);
8369 return -EINVAL;
8370 }
8371
8372 return 0;
8373}
8374
Leo Chang9056f462013-08-01 19:21:11 -07008375#ifdef WLAN_NL80211_TESTMODE
8376#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008377void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008378(
8379 void *pAdapter,
8380 void *indCont
8381)
8382{
Leo Changd9df8aa2013-09-26 13:32:26 -07008383 tSirLPHBInd *lphbInd;
8384 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008385
8386 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008387 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008388
8389 if (NULL == indCont)
8390 {
8391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008392 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008393 return;
8394 }
8395
Leo Changd9df8aa2013-09-26 13:32:26 -07008396 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008397 skb = cfg80211_testmode_alloc_event_skb(
8398 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008399 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008400 GFP_ATOMIC);
8401 if (!skb)
8402 {
8403 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8404 "LPHB timeout, NL buffer alloc fail");
8405 return;
8406 }
8407
Leo Changd9df8aa2013-09-26 13:32:26 -07008408 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
8409 {
8410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8411 "WLAN_HDD_TM_ATTR_CMD put fail");
8412 goto nla_put_failure;
8413 }
8414 if(!nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
8415 {
8416 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8417 "WLAN_HDD_TM_ATTR_TYPE put fail");
8418 goto nla_put_failure;
8419 }
8420 if(!nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
8421 sizeof(tSirLPHBInd), lphbInd))
8422 {
8423 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8424 "WLAN_HDD_TM_ATTR_DATA put fail");
8425 goto nla_put_failure;
8426 }
Leo Chang9056f462013-08-01 19:21:11 -07008427 cfg80211_testmode_event(skb, GFP_ATOMIC);
8428 return;
8429
8430nla_put_failure:
8431 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8432 "NLA Put fail");
8433 kfree_skb(skb);
8434
8435 return;
8436}
8437#endif /* FEATURE_WLAN_LPHB */
8438
8439static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8440{
8441 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8442 int err = 0;
8443#ifdef FEATURE_WLAN_LPHB
8444 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008445 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008446#endif /* FEATURE_WLAN_LPHB */
8447
8448 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8449 if (err)
8450 {
8451 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8452 "%s Testmode INV ATTR", __func__);
8453 return err;
8454 }
8455
8456 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8457 {
8458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8459 "%s Testmode INV CMD", __func__);
8460 return -EINVAL;
8461 }
8462
8463 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8464 {
8465#ifdef FEATURE_WLAN_LPHB
8466 /* Low Power Heartbeat configuration request */
8467 case WLAN_HDD_TM_CMD_WLAN_HB:
8468 {
8469 int buf_len;
8470 void *buf;
8471 tSirLPHBReq *hb_params = NULL;
8472
8473 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8474 {
8475 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8476 "%s Testmode INV DATA", __func__);
8477 return -EINVAL;
8478 }
8479
8480 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8481 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8482 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8483 if (NULL == hb_params)
8484 {
8485 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8486 "%s Request Buffer Alloc Fail", __func__);
8487 return -EINVAL;
8488 }
8489
8490 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008491 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8492 hb_params,
8493 wlan_hdd_cfg80211_lphb_ind_handler);
8494 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008495 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008496 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8497 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008498 vos_mem_free(hb_params);
8499 }
Leo Chang9056f462013-08-01 19:21:11 -07008500 return 0;
8501 }
8502#endif /* FEATURE_WLAN_LPHB */
8503 default:
8504 return -EOPNOTSUPP;
8505 }
8506
8507 return err;
8508}
8509#endif /* CONFIG_NL80211_TESTMODE */
8510
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308511static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8512 struct net_device *dev,
8513 int idx, struct survey_info *survey)
8514{
8515 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8516 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308517 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308518 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308519 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308520 v_S7_t snr,rssi;
8521 int status, i, j, filled = 0;
8522
8523 ENTER();
8524
8525
8526 if (NULL == pAdapter)
8527 {
8528 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8529 "%s: HDD adapter is Null", __func__);
8530 return -ENODEV;
8531 }
8532
8533 if (NULL == wiphy)
8534 {
8535 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8536 "%s: wiphy is Null", __func__);
8537 return -ENODEV;
8538 }
8539
8540 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8541 status = wlan_hdd_validate_context(pHddCtx);
8542
8543 if (0 != status)
8544 {
8545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8546 "%s: HDD context is not valid", __func__);
8547 return status;
8548 }
8549
Mihir Sheted9072e02013-08-21 17:02:29 +05308550 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8551
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308552 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308553 0 != pAdapter->survey_idx ||
8554 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308555 {
8556 /* The survey dump ops when implemented completely is expected to
8557 * return a survey of all channels and the ops is called by the
8558 * kernel with incremental values of the argument 'idx' till it
8559 * returns -ENONET. But we can only support the survey for the
8560 * operating channel for now. survey_idx is used to track
8561 * that the ops is called only once and then return -ENONET for
8562 * the next iteration
8563 */
8564 pAdapter->survey_idx = 0;
8565 return -ENONET;
8566 }
8567
8568 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8569
8570 wlan_hdd_get_snr(pAdapter, &snr);
8571 wlan_hdd_get_rssi(pAdapter, &rssi);
8572
8573 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
8574 hdd_wlan_get_freq(channel, &freq);
8575
8576
8577 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
8578 {
8579 if (NULL == wiphy->bands[i])
8580 {
8581 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
8582 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
8583 continue;
8584 }
8585
8586 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
8587 {
8588 struct ieee80211_supported_band *band = wiphy->bands[i];
8589
8590 if (band->channels[j].center_freq == (v_U16_t)freq)
8591 {
8592 survey->channel = &band->channels[j];
8593 /* The Rx BDs contain SNR values in dB for the received frames
8594 * while the supplicant expects noise. So we calculate and
8595 * return the value of noise (dBm)
8596 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
8597 */
8598 survey->noise = rssi - snr;
8599 survey->filled = SURVEY_INFO_NOISE_DBM;
8600 filled = 1;
8601 }
8602 }
8603 }
8604
8605 if (filled)
8606 pAdapter->survey_idx = 1;
8607 else
8608 {
8609 pAdapter->survey_idx = 0;
8610 return -ENONET;
8611 }
8612
8613 return 0;
8614}
8615
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308616/*
8617 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
8618 * this is called when cfg80211 driver resume
8619 * driver updates latest sched_scan scan result(if any) to cfg80211 database
8620 */
8621int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
8622{
8623 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8624 hdd_adapter_t *pAdapter;
8625 hdd_adapter_list_node_t *pAdapterNode, *pNext;
8626 VOS_STATUS status = VOS_STATUS_SUCCESS;
8627
8628 ENTER();
8629
8630 if ( NULL == pHddCtx )
8631 {
8632 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8633 "%s: HddCtx validation failed", __func__);
8634 return 0;
8635 }
8636
8637 if (pHddCtx->isLogpInProgress)
8638 {
8639 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8640 "%s: LOGP in Progress. Ignore!!!", __func__);
8641 return 0;
8642 }
8643
8644 if (pHddCtx->isLoadUnloadInProgress)
8645 {
8646 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8647 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8648 return 0;
8649 }
8650
8651 spin_lock(&pHddCtx->schedScan_lock);
8652 pHddCtx->isWiphySuspended = FALSE;
8653 if (TRUE != pHddCtx->isSchedScanUpdatePending)
8654 {
8655 spin_unlock(&pHddCtx->schedScan_lock);
8656 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8657 "%s: Return resume is not due to PNO indication", __func__);
8658 return 0;
8659 }
8660 // Reset flag to avoid updatating cfg80211 data old results again
8661 pHddCtx->isSchedScanUpdatePending = FALSE;
8662 spin_unlock(&pHddCtx->schedScan_lock);
8663
8664 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
8665
8666 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
8667 {
8668 pAdapter = pAdapterNode->pAdapter;
8669 if ( (NULL != pAdapter) &&
8670 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
8671 {
8672 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
8673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
8674 "%s: NO SCAN result", __func__);
8675 else
8676 cfg80211_sched_scan_results(pHddCtx->wiphy);
8677
8678 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8679 "%s : cfg80211 scan result database updated", __func__);
8680
8681 return 0;
8682
8683 }
8684 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
8685 pAdapterNode = pNext;
8686 }
8687
8688 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8689 "%s: Failed to find Adapter", __func__);
8690 return 0;
8691}
8692
8693/*
8694 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
8695 * this is called when cfg80211 driver suspends
8696 */
8697int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
8698 struct cfg80211_wowlan *wow)
8699{
8700 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8701
8702 ENTER();
8703 if (NULL == pHddCtx)
8704 {
8705 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8706 "%s: HddCtx validation failed", __func__);
8707 return 0;
8708 }
8709
8710 pHddCtx->isWiphySuspended = TRUE;
8711
8712 EXIT();
8713
8714 return 0;
8715}
8716
Jeff Johnson295189b2012-06-20 16:38:30 -07008717/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308718static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07008719{
8720 .add_virtual_intf = wlan_hdd_add_virtual_intf,
8721 .del_virtual_intf = wlan_hdd_del_virtual_intf,
8722 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
8723 .change_station = wlan_hdd_change_station,
8724#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
8725 .add_beacon = wlan_hdd_cfg80211_add_beacon,
8726 .del_beacon = wlan_hdd_cfg80211_del_beacon,
8727 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008728#else
8729 .start_ap = wlan_hdd_cfg80211_start_ap,
8730 .change_beacon = wlan_hdd_cfg80211_change_beacon,
8731 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07008732#endif
8733 .change_bss = wlan_hdd_cfg80211_change_bss,
8734 .add_key = wlan_hdd_cfg80211_add_key,
8735 .get_key = wlan_hdd_cfg80211_get_key,
8736 .del_key = wlan_hdd_cfg80211_del_key,
8737 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008738#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08008740#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008741 .scan = wlan_hdd_cfg80211_scan,
8742 .connect = wlan_hdd_cfg80211_connect,
8743 .disconnect = wlan_hdd_cfg80211_disconnect,
8744 .join_ibss = wlan_hdd_cfg80211_join_ibss,
8745 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
8746 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
8747 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
8748 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
8750 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
8751 .mgmt_tx = wlan_hdd_action,
8752#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
8753 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
8754 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
8755 .set_txq_params = wlan_hdd_set_txq_params,
8756#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 .get_station = wlan_hdd_cfg80211_get_station,
8758 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
8759 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008760 .add_station = wlan_hdd_cfg80211_add_station,
8761#ifdef FEATURE_WLAN_LFR
8762 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
8763 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
8764 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
8765#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07008766#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
8767 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
8768#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008769#ifdef FEATURE_WLAN_TDLS
8770 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
8771 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
8772#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308773#ifdef WLAN_FEATURE_GTK_OFFLOAD
8774 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
8775#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308776#ifdef FEATURE_WLAN_SCAN_PNO
8777 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
8778 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
8779#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308780 .resume = wlan_hdd_cfg80211_resume_wlan,
8781 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308782 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07008783#ifdef WLAN_NL80211_TESTMODE
8784 .testmode_cmd = wlan_hdd_cfg80211_testmode,
8785#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308786 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07008787};
8788