blob: a4eef990caea37362c800dcb42635e74ed2c6f14 [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
Kiet Lamac06e2c2013-10-23 16:25:07 +053097#define MAX_PENDING_LOG 5
Jeff Johnson295189b2012-06-20 16:38:30 -070098#define GET_IE_LEN_IN_BSS_DESC(lenInBss) ( lenInBss + sizeof(lenInBss) - \
99 ((int) OFFSET_OF( tSirBssDescription, ieFields)))
100
101#define HDD2GHZCHAN(freq, chan, flag) { \
102 .band = IEEE80211_BAND_2GHZ, \
103 .center_freq = (freq), \
104 .hw_value = (chan),\
105 .flags = (flag), \
106 .max_antenna_gain = 0 ,\
107 .max_power = 30, \
108}
109
110#define HDD5GHZCHAN(freq, chan, flag) { \
111 .band = IEEE80211_BAND_5GHZ, \
112 .center_freq = (freq), \
113 .hw_value = (chan),\
114 .flags = (flag), \
115 .max_antenna_gain = 0 ,\
116 .max_power = 30, \
117}
118
119#define HDD_G_MODE_RATETAB(rate, rate_id, flag)\
120{\
121 .bitrate = rate, \
122 .hw_value = rate_id, \
123 .flags = flag, \
124}
125
Lee Hoonkic1262f22013-01-24 21:59:00 -0800126#ifndef WLAN_FEATURE_TDLS_DEBUG
127#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_INFO
128#else
129#define TDLS_LOG_LEVEL VOS_TRACE_LEVEL_ERROR
130#endif
131
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530132#ifdef WLAN_FEATURE_VOWIFI_11R
133#define WLAN_AKM_SUITE_FT_8021X 0x000FAC03
134#define WLAN_AKM_SUITE_FT_PSK 0x000FAC04
135#endif
136
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530137static const u32 hdd_cipher_suites[] =
Jeff Johnson295189b2012-06-20 16:38:30 -0700138{
139 WLAN_CIPHER_SUITE_WEP40,
140 WLAN_CIPHER_SUITE_WEP104,
141 WLAN_CIPHER_SUITE_TKIP,
142#ifdef FEATURE_WLAN_CCX
143#define WLAN_CIPHER_SUITE_KRK 0x004096ff /* use for KRK */
144 WLAN_CIPHER_SUITE_KRK,
145 WLAN_CIPHER_SUITE_CCMP,
146#else
147 WLAN_CIPHER_SUITE_CCMP,
148#endif
149#ifdef FEATURE_WLAN_WAPI
150 WLAN_CIPHER_SUITE_SMS4,
151#endif
Chet Lanctot186b5732013-03-18 10:26:30 -0700152#ifdef WLAN_FEATURE_11W
153 WLAN_CIPHER_SUITE_AES_CMAC,
154#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700155};
156
157static inline int is_broadcast_ether_addr(const u8 *addr)
158{
159 return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) &&
160 (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff));
161}
162
163static struct ieee80211_channel hdd_channels_2_4_GHZ[] =
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530164{
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 HDD2GHZCHAN(2412, 1, 0) ,
166 HDD2GHZCHAN(2417, 2, 0) ,
167 HDD2GHZCHAN(2422, 3, 0) ,
168 HDD2GHZCHAN(2427, 4, 0) ,
169 HDD2GHZCHAN(2432, 5, 0) ,
170 HDD2GHZCHAN(2437, 6, 0) ,
171 HDD2GHZCHAN(2442, 7, 0) ,
172 HDD2GHZCHAN(2447, 8, 0) ,
173 HDD2GHZCHAN(2452, 9, 0) ,
174 HDD2GHZCHAN(2457, 10, 0) ,
175 HDD2GHZCHAN(2462, 11, 0) ,
176 HDD2GHZCHAN(2467, 12, 0) ,
177 HDD2GHZCHAN(2472, 13, 0) ,
178 HDD2GHZCHAN(2484, 14, 0) ,
179};
180
Jeff Johnson295189b2012-06-20 16:38:30 -0700181static struct ieee80211_channel hdd_social_channels_2_4_GHZ[] =
182{
183 HDD2GHZCHAN(2412, 1, 0) ,
184 HDD2GHZCHAN(2437, 6, 0) ,
185 HDD2GHZCHAN(2462, 11, 0) ,
186};
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188static struct ieee80211_channel hdd_channels_5_GHZ[] =
189{
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700190 HDD5GHZCHAN(4920, 240, 0) ,
191 HDD5GHZCHAN(4940, 244, 0) ,
192 HDD5GHZCHAN(4960, 248, 0) ,
193 HDD5GHZCHAN(4980, 252, 0) ,
194 HDD5GHZCHAN(5040, 208, 0) ,
195 HDD5GHZCHAN(5060, 212, 0) ,
196 HDD5GHZCHAN(5080, 216, 0) ,
Jeff Johnson295189b2012-06-20 16:38:30 -0700197 HDD5GHZCHAN(5180, 36, 0) ,
198 HDD5GHZCHAN(5200, 40, 0) ,
199 HDD5GHZCHAN(5220, 44, 0) ,
200 HDD5GHZCHAN(5240, 48, 0) ,
201 HDD5GHZCHAN(5260, 52, 0) ,
202 HDD5GHZCHAN(5280, 56, 0) ,
203 HDD5GHZCHAN(5300, 60, 0) ,
204 HDD5GHZCHAN(5320, 64, 0) ,
205 HDD5GHZCHAN(5500,100, 0) ,
206 HDD5GHZCHAN(5520,104, 0) ,
207 HDD5GHZCHAN(5540,108, 0) ,
208 HDD5GHZCHAN(5560,112, 0) ,
209 HDD5GHZCHAN(5580,116, 0) ,
210 HDD5GHZCHAN(5600,120, 0) ,
211 HDD5GHZCHAN(5620,124, 0) ,
212 HDD5GHZCHAN(5640,128, 0) ,
213 HDD5GHZCHAN(5660,132, 0) ,
214 HDD5GHZCHAN(5680,136, 0) ,
215 HDD5GHZCHAN(5700,140, 0) ,
216 HDD5GHZCHAN(5745,149, 0) ,
217 HDD5GHZCHAN(5765,153, 0) ,
218 HDD5GHZCHAN(5785,157, 0) ,
219 HDD5GHZCHAN(5805,161, 0) ,
220 HDD5GHZCHAN(5825,165, 0) ,
221};
222
223static struct ieee80211_rate g_mode_rates[] =
224{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530225 HDD_G_MODE_RATETAB(10, 0x1, 0),
226 HDD_G_MODE_RATETAB(20, 0x2, 0),
227 HDD_G_MODE_RATETAB(55, 0x4, 0),
228 HDD_G_MODE_RATETAB(110, 0x8, 0),
229 HDD_G_MODE_RATETAB(60, 0x10, 0),
230 HDD_G_MODE_RATETAB(90, 0x20, 0),
231 HDD_G_MODE_RATETAB(120, 0x40, 0),
232 HDD_G_MODE_RATETAB(180, 0x80, 0),
233 HDD_G_MODE_RATETAB(240, 0x100, 0),
234 HDD_G_MODE_RATETAB(360, 0x200, 0),
235 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 HDD_G_MODE_RATETAB(540, 0x800, 0),
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530237};
Jeff Johnson295189b2012-06-20 16:38:30 -0700238
239static struct ieee80211_rate a_mode_rates[] =
240{
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530241 HDD_G_MODE_RATETAB(60, 0x10, 0),
242 HDD_G_MODE_RATETAB(90, 0x20, 0),
243 HDD_G_MODE_RATETAB(120, 0x40, 0),
244 HDD_G_MODE_RATETAB(180, 0x80, 0),
245 HDD_G_MODE_RATETAB(240, 0x100, 0),
246 HDD_G_MODE_RATETAB(360, 0x200, 0),
247 HDD_G_MODE_RATETAB(480, 0x400, 0),
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 HDD_G_MODE_RATETAB(540, 0x800, 0),
249};
250
251static struct ieee80211_supported_band wlan_hdd_band_2_4_GHZ =
252{
253 .channels = hdd_channels_2_4_GHZ,
254 .n_channels = ARRAY_SIZE(hdd_channels_2_4_GHZ),
255 .band = IEEE80211_BAND_2GHZ,
256 .bitrates = g_mode_rates,
257 .n_bitrates = g_mode_rates_size,
258 .ht_cap.ht_supported = 1,
259 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
260 | IEEE80211_HT_CAP_GRN_FLD
261 | IEEE80211_HT_CAP_DSSSCCK40
262 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
263 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
264 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
265 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
266 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
267 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
268};
269
Jeff Johnson295189b2012-06-20 16:38:30 -0700270static struct ieee80211_supported_band wlan_hdd_band_p2p_2_4_GHZ =
271{
272 .channels = hdd_social_channels_2_4_GHZ,
273 .n_channels = ARRAY_SIZE(hdd_social_channels_2_4_GHZ),
274 .band = IEEE80211_BAND_2GHZ,
275 .bitrates = g_mode_rates,
276 .n_bitrates = g_mode_rates_size,
277 .ht_cap.ht_supported = 1,
278 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
279 | IEEE80211_HT_CAP_GRN_FLD
280 | IEEE80211_HT_CAP_DSSSCCK40
281 | IEEE80211_HT_CAP_LSIG_TXOP_PROT,
282 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
283 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
284 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
285 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
286 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
287};
Jeff Johnson295189b2012-06-20 16:38:30 -0700288
289static struct ieee80211_supported_band wlan_hdd_band_5_GHZ =
290{
291 .channels = hdd_channels_5_GHZ,
292 .n_channels = ARRAY_SIZE(hdd_channels_5_GHZ),
293 .band = IEEE80211_BAND_5GHZ,
294 .bitrates = a_mode_rates,
295 .n_bitrates = a_mode_rates_size,
296 .ht_cap.ht_supported = 1,
297 .ht_cap.cap = IEEE80211_HT_CAP_SGI_20
298 | IEEE80211_HT_CAP_GRN_FLD
299 | IEEE80211_HT_CAP_DSSSCCK40
300 | IEEE80211_HT_CAP_LSIG_TXOP_PROT
301 | IEEE80211_HT_CAP_SGI_40
302 | IEEE80211_HT_CAP_SUP_WIDTH_20_40,
303 .ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
304 .ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16,
305 .ht_cap.mcs.rx_mask = { 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, },
306 .ht_cap.mcs.rx_highest = cpu_to_le16( 72 ),
307 .ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED,
308};
309
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530310/* This structure contain information what kind of frame are expected in
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 TX/RX direction for each kind of interface */
312static const struct ieee80211_txrx_stypes
313wlan_hdd_txrx_stypes[NUM_NL80211_IFTYPES] = {
314 [NL80211_IFTYPE_STATION] = {
315 .tx = 0xffff,
316 .rx = BIT(SIR_MAC_MGMT_ACTION) |
317 BIT(SIR_MAC_MGMT_PROBE_REQ),
318 },
319 [NL80211_IFTYPE_AP] = {
320 .tx = 0xffff,
321 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
322 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
323 BIT(SIR_MAC_MGMT_PROBE_REQ) |
324 BIT(SIR_MAC_MGMT_DISASSOC) |
325 BIT(SIR_MAC_MGMT_AUTH) |
326 BIT(SIR_MAC_MGMT_DEAUTH) |
327 BIT(SIR_MAC_MGMT_ACTION),
328 },
Jeff Johnsonbc006202013-04-29 14:05:30 -0700329 [NL80211_IFTYPE_ADHOC] = {
330 .tx = 0xffff,
331 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
332 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
333 BIT(SIR_MAC_MGMT_PROBE_REQ) |
334 BIT(SIR_MAC_MGMT_DISASSOC) |
335 BIT(SIR_MAC_MGMT_AUTH) |
336 BIT(SIR_MAC_MGMT_DEAUTH) |
337 BIT(SIR_MAC_MGMT_ACTION),
338 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700339 [NL80211_IFTYPE_P2P_CLIENT] = {
340 .tx = 0xffff,
341 .rx = BIT(SIR_MAC_MGMT_ACTION) |
342 BIT(SIR_MAC_MGMT_PROBE_REQ),
343 },
344 [NL80211_IFTYPE_P2P_GO] = {
345 /* This is also same as for SoftAP */
346 .tx = 0xffff,
347 .rx = BIT(SIR_MAC_MGMT_ASSOC_REQ) |
348 BIT(SIR_MAC_MGMT_REASSOC_REQ) |
349 BIT(SIR_MAC_MGMT_PROBE_REQ) |
350 BIT(SIR_MAC_MGMT_DISASSOC) |
351 BIT(SIR_MAC_MGMT_AUTH) |
352 BIT(SIR_MAC_MGMT_DEAUTH) |
353 BIT(SIR_MAC_MGMT_ACTION),
354 },
Jeff Johnson295189b2012-06-20 16:38:30 -0700355};
356
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800357#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800358static const struct ieee80211_iface_limit
359wlan_hdd_iface_limit[] = {
360 {
Sunil Ravia72c3992013-01-31 06:12:22 -0800361 /* max = 3 ; Our driver create two interfaces during driver init
362 * wlan0 and p2p0 interfaces. p2p0 is considered as station
363 * interface until a group is formed. In JB architecture, once the
364 * group is formed, interface type of p2p0 is changed to P2P GO or
365 * Client.
366 * When supplicant remove the group, it first issue a set interface
367 * cmd to change the mode back to Station. In JB this works fine as
368 * we advertize two station type interface during driver init.
369 * Some vendors create separate interface for P2P GO/Client,
370 * after group formation(Third one). But while group remove
371 * supplicant first tries to change the mode(3rd interface) to STATION
372 * But as we advertized only two sta type interfaces nl80211 was
373 * returning error for the third one which was leading to failure in
374 * delete interface. Ideally while removing the group, supplicant
375 * should not try to change the 3rd interface mode to Station type.
376 * Till we get a fix in wpa_supplicant, we advertize max STA
377 * interface type to 3
378 */
379 .max = 3,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800380 .types = BIT(NL80211_IFTYPE_STATION),
381 },
382 {
383 .max = 1,
Jeff Johnsonbc006202013-04-29 14:05:30 -0700384 .types = BIT(NL80211_IFTYPE_ADHOC) | BIT(NL80211_IFTYPE_AP),
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800385 },
386 {
387 .max = 1,
388 .types = BIT(NL80211_IFTYPE_P2P_GO) |
389 BIT(NL80211_IFTYPE_P2P_CLIENT),
390 },
391};
392
393/* By default, only single channel concurrency is allowed */
394static struct ieee80211_iface_combination
395wlan_hdd_iface_combination = {
396 .limits = wlan_hdd_iface_limit,
397 .num_different_channels = 1,
Sunil Ravia72c3992013-01-31 06:12:22 -0800398 /*
399 * max = WLAN_MAX_INTERFACES ; JellyBean architecture creates wlan0
400 * and p2p0 interfaces during driver init
401 * Some vendors create separate interface for P2P operations.
402 * wlan0: STA interface
403 * p2p0: P2P Device interface, action frames goes
404 * through this interface.
405 * p2p-xx: P2P interface, After GO negotiation this interface is
406 * created for p2p operations(GO/CLIENT interface).
407 */
408 .max_interfaces = WLAN_MAX_INTERFACES,
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800409 .n_limits = ARRAY_SIZE(wlan_hdd_iface_limit),
410 .beacon_int_infra_match = false,
411};
412#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800413
Jeff Johnson295189b2012-06-20 16:38:30 -0700414static struct cfg80211_ops wlan_hdd_cfg80211_ops;
415
416/* Data rate 100KBPS based on IE Index */
417struct index_data_rate_type
418{
419 v_U8_t beacon_rate_index;
420 v_U16_t supported_rate[4];
421};
422
423/* 11B, 11G Rate table include Basic rate and Extended rate
424 The IDX field is the rate index
425 The HI field is the rate when RSSI is strong or being ignored
426 (in this case we report actual rate)
427 The MID field is the rate when RSSI is moderate
428 (in this case we cap 11b rates at 5.5 and 11g rates at 24)
429 The LO field is the rate when RSSI is low
430 (in this case we don't report rates, actual current rate used)
431 */
432static const struct
433{
434 v_U8_t beacon_rate_index;
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700435 v_U16_t supported_rate[4];
Jeff Johnson295189b2012-06-20 16:38:30 -0700436} supported_data_rate[] =
437{
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -0700438/* IDX HI HM LM LO (RSSI-based index */
439 {2, { 10, 10, 10, 0}},
440 {4, { 20, 20, 10, 0}},
441 {11, { 55, 20, 10, 0}},
442 {12, { 60, 55, 20, 0}},
443 {18, { 90, 55, 20, 0}},
444 {22, {110, 55, 20, 0}},
445 {24, {120, 90, 60, 0}},
446 {36, {180, 120, 60, 0}},
447 {44, {220, 180, 60, 0}},
448 {48, {240, 180, 90, 0}},
449 {66, {330, 180, 90, 0}},
450 {72, {360, 240, 90, 0}},
451 {96, {480, 240, 120, 0}},
452 {108, {540, 240, 120, 0}}
Jeff Johnson295189b2012-06-20 16:38:30 -0700453};
454
455/* MCS Based rate table */
456static struct index_data_rate_type supported_mcs_rate[] =
457{
458/* MCS L20 L40 S20 S40 */
459 {0, {65, 135, 72, 150}},
460 {1, {130, 270, 144, 300}},
461 {2, {195, 405, 217, 450}},
462 {3, {260, 540, 289, 600}},
463 {4, {390, 810, 433, 900}},
464 {5, {520, 1080, 578, 1200}},
465 {6, {585, 1215, 650, 1350}},
466 {7, {650, 1350, 722, 1500}}
467};
468
Leo Chang6f8870f2013-03-26 18:11:36 -0700469#ifdef WLAN_FEATURE_11AC
470
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530471#define DATA_RATE_11AC_MCS_MASK 0x03
Leo Chang6f8870f2013-03-26 18:11:36 -0700472
473struct index_vht_data_rate_type
474{
475 v_U8_t beacon_rate_index;
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530476 v_U16_t supported_VHT80_rate[2];
477 v_U16_t supported_VHT40_rate[2];
478 v_U16_t supported_VHT20_rate[2];
Leo Chang6f8870f2013-03-26 18:11:36 -0700479};
480
481typedef enum
482{
483 DATA_RATE_11AC_MAX_MCS_7,
484 DATA_RATE_11AC_MAX_MCS_8,
485 DATA_RATE_11AC_MAX_MCS_9,
486 DATA_RATE_11AC_MAX_MCS_NA
487} eDataRate11ACMaxMcs;
488
489/* MCS Based VHT rate table */
490static struct index_vht_data_rate_type supported_vht_mcs_rate[] =
491{
Gopichand Nakkala4c705372013-04-24 13:20:33 +0530492/* MCS L80 S80 L40 S40 L20 S40*/
493 {0, {293, 325}, {135, 150}, {65, 72}},
494 {1, {585, 650}, {270, 300}, {130, 144}},
495 {2, {878, 975}, {405, 450}, {195, 217}},
496 {3, {1170, 1300}, {540, 600}, {260, 289}},
497 {4, {1755, 1950}, {810, 900}, {390, 433}},
498 {5, {2340, 2600}, {1080, 1200}, {520, 578}},
499 {6, {2633, 2925}, {1215, 1350}, {585, 650}},
500 {7, {2925, 3250}, {1350, 1500}, {650, 722}},
501 {8, {3510, 3900}, {1620, 1800}, {780, 867}},
502 {9, {3900, 4333}, {1800, 2000}, {780, 867}}
Leo Chang6f8870f2013-03-26 18:11:36 -0700503};
504#endif /* WLAN_FEATURE_11AC */
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506extern struct net_device_ops net_ops_struct;
507
Leo Chang9056f462013-08-01 19:21:11 -0700508#ifdef WLAN_NL80211_TESTMODE
509enum wlan_hdd_tm_attr
510{
511 WLAN_HDD_TM_ATTR_INVALID = 0,
512 WLAN_HDD_TM_ATTR_CMD = 1,
513 WLAN_HDD_TM_ATTR_DATA = 2,
514 WLAN_HDD_TM_ATTR_TYPE = 3,
515 /* keep last */
516 WLAN_HDD_TM_ATTR_AFTER_LAST,
517 WLAN_HDD_TM_ATTR_MAX = WLAN_HDD_TM_ATTR_AFTER_LAST - 1,
518};
519
520enum wlan_hdd_tm_cmd
521{
522 WLAN_HDD_TM_CMD_WLAN_HB = 1,
523};
524
525#define WLAN_HDD_TM_DATA_MAX_LEN 5000
526
527static const struct nla_policy wlan_hdd_tm_policy[WLAN_HDD_TM_ATTR_MAX + 1] =
528{
529 [WLAN_HDD_TM_ATTR_CMD] = { .type = NLA_U32 },
530 [WLAN_HDD_TM_ATTR_DATA] = { .type = NLA_BINARY,
531 .len = WLAN_HDD_TM_DATA_MAX_LEN },
532};
533#endif /* WLAN_NL80211_TESTMODE */
534
Jeff Johnson295189b2012-06-20 16:38:30 -0700535/*
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530536 * FUNCTION: wlan_hdd_cfg80211_wiphy_alloc
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530537 * This function is called by hdd_wlan_startup()
538 * during initialization.
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530539 * This function is used to allocate wiphy structure.
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530541struct wiphy *wlan_hdd_cfg80211_wiphy_alloc(int priv_size)
Jeff Johnson295189b2012-06-20 16:38:30 -0700542{
543 struct wiphy *wiphy;
544 ENTER();
545
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530546 /*
547 * Create wiphy device
Jeff Johnson295189b2012-06-20 16:38:30 -0700548 */
549 wiphy = wiphy_new(&wlan_hdd_cfg80211_ops, priv_size);
550
551 if (!wiphy)
552 {
553 /* Print error and jump into err label and free the memory */
554 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wiphy init failed", __func__);
555 return NULL;
556 }
557
558 return wiphy;
559}
560
561/*
562 * FUNCTION: wlan_hdd_cfg80211_update_band
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530563 * This function is called from the supplicant through a
Jeff Johnson295189b2012-06-20 16:38:30 -0700564 * private ioctl to change the band value
565 */
566int wlan_hdd_cfg80211_update_band(struct wiphy *wiphy, eCsrBand eBand)
567{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530568 int i, j;
569 eNVChannelEnabledType channelEnabledState;
570
Jeff Johnsone7245742012-09-05 17:12:55 -0700571 ENTER();
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530572 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 {
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530574
575 if (NULL == wiphy->bands[i])
576 {
577 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
578 __func__, i);
579 continue;
580 }
581
582 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
583 {
584 struct ieee80211_supported_band *band = wiphy->bands[i];
585
586 channelEnabledState = vos_nv_getChannelEnabledState(
587 band->channels[j].hw_value);
588
589 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == eBand) // 5G only
590 {
591 // Enable Social channels for P2P
592 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq) &&
593 NV_CHANNEL_ENABLE == channelEnabledState)
594 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
595 else
596 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
597 continue;
598 }
599 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == eBand) // 2G only
600 {
601 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
602 continue;
603 }
604
605 if (NV_CHANNEL_DISABLE == channelEnabledState ||
606 NV_CHANNEL_INVALID == channelEnabledState)
607 {
608 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
609 }
610 else if (NV_CHANNEL_DFS == channelEnabledState)
611 {
612 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
613 band->channels[j].flags |= IEEE80211_CHAN_RADAR;
614 }
615 else
616 {
617 band->channels[j].flags &= ~(IEEE80211_CHAN_DISABLED
618 |IEEE80211_CHAN_RADAR);
619 }
620 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700621 }
622 return 0;
623}
624/*
625 * FUNCTION: wlan_hdd_cfg80211_init
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530626 * This function is called by hdd_wlan_startup()
627 * during initialization.
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 * This function is used to initialize and register wiphy structure.
629 */
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530630int wlan_hdd_cfg80211_init(struct device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 struct wiphy *wiphy,
632 hdd_config_t *pCfg
633 )
634{
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530635 int i, j;
Jeff Johnsone7245742012-09-05 17:12:55 -0700636 ENTER();
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 /* Now bind the underlying wlan device with wiphy */
639 set_wiphy_dev(wiphy, dev);
640
641 wiphy->mgmt_stypes = wlan_hdd_txrx_stypes;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700642
Kiet Lam6c583332013-10-14 05:37:09 +0530643#ifndef CONFIG_ENABLE_LINUX_REG
Amar Singhal0a402232013-10-11 20:57:16 -0700644 /* the flag for the other case would be initialzed in
645 vos_init_wiphy_from_nv_bin */
Amar Singhal0a402232013-10-11 20:57:16 -0700646 wiphy->flags |= WIPHY_FLAG_STRICT_REGULATORY;
Kiet Lam6c583332013-10-14 05:37:09 +0530647#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700648
Amar Singhalfddc28c2013-09-05 13:03:40 -0700649 /* This will disable updating of NL channels from passive to
650 * active if a beacon is received on passive channel. */
651 wiphy->flags |= WIPHY_FLAG_DISABLE_BEACON_HINTS;
Amar Singhalf0073192013-09-20 12:34:56 -0700652
Amar Singhalfddc28c2013-09-05 13:03:40 -0700653
Amar Singhala49cbc52013-10-08 18:37:44 -0700654
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700655#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -0700656 wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME
657 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD
658 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL
Jeff Johnsone7245742012-09-05 17:12:55 -0700659 | WIPHY_FLAG_OFFCHAN_TX;
Kiet Lam6c583332013-10-14 05:37:09 +0530660 wiphy->country_ie_pref = NL80211_COUNTRY_IE_IGNORE_CORE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700661#endif
Amar Singhala49cbc52013-10-08 18:37:44 -0700662
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700663#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
664 if (pCfg->isFastTransitionEnabled
James Zmuda77fb5ae2013-01-29 08:00:17 -0800665#ifdef FEATURE_WLAN_LFR
Srinivas Girigowda640728a2013-03-28 12:21:54 -0700666 || pCfg->isFastRoamIniFeatureEnabled
667#endif
668#ifdef FEATURE_WLAN_CCX
669 || pCfg->isCcxIniFeatureEnabled
670#endif
671 )
672 {
673 wiphy->flags |= WIPHY_FLAG_SUPPORTS_FW_ROAM;
674 }
James Zmuda77fb5ae2013-01-29 08:00:17 -0800675#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800676#ifdef FEATURE_WLAN_TDLS
677 wiphy->flags |= WIPHY_FLAG_SUPPORTS_TDLS
678 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP;
679#endif
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530680#ifdef FEATURE_WLAN_SCAN_PNO
681 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
Madan Mohan Koyyalamudi75de0102013-09-17 14:56:29 +0530682 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530683 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +0530684 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530685#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800686
Amar Singhalfddc28c2013-09-05 13:03:40 -0700687#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700688 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
689 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700690 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700691 driver need to determine what to do with both
692 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700693
694 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700695#else
696 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700697#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700698
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530699 wiphy->max_scan_ssids = MAX_SCAN_SSID;
700
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530701 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700702
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530703 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
704
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530706 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 | BIT(NL80211_IFTYPE_P2P_CLIENT)
709 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 | BIT(NL80211_IFTYPE_AP);
711
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800712#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800713 if( pCfg->enableMCC )
714 {
715 /* Currently, supports up to two channels */
716 wlan_hdd_iface_combination.num_different_channels = 2;
717
718 if( !pCfg->allowMCCGODiffBI )
719 wlan_hdd_iface_combination.beacon_int_infra_match = true;
720
721 }
722 wiphy->iface_combinations = &wlan_hdd_iface_combination;
723 wiphy->n_iface_combinations = 1;
724#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 /* Before registering we need to update the ht capabilitied based
727 * on ini values*/
728 if( !pCfg->ShortGI20MhzEnable )
729 {
730 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
731 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
732 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
733 }
734
735 if( !pCfg->ShortGI40MhzEnable )
736 {
737 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
738 }
739
740 if( !pCfg->nChannelBondingMode5GHz )
741 {
742 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
743 }
744
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530745 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
746 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
747
748 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
749 {
750
751 if (NULL == wiphy->bands[i])
752 {
753 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
754 __func__, i);
755 continue;
756 }
757
758 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
759 {
760 struct ieee80211_supported_band *band = wiphy->bands[i];
761
762 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
763 {
764 // Enable social channels for P2P
765 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
766 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
767 else
768 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
769 continue;
770 }
771 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
772 {
773 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
774 continue;
775 }
776 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 }
778 /*Initialise the supported cipher suite details*/
779 wiphy->cipher_suites = hdd_cipher_suites;
780 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
781
782 /*signal strength in mBm (100*dBm) */
783 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
784
785#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 wiphy->max_remain_on_channel_duration = 1000;
787#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700788
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530789 EXIT();
790 return 0;
791}
792
793/* In this function we are registering wiphy. */
794int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
795{
796 ENTER();
797 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700798 if (0 > wiphy_register(wiphy))
799 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530800 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
802 return -EIO;
803 }
804
805 EXIT();
806 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530807}
Jeff Johnson295189b2012-06-20 16:38:30 -0700808
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530809/* In this function we are updating channel list when,
810 regulatory domain is FCC and country code is US.
811 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
812 As per FCC smart phone is not a indoor device.
813 GO should not opeate on indoor channels */
814void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
815{
816 int j;
817 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
818 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
819 //Default counrtycode from NV at the time of wiphy initialization.
820 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
821 &defaultCountryCode[0]))
822 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700823 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530824 }
825 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
826 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530827 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
828 {
829 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
830 return;
831 }
832 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
833 {
834 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
835 // Mark UNII -1 band channel as passive
836 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
837 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
838 }
839 }
840}
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842/* In this function we will do all post VOS start initialization.
843 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530844 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700845*/
846void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
847{
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
849 /* Register for all P2P action, public action etc frames */
850 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
851
Jeff Johnsone7245742012-09-05 17:12:55 -0700852 ENTER();
853
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 /* Right now we are registering these frame when driver is getting
855 initialized. Once we will move to 2.6.37 kernel, in which we have
856 frame register ops, we will move this code as a part of that */
857 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530858 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
860
861 /* GAS Initial Response */
862 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
863 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530864
Jeff Johnson295189b2012-06-20 16:38:30 -0700865 /* GAS Comeback Request */
866 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
867 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
868
869 /* GAS Comeback Response */
870 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
871 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
872
873 /* P2P Public Action */
874 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530875 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 P2P_PUBLIC_ACTION_FRAME_SIZE );
877
878 /* P2P Action */
879 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
880 (v_U8_t*)P2P_ACTION_FRAME,
881 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700882
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530883 /* WNM BSS Transition Request frame */
884 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
885 (v_U8_t*)WNM_BSS_ACTION_FRAME,
886 WNM_BSS_ACTION_FRAME_SIZE );
887
Chet Lanctot186b5732013-03-18 10:26:30 -0700888#ifdef WLAN_FEATURE_11W
889 /* SA Query Response Action Frame */
890 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
891 (v_U8_t*)SA_QUERY_FRAME_RSP,
892 SA_QUERY_FRAME_RSP_SIZE );
893#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700894}
895
896void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
897{
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
899 /* Register for all P2P action, public action etc frames */
900 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
901
Jeff Johnsone7245742012-09-05 17:12:55 -0700902 ENTER();
903
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 /* Right now we are registering these frame when driver is getting
905 initialized. Once we will move to 2.6.37 kernel, in which we have
906 frame register ops, we will move this code as a part of that */
907 /* GAS Initial Request */
908
909 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
910 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
911
912 /* GAS Initial Response */
913 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
914 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530915
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 /* GAS Comeback Request */
917 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
918 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
919
920 /* GAS Comeback Response */
921 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
922 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
923
924 /* P2P Public Action */
925 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530926 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 P2P_PUBLIC_ACTION_FRAME_SIZE );
928
929 /* P2P Action */
930 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
931 (v_U8_t*)P2P_ACTION_FRAME,
932 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700933
934#ifdef WLAN_FEATURE_11W
935 /* SA Query Response Action Frame */
936 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
937 (v_U8_t*)SA_QUERY_FRAME_RSP,
938 SA_QUERY_FRAME_RSP_SIZE );
939#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700940}
941
942#ifdef FEATURE_WLAN_WAPI
943void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
944 const u8 *mac_addr, u8 *key , int key_Len)
945{
946 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
947 tCsrRoamSetKey setKey;
948 v_BOOL_t isConnected = TRUE;
949 int status = 0;
950 v_U32_t roamId= 0xFF;
951 tANI_U8 *pKeyPtr = NULL;
952 int n = 0;
953
954 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
955 __func__,pAdapter->device_mode);
956
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530957 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700958 setKey.keyId = key_index; // Store Key ID
959 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
960 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
961 setKey.paeRole = 0 ; // the PAE role
962 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
963 {
964 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
965 }
966 else
967 {
968 isConnected = hdd_connIsConnected(pHddStaCtx);
969 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
970 }
971 setKey.keyLength = key_Len;
972 pKeyPtr = setKey.Key;
973 memcpy( pKeyPtr, key, key_Len);
974
975 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
976 __func__, key_Len);
977 for (n = 0 ; n < key_Len; n++)
978 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
979 __func__,n,setKey.Key[n]);
980
981 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
982 if ( isConnected )
983 {
984 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
985 pAdapter->sessionId, &setKey, &roamId );
986 }
987 if ( status != 0 )
988 {
989 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
990 "[%4d] sme_RoamSetKey returned ERROR status= %d",
991 __LINE__, status );
992 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
993 }
994}
995#endif /* FEATURE_WLAN_WAPI*/
996
997#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530998int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 beacon_data_t **ppBeacon,
1000 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001001#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301002int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001003 beacon_data_t **ppBeacon,
1004 struct cfg80211_beacon_data *params,
1005 int dtim_period)
1006#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301007{
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 int size;
1009 beacon_data_t *beacon = NULL;
1010 beacon_data_t *old = NULL;
1011 int head_len,tail_len;
1012
Jeff Johnsone7245742012-09-05 17:12:55 -07001013 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 if (params->head && !params->head_len)
1015 return -EINVAL;
1016
1017 old = pAdapter->sessionCtx.ap.beacon;
1018
1019 if (!params->head && !old)
1020 return -EINVAL;
1021
Jeff Johnson295189b2012-06-20 16:38:30 -07001022#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1023 /* Kernel 3.0 is not updating dtim_period for set beacon */
1024 if (!params->dtim_period)
1025 return -EINVAL;
1026#endif
1027
1028 if(params->head)
1029 head_len = params->head_len;
1030 else
1031 head_len = old->head_len;
1032
1033 if(params->tail || !old)
1034 tail_len = params->tail_len;
1035 else
1036 tail_len = old->tail_len;
1037
1038 size = sizeof(beacon_data_t) + head_len + tail_len;
1039
1040 beacon = kzalloc(size, GFP_KERNEL);
1041
1042 if( beacon == NULL )
1043 return -ENOMEM;
1044
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001045#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 if(params->dtim_period || !old )
1047 beacon->dtim_period = params->dtim_period;
1048 else
1049 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001050#else
1051 if(dtim_period || !old )
1052 beacon->dtim_period = dtim_period;
1053 else
1054 beacon->dtim_period = old->dtim_period;
1055#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301056
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1058 beacon->tail = beacon->head + head_len;
1059 beacon->head_len = head_len;
1060 beacon->tail_len = tail_len;
1061
1062 if(params->head) {
1063 memcpy (beacon->head,params->head,beacon->head_len);
1064 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301065 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 if(old)
1067 memcpy (beacon->head,old->head,beacon->head_len);
1068 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 if(params->tail) {
1071 memcpy (beacon->tail,params->tail,beacon->tail_len);
1072 }
1073 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301074 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 memcpy (beacon->tail,old->tail,beacon->tail_len);
1076 }
1077
1078 *ppBeacon = beacon;
1079
1080 kfree(old);
1081
1082 return 0;
1083
1084}
Jeff Johnson295189b2012-06-20 16:38:30 -07001085
1086v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1087{
1088 int left = length;
1089 v_U8_t *ptr = pIes;
1090 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301091
Jeff Johnson295189b2012-06-20 16:38:30 -07001092 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301093 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 elem_id = ptr[0];
1095 elem_len = ptr[1];
1096 left -= 2;
1097 if(elem_len > left)
1098 {
1099 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001100 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 eid,elem_len,left);
1102 return NULL;
1103 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301104 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 {
1106 return ptr;
1107 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301108
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 left -= elem_len;
1110 ptr += (elem_len + 2);
1111 }
1112 return NULL;
1113}
1114
Jeff Johnson295189b2012-06-20 16:38:30 -07001115/* Check if rate is 11g rate or not */
1116static int wlan_hdd_rate_is_11g(u8 rate)
1117{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001118 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 u8 i;
1120 for (i = 0; i < 8; i++)
1121 {
1122 if(rate == gRateArray[i])
1123 return TRUE;
1124 }
1125 return FALSE;
1126}
1127
1128/* Check for 11g rate and set proper 11g only mode */
1129static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1130 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1131{
1132 u8 i, num_rates = pIe[0];
1133
1134 pIe += 1;
1135 for ( i = 0; i < num_rates; i++)
1136 {
1137 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1138 {
1139 /* If rate set have 11g rate than change the mode to 11G */
1140 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1141 if (pIe[i] & BASIC_RATE_MASK)
1142 {
1143 /* If we have 11g rate as basic rate, it means mode
1144 is 11g only mode.
1145 */
1146 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1147 *pCheckRatesfor11g = FALSE;
1148 }
1149 }
1150 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1151 {
1152 *require_ht = TRUE;
1153 }
1154 }
1155 return;
1156}
1157
1158static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1159{
1160 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1161 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1162 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1163 u8 checkRatesfor11g = TRUE;
1164 u8 require_ht = FALSE;
1165 u8 *pIe=NULL;
1166
1167 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1168
1169 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1170 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1171 if (pIe != NULL)
1172 {
1173 pIe += 1;
1174 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1175 &pConfig->SapHw_mode);
1176 }
1177
1178 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1179 WLAN_EID_EXT_SUPP_RATES);
1180 if (pIe != NULL)
1181 {
1182
1183 pIe += 1;
1184 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1185 &pConfig->SapHw_mode);
1186 }
1187
1188 if( pConfig->channel > 14 )
1189 {
1190 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1191 }
1192
1193 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1194 WLAN_EID_HT_CAPABILITY);
1195
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301196 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 {
1198 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1199 if(require_ht)
1200 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1201 }
1202}
1203
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301204static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1205 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1206{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001207 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301208 v_U8_t *pIe = NULL;
1209 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1210
1211 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1212 pBeacon->tail, pBeacon->tail_len);
1213
1214 if (pIe)
1215 {
1216 ielen = pIe[1] + 2;
1217 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1218 {
1219 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1220 }
1221 else
1222 {
1223 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1224 return -EINVAL;
1225 }
1226 *total_ielen += ielen;
1227 }
1228 return 0;
1229}
1230
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001231static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1232 v_U8_t *genie, v_U8_t *total_ielen)
1233{
1234 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1235 int left = pBeacon->tail_len;
1236 v_U8_t *ptr = pBeacon->tail;
1237 v_U8_t elem_id, elem_len;
1238 v_U16_t ielen = 0;
1239
1240 if ( NULL == ptr || 0 == left )
1241 return;
1242
1243 while (left >= 2)
1244 {
1245 elem_id = ptr[0];
1246 elem_len = ptr[1];
1247 left -= 2;
1248 if (elem_len > left)
1249 {
1250 hddLog( VOS_TRACE_LEVEL_ERROR,
1251 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1252 elem_id, elem_len, left);
1253 return;
1254 }
1255 if (IE_EID_VENDOR == elem_id)
1256 {
1257 /* skipping the VSIE's which we don't want to include or
1258 * it will be included by existing code
1259 */
1260 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1261#ifdef WLAN_FEATURE_WFD
1262 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1263#endif
1264 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1265 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1266 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1267 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1268 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1269 {
1270 ielen = ptr[1] + 2;
1271 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1272 {
1273 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1274 *total_ielen += ielen;
1275 }
1276 else
1277 {
1278 hddLog( VOS_TRACE_LEVEL_ERROR,
1279 "IE Length is too big "
1280 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1281 elem_id, elem_len, *total_ielen);
1282 }
1283 }
1284 }
1285
1286 left -= elem_len;
1287 ptr += (elem_len + 2);
1288 }
1289 return;
1290}
1291
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001292#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001293static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1294 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001295#else
1296static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1297 struct cfg80211_beacon_data *params)
1298#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001299{
1300 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301301 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001303 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001304
1305 genie = vos_mem_malloc(MAX_GENIE_LEN);
1306
1307 if(genie == NULL) {
1308
1309 return -ENOMEM;
1310 }
1311
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301312 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1313 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001314 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301315 ret = -EINVAL;
1316 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 }
1318
1319#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301320 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1321 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1322 {
1323 ret = -EINVAL;
1324 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 }
1326#endif
1327
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301328 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1329 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001330 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301331 ret = -EINVAL;
1332 goto done;
1333 }
1334
1335 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1336 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001337 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001339
1340 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1341 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1342 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1343 {
1344 hddLog(LOGE,
1345 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001346 ret = -EINVAL;
1347 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001348 }
1349
1350 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1351 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1352 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1353 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1354 ==eHAL_STATUS_FAILURE)
1355 {
1356 hddLog(LOGE,
1357 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001358 ret = -EINVAL;
1359 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 }
1361
1362 // Added for ProResp IE
1363 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1364 {
1365 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1366 u8 probe_rsp_ie_len[3] = {0};
1367 u8 counter = 0;
1368 /* Check Probe Resp Length if it is greater then 255 then Store
1369 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1370 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1371 Store More then 255 bytes into One Variable.
1372 */
1373 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1374 {
1375 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1376 {
1377 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1378 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1379 }
1380 else
1381 {
1382 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1383 rem_probe_resp_ie_len = 0;
1384 }
1385 }
1386
1387 rem_probe_resp_ie_len = 0;
1388
1389 if (probe_rsp_ie_len[0] > 0)
1390 {
1391 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1392 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1393 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1394 probe_rsp_ie_len[0], NULL,
1395 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1396 {
1397 hddLog(LOGE,
1398 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001399 ret = -EINVAL;
1400 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001401 }
1402 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1403 }
1404
1405 if (probe_rsp_ie_len[1] > 0)
1406 {
1407 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1408 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1409 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1410 probe_rsp_ie_len[1], NULL,
1411 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1412 {
1413 hddLog(LOGE,
1414 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001415 ret = -EINVAL;
1416 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 }
1418 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1419 }
1420
1421 if (probe_rsp_ie_len[2] > 0)
1422 {
1423 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1424 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1425 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1426 probe_rsp_ie_len[2], NULL,
1427 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1428 {
1429 hddLog(LOGE,
1430 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001431 ret = -EINVAL;
1432 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 }
1434 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1435 }
1436
1437 if (probe_rsp_ie_len[1] == 0 )
1438 {
1439 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1440 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1441 eANI_BOOLEAN_FALSE) )
1442 {
1443 hddLog(LOGE,
1444 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1445 }
1446 }
1447
1448 if (probe_rsp_ie_len[2] == 0 )
1449 {
1450 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1451 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1452 eANI_BOOLEAN_FALSE) )
1453 {
1454 hddLog(LOGE,
1455 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1456 }
1457 }
1458
1459 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1460 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1461 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1462 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1463 == eHAL_STATUS_FAILURE)
1464 {
1465 hddLog(LOGE,
1466 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001467 ret = -EINVAL;
1468 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001469 }
1470 }
1471 else
1472 {
1473 // Reset WNI_CFG_PROBE_RSP Flags
1474 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1475
1476 hddLog(VOS_TRACE_LEVEL_INFO,
1477 "%s: No Probe Response IE received in set beacon",
1478 __func__);
1479 }
1480
1481 // Added for AssocResp IE
1482 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1483 {
1484 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1485 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1486 params->assocresp_ies_len, NULL,
1487 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1488 {
1489 hddLog(LOGE,
1490 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001491 ret = -EINVAL;
1492 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494
1495 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1496 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1497 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1498 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1499 == eHAL_STATUS_FAILURE)
1500 {
1501 hddLog(LOGE,
1502 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001503 ret = -EINVAL;
1504 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001505 }
1506 }
1507 else
1508 {
1509 hddLog(VOS_TRACE_LEVEL_INFO,
1510 "%s: No Assoc Response IE received in set beacon",
1511 __func__);
1512
1513 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1514 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1515 eANI_BOOLEAN_FALSE) )
1516 {
1517 hddLog(LOGE,
1518 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1519 }
1520 }
1521
Jeff Johnsone7245742012-09-05 17:12:55 -07001522done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001523 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301524 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001525}
Jeff Johnson295189b2012-06-20 16:38:30 -07001526
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301527/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001528 * FUNCTION: wlan_hdd_validate_operation_channel
1529 * called by wlan_hdd_cfg80211_start_bss() and
1530 * wlan_hdd_cfg80211_set_channel()
1531 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301532 * channel list.
1533 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001534VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001535{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301536
Jeff Johnson295189b2012-06-20 16:38:30 -07001537 v_U32_t num_ch = 0;
1538 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1539 u32 indx = 0;
1540 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301541 v_U8_t fValidChannel = FALSE, count = 0;
1542 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301543
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1545
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301546 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301548 /* Validate the channel */
1549 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301551 if ( channel == rfChannels[count].channelNum )
1552 {
1553 fValidChannel = TRUE;
1554 break;
1555 }
1556 }
1557 if (fValidChannel != TRUE)
1558 {
1559 hddLog(VOS_TRACE_LEVEL_ERROR,
1560 "%s: Invalid Channel [%d]", __func__, channel);
1561 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 }
1563 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301564 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301566 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1567 valid_ch, &num_ch))
1568 {
1569 hddLog(VOS_TRACE_LEVEL_ERROR,
1570 "%s: failed to get valid channel list", __func__);
1571 return VOS_STATUS_E_FAILURE;
1572 }
1573 for (indx = 0; indx < num_ch; indx++)
1574 {
1575 if (channel == valid_ch[indx])
1576 {
1577 break;
1578 }
1579 }
1580
1581 if (indx >= num_ch)
1582 {
1583 hddLog(VOS_TRACE_LEVEL_ERROR,
1584 "%s: Invalid Channel [%d]", __func__, channel);
1585 return VOS_STATUS_E_FAILURE;
1586 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 }
1588 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301589
Jeff Johnson295189b2012-06-20 16:38:30 -07001590}
1591
Viral Modi3a32cc52013-02-08 11:14:52 -08001592/**
1593 * FUNCTION: wlan_hdd_cfg80211_set_channel
1594 * This function is used to set the channel number
1595 */
1596static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1597 struct ieee80211_channel *chan,
1598 enum nl80211_channel_type channel_type
1599 )
1600{
1601 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001602 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001603 hdd_adapter_t *pAdapter = NULL;
1604 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301605 hdd_context_t *pHddCtx;
1606 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001607
1608 ENTER();
1609
1610 if( NULL == dev )
1611 {
1612 hddLog(VOS_TRACE_LEVEL_ERROR,
1613 "%s: Called with dev = NULL.\n", __func__);
1614 return -ENODEV;
1615 }
1616 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1617
1618 hddLog(VOS_TRACE_LEVEL_INFO,
1619 "%s: device_mode = %d freq = %d \n",__func__,
1620 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301621
1622 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1623 status = wlan_hdd_validate_context(pHddCtx);
1624
1625 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001626 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301627 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1628 "%s: HDD context is not valid", __func__);
1629 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001630 }
1631
1632 /*
1633 * Do freq to chan conversion
1634 * TODO: for 11a
1635 */
1636
1637 channel = ieee80211_frequency_to_channel(freq);
1638
1639 /* Check freq range */
1640 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1641 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1642 {
1643 hddLog(VOS_TRACE_LEVEL_ERROR,
1644 "%s: Channel [%d] is outside valid range from %d to %d\n",
1645 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1646 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1647 return -EINVAL;
1648 }
1649
1650 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1651
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301652 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1653 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001654 {
1655 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1656 {
1657 hddLog(VOS_TRACE_LEVEL_ERROR,
1658 "%s: Invalid Channel [%d] \n", __func__, channel);
1659 return -EINVAL;
1660 }
1661 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1662 "%s: set channel to [%d] for device mode =%d",
1663 __func__, channel,pAdapter->device_mode);
1664 }
1665 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001666 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001667 )
1668 {
1669 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1670 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1671 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1672
1673 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1674 {
1675 /* Link is up then return cant set channel*/
1676 hddLog( VOS_TRACE_LEVEL_ERROR,
1677 "%s: IBSS Associated, can't set the channel\n", __func__);
1678 return -EINVAL;
1679 }
1680
1681 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1682 pHddStaCtx->conn_info.operationChannel = channel;
1683 pRoamProfile->ChannelInfo.ChannelList =
1684 &pHddStaCtx->conn_info.operationChannel;
1685 }
1686 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001687 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001688 )
1689 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301690 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1691 {
1692 if(VOS_STATUS_SUCCESS !=
1693 wlan_hdd_validate_operation_channel(pAdapter,channel))
1694 {
1695 hddLog(VOS_TRACE_LEVEL_ERROR,
1696 "%s: Invalid Channel [%d] \n", __func__, channel);
1697 return -EINVAL;
1698 }
1699 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1700 }
1701 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001702 {
1703 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1704
1705 /* If auto channel selection is configured as enable/ 1 then ignore
1706 channel set by supplicant
1707 */
1708 if ( cfg_param->apAutoChannelSelection )
1709 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301710 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1711 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001712 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1713 "%s: set channel to auto channel (0) for device mode =%d",
1714 __func__, pAdapter->device_mode);
1715 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301716 else
1717 {
1718 if(VOS_STATUS_SUCCESS !=
1719 wlan_hdd_validate_operation_channel(pAdapter,channel))
1720 {
1721 hddLog(VOS_TRACE_LEVEL_ERROR,
1722 "%s: Invalid Channel [%d] \n", __func__, channel);
1723 return -EINVAL;
1724 }
1725 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1726 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001727 }
1728 }
1729 else
1730 {
1731 hddLog(VOS_TRACE_LEVEL_FATAL,
1732 "%s: Invalid device mode failed to set valid channel", __func__);
1733 return -EINVAL;
1734 }
1735 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301736 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001737}
1738
Jeff Johnson295189b2012-06-20 16:38:30 -07001739#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1740static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1741 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001742#else
1743static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1744 struct cfg80211_beacon_data *params,
1745 const u8 *ssid, size_t ssid_len,
1746 enum nl80211_hidden_ssid hidden_ssid)
1747#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001748{
1749 tsap_Config_t *pConfig;
1750 beacon_data_t *pBeacon = NULL;
1751 struct ieee80211_mgmt *pMgmt_frame;
1752 v_U8_t *pIe=NULL;
1753 v_U16_t capab_info;
1754 eCsrAuthType RSNAuthType;
1755 eCsrEncryptionType RSNEncryptType;
1756 eCsrEncryptionType mcRSNEncryptType;
1757 int status = VOS_STATUS_SUCCESS;
1758 tpWLAN_SAPEventCB pSapEventCallback;
1759 hdd_hostapd_state_t *pHostapdState;
1760 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1761 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301762 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 struct qc_mac_acl_entry *acl_entry = NULL;
1764 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001765 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766
1767 ENTER();
1768
1769 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1770
1771 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1772
1773 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1774
1775 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1776
1777 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1778
1779 //channel is already set in the set_channel Call back
1780 //pConfig->channel = pCommitConfig->channel;
1781
1782 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301783 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1785
1786 pConfig->dtim_period = pBeacon->dtim_period;
1787
1788 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1789 pConfig->dtim_period);
1790
1791
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001792 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001793 {
1794 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 WLAN_EID_COUNTRY);
Jeff Johnson32d95a32012-09-10 13:15:23 -07001796 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001798 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001799 pConfig->ieee80211d = 1;
1800 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1801 sme_setRegInfo(hHal, pConfig->countryCode);
1802 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001804 else
1805 {
1806 pConfig->ieee80211d = 0;
1807 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301808 /*
1809 * If auto channel is configured i.e. channel is 0,
1810 * so skip channel validation.
1811 */
1812 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1813 {
1814 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1815 {
1816 hddLog(VOS_TRACE_LEVEL_ERROR,
1817 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1818 return -EINVAL;
1819 }
1820 }
1821 else
1822 {
1823 if(1 != pHddCtx->is_dynamic_channel_range_set)
1824 {
1825 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1826 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1827 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1828 }
1829 pHddCtx->is_dynamic_channel_range_set = 0;
1830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001832 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 {
1834 pConfig->ieee80211d = 0;
1835 }
1836 pConfig->authType = eSAP_AUTO_SWITCH;
1837
1838 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301839
1840 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1842
1843 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1844
1845 /*Set wps station to configured*/
1846 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1847
1848 if(pIe)
1849 {
1850 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1851 {
1852 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1853 return -EINVAL;
1854 }
1855 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1856 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001857 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 /* Check 15 bit of WPS IE as it contain information for wps state
1859 * WPS state
1860 */
1861 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1862 {
1863 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1864 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1865 {
1866 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1867 }
1868 }
1869 }
1870 else
1871 {
1872 pConfig->wps_state = SAP_WPS_DISABLED;
1873 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301874 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001875
1876 pConfig->RSNWPAReqIELength = 0;
1877 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301878 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 WLAN_EID_RSN);
1880 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301881 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001882 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1883 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1884 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301885 /* The actual processing may eventually be more extensive than
1886 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 * by the app.
1888 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301889 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1891 &RSNEncryptType,
1892 &mcRSNEncryptType,
1893 &RSNAuthType,
1894 pConfig->pRSNWPAReqIE[1]+2,
1895 pConfig->pRSNWPAReqIE );
1896
1897 if( VOS_STATUS_SUCCESS == status )
1898 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301899 /* Now copy over all the security attributes you have
1900 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 * */
1902 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1903 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1904 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1905 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301906 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 "EncryptionType = %d mcEncryptionType = %d\n"),
1908 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1909 }
1910 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301911
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1913 pBeacon->tail, pBeacon->tail_len);
1914
1915 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1916 {
1917 if (pConfig->pRSNWPAReqIE)
1918 {
1919 /*Mixed mode WPA/WPA2*/
1920 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1921 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1922 }
1923 else
1924 {
1925 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1926 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1927 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301928 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001929 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1930 &RSNEncryptType,
1931 &mcRSNEncryptType,
1932 &RSNAuthType,
1933 pConfig->pRSNWPAReqIE[1]+2,
1934 pConfig->pRSNWPAReqIE );
1935
1936 if( VOS_STATUS_SUCCESS == status )
1937 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301938 /* Now copy over all the security attributes you have
1939 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 * */
1941 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1942 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1943 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1944 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301945 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 "EncryptionType = %d mcEncryptionType = %d\n"),
1947 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1948 }
1949 }
1950 }
1951
Jeff Johnson4416a782013-03-25 14:17:50 -07001952 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1953 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1954 return -EINVAL;
1955 }
1956
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1958
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001959#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 if (params->ssid != NULL)
1961 {
1962 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1963 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1964 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1965 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1966 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001967#else
1968 if (ssid != NULL)
1969 {
1970 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1971 pConfig->SSIDinfo.ssid.length = ssid_len;
1972 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1973 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1974 }
1975#endif
1976
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301977 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301979
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 /* default value */
1981 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1982 pConfig->num_accept_mac = 0;
1983 pConfig->num_deny_mac = 0;
1984
1985 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1986 pBeacon->tail, pBeacon->tail_len);
1987
1988 /* pIe for black list is following form:
1989 type : 1 byte
1990 length : 1 byte
1991 OUI : 4 bytes
1992 acl type : 1 byte
1993 no of mac addr in black list: 1 byte
1994 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301995 */
1996 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 {
1998 pConfig->SapMacaddr_acl = pIe[6];
1999 pConfig->num_deny_mac = pIe[7];
2000 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
2001 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302002 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2003 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002004 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2005 for (i = 0; i < pConfig->num_deny_mac; i++)
2006 {
2007 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2008 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302009 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002010 }
2011 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2012 pBeacon->tail, pBeacon->tail_len);
2013
2014 /* pIe for white list is following form:
2015 type : 1 byte
2016 length : 1 byte
2017 OUI : 4 bytes
2018 acl type : 1 byte
2019 no of mac addr in white list: 1 byte
2020 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302021 */
2022 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 {
2024 pConfig->SapMacaddr_acl = pIe[6];
2025 pConfig->num_accept_mac = pIe[7];
2026 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2027 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302028 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2029 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2031 for (i = 0; i < pConfig->num_accept_mac; i++)
2032 {
2033 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2034 acl_entry++;
2035 }
2036 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302037
Jeff Johnson295189b2012-06-20 16:38:30 -07002038 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2039
Jeff Johnsone7245742012-09-05 17:12:55 -07002040#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002041 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05302042 * This is valid only if mode is set to 11n in hostapd, either AUTO or
2043 * 11ac in .ini and 11ac is supported by both host and firmware.
2044 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
2045 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002046 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2047 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302048 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002049 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
Kiet Lam0f320422013-11-21 19:29:17 +05302050 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) &&
2051 (sme_IsFeatureSupportedByDriver(DOT11AC)) && (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002052 {
2053 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002054
2055 /* Disable VHT support in 2.4 GHz band */
2056 if (pConfig->channel <= 14 &&
2057 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2058 {
2059 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2060 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002061 }
2062#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302063
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002064 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2065 {
2066 sme_SelectCBMode(hHal,
2067 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2068 pConfig->channel);
2069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 // ht_capab is not what the name conveys,this is used for protection bitmap
2071 pConfig->ht_capab =
2072 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2073
2074 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2075 {
2076 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2077 return -EINVAL;
2078 }
2079
2080 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302081 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2083 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302084 pConfig->obssProtEnabled =
2085 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002086
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302087 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002088 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302089 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2091 (int)pConfig->channel);
2092 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302093 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2094 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302096 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2098 pConfig->protEnabled, pConfig->obssProtEnabled);
2099
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302100 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 {
2102 //Bss already started. just return.
2103 //TODO Probably it should update some beacon params.
2104 hddLog( LOGE, "Bss Already started...Ignore the request");
2105 EXIT();
2106 return 0;
2107 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302108
Jeff Johnson295189b2012-06-20 16:38:30 -07002109 pConfig->persona = pHostapdAdapter->device_mode;
2110
2111 pSapEventCallback = hdd_hostapd_SAPEventCB;
2112 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2113 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2114 {
2115 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2116 return -EINVAL;
2117 }
2118
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302119 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2121
2122 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302123
Jeff Johnson295189b2012-06-20 16:38:30 -07002124 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302125 {
2126 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002127 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002128 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 VOS_ASSERT(0);
2130 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302131
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 //Succesfully started Bss update the state bit.
2133 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2134
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002135#ifdef WLAN_FEATURE_P2P_DEBUG
2136 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2137 {
2138 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2139 {
2140 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2141 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002142 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002143 }
2144 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2145 {
2146 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2147 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002148 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002149 }
2150 }
2151#endif
2152
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 pHostapdState->bCommit = TRUE;
2154 EXIT();
2155
2156 return 0;
2157}
2158
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002159#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302160static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2161 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 struct beacon_parameters *params)
2163{
2164 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302165 hdd_context_t *pHddCtx;
2166 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002167
2168 ENTER();
2169
2170 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2171
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302172 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2173 status = wlan_hdd_validate_context(pHddCtx);
2174
2175 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002176 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302177 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2178 "%s: HDD context is not valid", __func__);
2179 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002180 }
2181
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302182 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 )
2185 {
2186 beacon_data_t *old,*new;
2187
2188 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302189
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 if (old)
2191 return -EALREADY;
2192
2193 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2194
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302195 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 {
2197 hddLog(VOS_TRACE_LEVEL_FATAL,
2198 "%s:Error!!! Allocating the new beacon\n",__func__);
2199 return -EINVAL;
2200 }
2201
2202 pAdapter->sessionCtx.ap.beacon = new;
2203
2204 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2205 }
2206
2207 EXIT();
2208 return status;
2209}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302210
2211static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 struct net_device *dev,
2213 struct beacon_parameters *params)
2214{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302215 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302216 hdd_context_t *pHddCtx;
2217 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002218
2219 ENTER();
2220
2221 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2222 __func__,pAdapter->device_mode);
2223
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302224 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2225 status = wlan_hdd_validate_context(pHddCtx);
2226
2227 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002228 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302229 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2230 "%s: HDD context is not valid", __func__);
2231 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002232 }
2233
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302234 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302236 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 {
2238 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302239
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302241
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 if (!old)
2243 return -ENOENT;
2244
2245 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2246
2247 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302248 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 "%s: Error!!! Allocating the new beacon\n",__func__);
2250 return -EINVAL;
2251 }
2252
2253 pAdapter->sessionCtx.ap.beacon = new;
2254
2255 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2256 }
2257
2258 EXIT();
2259 return status;
2260}
2261
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002262#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2263
2264#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002265static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2266 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002267#else
2268static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2269 struct net_device *dev)
2270#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002271{
2272 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002273 hdd_context_t *pHddCtx = NULL;
2274 hdd_scaninfo_t *pScanInfo = NULL;
2275 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302276 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002277
2278 ENTER();
2279
2280 if (NULL == pAdapter)
2281 {
2282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002283 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 return -ENODEV;
2285 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002286
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302287 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2288 status = wlan_hdd_validate_context(pHddCtx);
2289
2290 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002291 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2293 "%s: HDD context is not valid", __func__);
2294 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002295 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002296
2297 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2298 if (NULL == staAdapter)
2299 {
2300 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2301 if (NULL == staAdapter)
2302 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002303 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2304 "%s: HDD adapter context for STA/P2P-CLI is Null",
2305 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002306 }
2307 }
2308
2309 pScanInfo = &pHddCtx->scan_info;
2310
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2312 __func__,pAdapter->device_mode);
2313
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002314 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002315 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002316 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302317 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002318 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002319 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002320 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2321 if (!status)
2322 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002323 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson902c9832012-12-10 14:28:09 -08002324 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002325 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002326 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002327 }
2328 }
2329
Jeff Johnson295189b2012-06-20 16:38:30 -07002330 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 )
2333 {
2334 beacon_data_t *old;
2335
2336 old = pAdapter->sessionCtx.ap.beacon;
2337
2338 if (!old)
2339 return -ENOENT;
2340
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002342
2343 mutex_lock(&pHddCtx->sap_lock);
2344 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2345 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002346 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 {
2348 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2349
2350 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2351
2352 if (!VOS_IS_STATUS_SUCCESS(status))
2353 {
2354 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2355 ("ERROR: HDD vos wait for single_event failed!!\n"));
2356 VOS_ASSERT(0);
2357 }
2358 }
2359 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2360 }
2361 mutex_unlock(&pHddCtx->sap_lock);
2362
2363 if(status != VOS_STATUS_SUCCESS)
2364 {
2365 hddLog(VOS_TRACE_LEVEL_FATAL,
2366 "%s:Error!!! Stopping the BSS\n",__func__);
2367 return -EINVAL;
2368 }
2369
Jeff Johnson4416a782013-03-25 14:17:50 -07002370 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2372 ==eHAL_STATUS_FAILURE)
2373 {
2374 hddLog(LOGE,
2375 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2376 }
2377
Jeff Johnson4416a782013-03-25 14:17:50 -07002378 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2380 eANI_BOOLEAN_FALSE) )
2381 {
2382 hddLog(LOGE,
2383 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2384 }
2385
2386 // Reset WNI_CFG_PROBE_RSP Flags
2387 wlan_hdd_reset_prob_rspies(pAdapter);
2388
2389 pAdapter->sessionCtx.ap.beacon = NULL;
2390 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002391#ifdef WLAN_FEATURE_P2P_DEBUG
2392 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2393 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2394 {
2395 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2396 "GO got removed");
2397 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2398 }
2399#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 }
2401 EXIT();
2402 return status;
2403}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002404
2405#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2406
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302407static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2408 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002409 struct cfg80211_ap_settings *params)
2410{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302411 hdd_adapter_t *pAdapter;
2412 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302413 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002414
2415 ENTER();
2416
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302417 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002418 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302420 "%s: Device is Null", __func__);
2421 return -ENODEV;
2422 }
2423
2424 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2425 if (NULL == pAdapter)
2426 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302428 "%s: HDD adapter is Null", __func__);
2429 return -ENODEV;
2430 }
2431
2432 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2433 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302435 "%s: HDD adapter magic is invalid", __func__);
2436 return -ENODEV;
2437 }
2438
2439 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302440 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302441
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302442 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302443 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302444 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2445 "%s: HDD context is not valid", __func__);
2446 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302447 }
2448
2449 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2450 __func__, pAdapter->device_mode);
2451
2452 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002453 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002454 )
2455 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302456 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002457
2458 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302459
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002460 if (old)
2461 return -EALREADY;
2462
2463 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2464
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302465 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002466 {
2467 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302468 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002469 return -EINVAL;
2470 }
2471 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002472#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002473 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2474#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2475 params->channel, params->channel_type);
2476#else
2477 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2478#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002479#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002480 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2481 params->ssid_len, params->hidden_ssid);
2482 }
2483
2484 EXIT();
2485 return status;
2486}
2487
2488
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302489static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002490 struct net_device *dev,
2491 struct cfg80211_beacon_data *params)
2492{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302493 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302494 hdd_context_t *pHddCtx;
2495 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002496
2497 ENTER();
2498
2499 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2500 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302501
2502 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2503 status = wlan_hdd_validate_context(pHddCtx);
2504
2505 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002506 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302507 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2508 "%s: HDD context is not valid", __func__);
2509 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002510 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002511
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302512 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002513 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302514 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002515 {
2516 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302517
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002518 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302519
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002520 if (!old)
2521 return -ENOENT;
2522
2523 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2524
2525 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302526 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002527 "%s: Error!!! Allocating the new beacon\n",__func__);
2528 return -EINVAL;
2529 }
2530
2531 pAdapter->sessionCtx.ap.beacon = new;
2532
2533 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2534 }
2535
2536 EXIT();
2537 return status;
2538}
2539
2540#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2541
Jeff Johnson295189b2012-06-20 16:38:30 -07002542
2543static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2544 struct net_device *dev,
2545 struct bss_parameters *params)
2546{
2547 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2548
2549 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302550
Jeff Johnson295189b2012-06-20 16:38:30 -07002551 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2552 __func__,pAdapter->device_mode);
2553
2554 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002555 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302556 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002557 {
2558 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2559 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302560 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 {
2562 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002564 }
2565
2566 EXIT();
2567 return 0;
2568}
2569
Kiet Lam10841362013-11-01 11:36:50 +05302570/* FUNCTION: wlan_hdd_change_country_code_cd
2571* to wait for contry code completion
2572*/
2573void* wlan_hdd_change_country_code_cb(void *pAdapter)
2574{
2575 hdd_adapter_t *call_back_pAdapter = pAdapter;
2576 complete(&call_back_pAdapter->change_country_code);
2577 return NULL;
2578}
2579
Jeff Johnson295189b2012-06-20 16:38:30 -07002580/*
2581 * FUNCTION: wlan_hdd_cfg80211_change_iface
2582 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2583 */
2584int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2585 struct net_device *ndev,
2586 enum nl80211_iftype type,
2587 u32 *flags,
2588 struct vif_params *params
2589 )
2590{
2591 struct wireless_dev *wdev;
2592 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2593 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002594 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002595 tCsrRoamProfile *pRoamProfile = NULL;
2596 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302597 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002598 eMib_dot11DesiredBssType connectedBssType;
2599 VOS_STATUS status;
2600
2601 ENTER();
2602
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302603 status = wlan_hdd_validate_context(pHddCtx);
2604
2605 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302607 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2608 "%s: HDD context is not valid", __func__);
2609 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 }
2611
2612 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2613 __func__, pAdapter->device_mode);
2614
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302615 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 wdev = ndev->ieee80211_ptr;
2617
2618#ifdef WLAN_BTAMP_FEATURE
2619 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2620 (NL80211_IFTYPE_ADHOC == type)||
2621 (NL80211_IFTYPE_AP == type)||
2622 (NL80211_IFTYPE_P2P_GO == type))
2623 {
2624 pHddCtx->isAmpAllowed = VOS_FALSE;
2625 // stop AMP traffic
2626 status = WLANBAP_StopAmp();
2627 if(VOS_STATUS_SUCCESS != status )
2628 {
2629 pHddCtx->isAmpAllowed = VOS_TRUE;
2630 hddLog(VOS_TRACE_LEVEL_FATAL,
2631 "%s: Failed to stop AMP", __func__);
2632 return -EINVAL;
2633 }
2634 }
2635#endif //WLAN_BTAMP_FEATURE
2636 /* Reset the current device mode bit mask*/
2637 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2638
2639 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002641 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 )
2643 {
2644 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2645 pRoamProfile = &pWextState->roamProfile;
2646 LastBSSType = pRoamProfile->BSSType;
2647
2648 switch (type)
2649 {
2650 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 hddLog(VOS_TRACE_LEVEL_INFO,
2653 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2654 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002655#ifdef WLAN_FEATURE_11AC
2656 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2657 {
2658 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2659 }
2660#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302661 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002662 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002664 //Check for sub-string p2p to confirm its a p2p interface
2665 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302666 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002667 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2668 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2669 }
2670 else
2671 {
2672 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002674 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302675#ifdef FEATURE_WLAN_TDLS
2676 /* The open adapter for the p2p shall skip initializations in
2677 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2678 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2679 * tdls_init when the change_iface sets the device mode to
2680 * WLAN_HDD_P2P_CLIENT.
2681 */
2682
2683 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2684 {
2685 if (0 != wlan_hdd_tdls_init (pAdapter))
2686 {
2687 return -EINVAL;
2688 }
2689 }
2690#endif
2691
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 break;
2693 case NL80211_IFTYPE_ADHOC:
2694 hddLog(VOS_TRACE_LEVEL_INFO,
2695 "%s: setting interface Type to ADHOC", __func__);
2696 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2697 pRoamProfile->phyMode =
2698 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002699 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002700 wdev->iftype = type;
2701 break;
2702
2703 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002704 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 {
2706 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2707 "%s: setting interface Type to %s", __func__,
2708 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2709
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002710 //Cancel any remain on channel for GO mode
2711 if (NL80211_IFTYPE_P2P_GO == type)
2712 {
2713 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2714 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002715 if (NL80211_IFTYPE_AP == type)
2716 {
2717 /* As Loading WLAN Driver one interface being created for p2p device
2718 * address. This will take one HW STA and the max number of clients
2719 * that can connect to softAP will be reduced by one. so while changing
2720 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2721 * interface as it is not required in SoftAP mode.
2722 */
2723
2724 // Get P2P Adapter
2725 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2726
2727 if (pP2pAdapter)
2728 {
2729 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2730 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2731 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2732 }
2733 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302734#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002735
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302736 /* A Mutex Lock is introduced while changing the mode to
2737 * protect the concurrent access for the Adapters by TDLS
2738 * module.
2739 */
2740 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2741 {
2742 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2743 "%s: unable to lock list", __func__);
2744 return -EINVAL;
2745 }
2746#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 //De-init the adapter.
2748 hdd_stop_adapter( pHddCtx, pAdapter );
2749 hdd_deinit_adapter( pHddCtx, pAdapter );
2750 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2752 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302753#ifdef FEATURE_WLAN_TDLS
2754 mutex_unlock(&pHddCtx->tdls_lock);
2755#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002756
2757 //Disable BMPS and IMPS if enabled
2758 //before starting Go
2759 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2760 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302761 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002762 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2763 {
2764 //Fail to Exit BMPS
2765 VOS_ASSERT(0);
2766 }
2767 }
2768
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002769 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2770 (pConfig->apRandomBssidEnabled))
2771 {
2772 /* To meet Android requirements create a randomized
2773 MAC address of the form 02:1A:11:Fx:xx:xx */
2774 get_random_bytes(&ndev->dev_addr[3], 3);
2775 ndev->dev_addr[0] = 0x02;
2776 ndev->dev_addr[1] = 0x1A;
2777 ndev->dev_addr[2] = 0x11;
2778 ndev->dev_addr[3] |= 0xF0;
2779 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2780 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08002781 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
2782 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002783 }
2784
Jeff Johnson295189b2012-06-20 16:38:30 -07002785 hdd_set_ap_ops( pAdapter->dev );
2786
Kiet Lam10841362013-11-01 11:36:50 +05302787 /* This is for only SAP mode where users can
2788 * control country through ini.
2789 * P2P GO follows station country code
2790 * acquired during the STA scanning. */
2791 if((NL80211_IFTYPE_AP == type) &&
2792 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
2793 {
2794 int status = 0;
2795 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
2796 "%s: setting country code from INI ", __func__);
2797 init_completion(&pAdapter->change_country_code);
2798 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2799 (void *)(tSmeChangeCountryCallback)
2800 wlan_hdd_change_country_code_cb,
2801 pConfig->apCntryCode, pAdapter,
2802 pHddCtx->pvosContext,
2803 VOS_FALSE);
2804 if (eHAL_STATUS_SUCCESS == status)
2805 {
2806 /* Wait for completion */
2807 status = wait_for_completion_interruptible_timeout(
2808 &pAdapter->change_country_code,
2809 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2810 if (status <= 0)
2811 {
2812 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2813 "%s: SME Timed out while setting country code ",
2814 __func__);
2815 }
2816 }
2817 else
2818 {
2819 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2820 "%s: SME Change Country code failed \n",__func__);
2821 return -EINVAL;
2822 }
2823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 status = hdd_init_ap_mode(pAdapter);
2825 if(status != VOS_STATUS_SUCCESS)
2826 {
2827 hddLog(VOS_TRACE_LEVEL_FATAL,
2828 "%s: Error initializing the ap mode", __func__);
2829 return -EINVAL;
2830 }
2831 hdd_set_conparam(1);
2832
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 /*interface type changed update in wiphy structure*/
2834 if(wdev)
2835 {
2836 wdev->iftype = type;
2837 pHddCtx->change_iface = type;
2838 }
2839 else
2840 {
2841 hddLog(VOS_TRACE_LEVEL_ERROR,
2842 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2843 return -EINVAL;
2844 }
2845 goto done;
2846 }
2847
2848 default:
2849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2850 __func__);
2851 return -EOPNOTSUPP;
2852 }
2853 }
2854 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 )
2857 {
2858 switch(type)
2859 {
2860 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302863#ifdef FEATURE_WLAN_TDLS
2864
2865 /* A Mutex Lock is introduced while changing the mode to
2866 * protect the concurrent access for the Adapters by TDLS
2867 * module.
2868 */
2869 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2870 {
2871 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2872 "%s: unable to lock list", __func__);
2873 return -EINVAL;
2874 }
2875#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002876 hdd_stop_adapter( pHddCtx, pAdapter );
2877 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002879 //Check for sub-string p2p to confirm its a p2p interface
2880 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002881 {
2882 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2883 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2884 }
2885 else
2886 {
2887 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 hdd_set_conparam(0);
2891 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2893 hdd_set_station_ops( pAdapter->dev );
2894 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302895#ifdef FEATURE_WLAN_TDLS
2896 mutex_unlock(&pHddCtx->tdls_lock);
2897#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 if( VOS_STATUS_SUCCESS != status )
2899 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002900 /* In case of JB, for P2P-GO, only change interface will be called,
2901 * This is the right place to enable back bmps_imps()
2902 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302903 if (pHddCtx->hdd_wlan_suspended)
2904 {
2905 hdd_set_pwrparams(pHddCtx);
2906 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002907 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 goto done;
2909 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2913 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 goto done;
2915 default:
2916 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2917 __func__);
2918 return -EOPNOTSUPP;
2919
2920 }
2921
2922 }
2923 else
2924 {
2925 return -EOPNOTSUPP;
2926 }
2927
2928
2929 if(pRoamProfile)
2930 {
2931 if ( LastBSSType != pRoamProfile->BSSType )
2932 {
2933 /*interface type changed update in wiphy structure*/
2934 wdev->iftype = type;
2935
2936 /*the BSS mode changed, We need to issue disconnect
2937 if connected or in IBSS disconnect state*/
2938 if ( hdd_connGetConnectedBssType(
2939 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2940 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2941 {
2942 /*need to issue a disconnect to CSR.*/
2943 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2944 if( eHAL_STATUS_SUCCESS ==
2945 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2946 pAdapter->sessionId,
2947 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2948 {
2949 wait_for_completion_interruptible_timeout(
2950 &pAdapter->disconnect_comp_var,
2951 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2952 }
2953 }
2954 }
2955 }
2956
2957done:
2958 /*set bitmask based on updated value*/
2959 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002960
2961 /* Only STA mode support TM now
2962 * all other mode, TM feature should be disabled */
2963 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2964 (~VOS_STA & pHddCtx->concurrency_mode) )
2965 {
2966 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2967 }
2968
Jeff Johnson295189b2012-06-20 16:38:30 -07002969#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302970 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2972 {
2973 //we are ok to do AMP
2974 pHddCtx->isAmpAllowed = VOS_TRUE;
2975 }
2976#endif //WLAN_BTAMP_FEATURE
2977 EXIT();
2978 return 0;
2979}
2980
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002981#ifdef FEATURE_WLAN_TDLS
2982static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2983 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2984{
2985 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2986 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2987 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07002988 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002989
2990 ENTER();
2991
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05302992 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002993 {
2994 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2995 "Invalid arguments");
2996 return -EINVAL;
2997 }
Hoonki Lee27511902013-03-14 18:19:06 -07002998
2999 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3000 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3001 {
3002 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3003 "%s: TDLS mode is disabled OR not enabled in FW."
3004 MAC_ADDRESS_STR " Request declined.",
3005 __func__, MAC_ADDR_ARRAY(mac));
3006 return -ENOTSUPP;
3007 }
3008
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003009 if (pHddCtx->isLogpInProgress)
3010 {
3011 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3012 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003013 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003014 return -EBUSY;
3015 }
3016
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303017 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003018
3019 if ( NULL == pTdlsPeer ) {
3020 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3021 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3022 __func__, MAC_ADDR_ARRAY(mac), update);
3023 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003024 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003025
3026 /* in add station, we accept existing valid staId if there is */
3027 if ((0 == update) &&
3028 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3029 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003030 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003031 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003032 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003033 " link_status %d. staId %d. add station ignored.",
3034 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3035 return 0;
3036 }
3037 /* in change station, we accept only when staId is valid */
3038 if ((1 == update) &&
3039 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3040 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3041 {
3042 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3043 "%s: " MAC_ADDRESS_STR
3044 " link status %d. staId %d. change station %s.",
3045 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3046 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3047 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003048 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003049
3050 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303051 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003052 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003053 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3054 "%s: " MAC_ADDRESS_STR
3055 " TDLS setup is ongoing. Request declined.",
3056 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003057 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003058 }
3059
3060 /* first to check if we reached to maximum supported TDLS peer.
3061 TODO: for now, return -EPERM looks working fine,
3062 but need to check if any other errno fit into this category.*/
3063 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3064 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3066 "%s: " MAC_ADDRESS_STR
3067 " TDLS Max peer already connected. Request declined.",
3068 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003069 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003070 }
3071 else
3072 {
3073 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303074 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003075 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003076 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3078 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3079 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003080 return -EPERM;
3081 }
3082 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003083 if (0 == update)
3084 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003085
Jeff Johnsond75fe012013-04-06 10:53:06 -07003086 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303087 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003088 {
3089 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3090 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003091 if(StaParams->htcap_present)
3092 {
3093 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3094 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3095 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3096 "ht_capa->extended_capabilities: %0x",
3097 StaParams->HTCap.extendedHtCapInfo);
3098 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003099 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3100 "params->capability: %0x",StaParams->capability);
3101 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003102 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003103 if(StaParams->vhtcap_present)
3104 {
3105 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3106 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3107 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3108 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3109 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003110 {
3111 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003112 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003113 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3114 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3115 "[%d]: %x ", i, StaParams->supported_rates[i]);
3116 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003117 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303118 else if ((1 == update) && (NULL == StaParams))
3119 {
3120 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3121 "%s : update is true, but staParams is NULL. Error!", __func__);
3122 return -EPERM;
3123 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003124
3125 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3126
3127 if (!update)
3128 {
3129 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3130 pAdapter->sessionId, mac);
3131 }
3132 else
3133 {
3134 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3135 pAdapter->sessionId, mac, StaParams);
3136 }
3137
3138 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3139 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3140
3141 if (!status)
3142 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003143 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003144 "%s: timeout waiting for tdls add station indication",
3145 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003146 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003147 }
3148 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3149 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003151 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003152 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003153 }
3154
3155 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003156
3157error:
3158 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3159 return -EPERM;
3160
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003161}
3162#endif
3163
Jeff Johnson295189b2012-06-20 16:38:30 -07003164static int wlan_hdd_change_station(struct wiphy *wiphy,
3165 struct net_device *dev,
3166 u8 *mac,
3167 struct station_parameters *params)
3168{
3169 VOS_STATUS status = VOS_STATUS_SUCCESS;
3170 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303171 hdd_context_t *pHddCtx;
3172 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003174#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003175 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003176 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003177#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003178 ENTER();
3179
Gopichand Nakkala29149562013-05-10 21:43:41 +05303180 if ((NULL == pAdapter))
3181 {
3182 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3183 "invalid adapter ");
3184 return -EINVAL;
3185 }
3186
3187 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3188 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3189
3190 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3191 {
3192 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3193 "invalid HDD state or HDD station context");
3194 return -EINVAL;
3195 }
3196
3197 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003198 {
3199 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3200 "%s:LOGP in Progress. Ignore!!!", __func__);
3201 return -EAGAIN;
3202 }
3203
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3205
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003206 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3207 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003208 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003209 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303211 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 WLANTL_STA_AUTHENTICATED);
3213
Gopichand Nakkala29149562013-05-10 21:43:41 +05303214 if (status != VOS_STATUS_SUCCESS)
3215 {
3216 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3217 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3218 return -EINVAL;
3219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 }
3221 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003222 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3223 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303224#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003225 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3226 StaParams.capability = params->capability;
3227 StaParams.uapsd_queues = params->uapsd_queues;
3228 StaParams.max_sp = params->max_sp;
3229
3230 if (0 != params->ext_capab_len)
3231 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3232 sizeof(StaParams.extn_capability));
3233
3234 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003235 {
3236 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003237 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003238 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003239
3240 StaParams.supported_rates_len = params->supported_rates_len;
3241
3242 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3243 * The supported_rates array , for all the structures propogating till Add Sta
3244 * to the firmware has to be modified , if the supplicant (ieee80211) is
3245 * modified to send more rates.
3246 */
3247
3248 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3249 */
3250 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3251 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3252
3253 if (0 != StaParams.supported_rates_len) {
3254 int i = 0;
3255 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3256 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003257 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003258 "Supported Rates with Length %d", StaParams.supported_rates_len);
3259 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003260 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003261 "[%d]: %0x", i, StaParams.supported_rates[i]);
3262 }
3263
3264 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003265 {
3266 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003267 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003268 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003269
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003270 if (0 != params->ext_capab_len ) {
3271 /*Define A Macro : TODO Sunil*/
3272 if ((1<<4) & StaParams.extn_capability[3]) {
3273 isBufSta = 1;
3274 }
3275 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303276 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3277 params->max_sp, isBufSta);
3278 if (VOS_STATUS_SUCCESS != status) {
3279 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3280 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3281 return -EINVAL;
3282 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003283 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3284
3285 if (VOS_STATUS_SUCCESS != status) {
3286 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3287 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3288 return -EINVAL;
3289 }
3290 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003291#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303292 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003293 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 return status;
3295}
3296
3297/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 * FUNCTION: wlan_hdd_cfg80211_add_key
3299 * This function is used to initialize the key information
3300 */
3301#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003302static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 struct net_device *ndev,
3304 u8 key_index, bool pairwise,
3305 const u8 *mac_addr,
3306 struct key_params *params
3307 )
3308#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003309static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 struct net_device *ndev,
3311 u8 key_index, const u8 *mac_addr,
3312 struct key_params *params
3313 )
3314#endif
3315{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003316 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003317 tCsrRoamSetKey setKey;
3318 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303319 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003320 v_U32_t roamId= 0xFF;
3321 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 hdd_hostapd_state_t *pHostapdState;
3323 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003324 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303325 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003326
3327 ENTER();
3328
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303329 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3330 status = wlan_hdd_validate_context(pHddCtx);
3331
3332 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003333 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303334 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3335 "%s: HDD context is not valid", __func__);
3336 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003337 }
3338
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003339 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3340 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003341
3342 if (CSR_MAX_NUM_KEY <= key_index)
3343 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003344 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 key_index);
3346
3347 return -EINVAL;
3348 }
3349
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003350 if (CSR_MAX_KEY_LEN < params->key_len)
3351 {
3352 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3353 params->key_len);
3354
3355 return -EINVAL;
3356 }
3357
3358 hddLog(VOS_TRACE_LEVEL_INFO,
3359 "%s: called with key index = %d & key length %d",
3360 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003361
3362 /*extract key idx, key len and key*/
3363 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3364 setKey.keyId = key_index;
3365 setKey.keyLength = params->key_len;
3366 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3367
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003368 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 {
3370 case WLAN_CIPHER_SUITE_WEP40:
3371 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3372 break;
3373
3374 case WLAN_CIPHER_SUITE_WEP104:
3375 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3376 break;
3377
3378 case WLAN_CIPHER_SUITE_TKIP:
3379 {
3380 u8 *pKey = &setKey.Key[0];
3381 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3382
3383 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3384
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003385 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003386
3387 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003388 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 |--------------|----------|----------|
3390 <---16bytes---><--8bytes--><--8bytes-->
3391
3392 */
3393 /*Sme expects the 32 bytes key to be in the below order
3394
3395 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003396 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 |--------------|----------|----------|
3398 <---16bytes---><--8bytes--><--8bytes-->
3399 */
3400 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003401 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003402
3403 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003404 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003405
3406 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003407 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003408
3409
3410 break;
3411 }
3412
3413 case WLAN_CIPHER_SUITE_CCMP:
3414 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3415 break;
3416
3417#ifdef FEATURE_WLAN_WAPI
3418 case WLAN_CIPHER_SUITE_SMS4:
3419 {
3420 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3421 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3422 params->key, params->key_len);
3423 return 0;
3424 }
3425#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003426
Jeff Johnson295189b2012-06-20 16:38:30 -07003427#ifdef FEATURE_WLAN_CCX
3428 case WLAN_CIPHER_SUITE_KRK:
3429 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3430 break;
3431#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003432
3433#ifdef WLAN_FEATURE_11W
3434 case WLAN_CIPHER_SUITE_AES_CMAC:
3435 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003436 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003437#endif
3438
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003440 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 __func__, params->cipher);
3442 return -EOPNOTSUPP;
3443 }
3444
3445 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3446 __func__, setKey.encType);
3447
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003448 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003449#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3450 (!pairwise)
3451#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003452 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003453#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003454 )
3455 {
3456 /* set group key*/
3457 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3458 "%s- %d: setting Broadcast key",
3459 __func__, __LINE__);
3460 setKey.keyDirection = eSIR_RX_ONLY;
3461 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3462 }
3463 else
3464 {
3465 /* set pairwise key*/
3466 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3467 "%s- %d: setting pairwise key",
3468 __func__, __LINE__);
3469 setKey.keyDirection = eSIR_TX_RX;
3470 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3471 }
3472 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3473 {
3474 setKey.keyDirection = eSIR_TX_RX;
3475 /*Set the group key*/
3476 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3477 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003478
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003479 if ( 0 != status )
3480 {
3481 hddLog(VOS_TRACE_LEVEL_ERROR,
3482 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3483 return -EINVAL;
3484 }
3485 /*Save the keys here and call sme_RoamSetKey for setting
3486 the PTK after peer joins the IBSS network*/
3487 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3488 &setKey, sizeof(tCsrRoamSetKey));
3489 return status;
3490 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303491 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3492 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3493 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003495 if( pHostapdState->bssState == BSS_START )
3496 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3498
3499 if ( status != eHAL_STATUS_SUCCESS )
3500 {
3501 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3502 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3503 __LINE__, status );
3504 }
3505 }
3506
3507 /* Saving WEP keys */
3508 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3509 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3510 {
3511 //Save the wep key in ap context. Issue setkey after the BSS is started.
3512 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3513 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3514 }
3515 else
3516 {
3517 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003518 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3520 }
3521 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003522 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3523 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 {
3525 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3526 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3527
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303528#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3529 if (!pairwise)
3530#else
3531 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3532#endif
3533 {
3534 /* set group key*/
3535 if (pHddStaCtx->roam_info.deferKeyComplete)
3536 {
3537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3538 "%s- %d: Perform Set key Complete",
3539 __func__, __LINE__);
3540 hdd_PerformRoamSetKeyComplete(pAdapter);
3541 }
3542 }
3543
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3545
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003546 pWextState->roamProfile.Keys.defaultIndex = key_index;
3547
3548
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003549 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 params->key, params->key_len);
3551
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303552
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3554
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303555 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303557 __func__, setKey.peerMac[0], setKey.peerMac[1],
3558 setKey.peerMac[2], setKey.peerMac[3],
3559 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003560 setKey.keyDirection);
3561
3562 vos_status = wlan_hdd_check_ula_done(pAdapter);
3563
3564 if ( vos_status != VOS_STATUS_SUCCESS )
3565 {
3566 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3567 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3568 __LINE__, vos_status );
3569
3570 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3571
3572 return -EINVAL;
3573
3574 }
3575
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003576#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303577 /* The supplicant may attempt to set the PTK once pre-authentication
3578 is done. Save the key in the UMAC and include it in the ADD BSS
3579 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003580 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303581 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003582 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303583 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3584 "%s: Update PreAuth Key success", __func__);
3585 return 0;
3586 }
3587 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3588 {
3589 hddLog(VOS_TRACE_LEVEL_ERROR,
3590 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303591 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003592 }
3593#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003594
3595 /* issue set key request to SME*/
3596 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3597 pAdapter->sessionId, &setKey, &roamId );
3598
3599 if ( 0 != status )
3600 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303601 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3603 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3604 return -EINVAL;
3605 }
3606
3607
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303608 /* in case of IBSS as there was no information available about WEP keys during
3609 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303611 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3612 !( ( IW_AUTH_KEY_MGMT_802_1X
3613 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3615 )
3616 &&
3617 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3618 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3619 )
3620 )
3621 {
3622 setKey.keyDirection = eSIR_RX_ONLY;
3623 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3624
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303625 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303627 __func__, setKey.peerMac[0], setKey.peerMac[1],
3628 setKey.peerMac[2], setKey.peerMac[3],
3629 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 setKey.keyDirection);
3631
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303632 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 pAdapter->sessionId, &setKey, &roamId );
3634
3635 if ( 0 != status )
3636 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303637 hddLog(VOS_TRACE_LEVEL_ERROR,
3638 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 __func__, status);
3640 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3641 return -EINVAL;
3642 }
3643 }
3644 }
3645
3646 return 0;
3647}
3648
3649/*
3650 * FUNCTION: wlan_hdd_cfg80211_get_key
3651 * This function is used to get the key information
3652 */
3653#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303654static int wlan_hdd_cfg80211_get_key(
3655 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303657 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 const u8 *mac_addr, void *cookie,
3659 void (*callback)(void *cookie, struct key_params*)
3660 )
3661#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303662static int wlan_hdd_cfg80211_get_key(
3663 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 struct net_device *ndev,
3665 u8 key_index, const u8 *mac_addr, void *cookie,
3666 void (*callback)(void *cookie, struct key_params*)
3667 )
3668#endif
3669{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303670 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3672 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3673 struct key_params params;
3674
3675 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303676
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3678 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303679
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 memset(&params, 0, sizeof(params));
3681
3682 if (CSR_MAX_NUM_KEY <= key_index)
3683 {
3684 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003686
3687 switch(pRoamProfile->EncryptionType.encryptionType[0])
3688 {
3689 case eCSR_ENCRYPT_TYPE_NONE:
3690 params.cipher = IW_AUTH_CIPHER_NONE;
3691 break;
3692
3693 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3694 case eCSR_ENCRYPT_TYPE_WEP40:
3695 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3696 break;
3697
3698 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3699 case eCSR_ENCRYPT_TYPE_WEP104:
3700 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3701 break;
3702
3703 case eCSR_ENCRYPT_TYPE_TKIP:
3704 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3705 break;
3706
3707 case eCSR_ENCRYPT_TYPE_AES:
3708 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3709 break;
3710
3711 default:
3712 params.cipher = IW_AUTH_CIPHER_NONE;
3713 break;
3714 }
3715
3716 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3717 params.seq_len = 0;
3718 params.seq = NULL;
3719 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3720 callback(cookie, &params);
3721 return 0;
3722}
3723
3724/*
3725 * FUNCTION: wlan_hdd_cfg80211_del_key
3726 * This function is used to delete the key information
3727 */
3728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303729static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303731 u8 key_index,
3732 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 const u8 *mac_addr
3734 )
3735#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303736static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 struct net_device *ndev,
3738 u8 key_index,
3739 const u8 *mac_addr
3740 )
3741#endif
3742{
3743 int status = 0;
3744
3745 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303746 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 //it is observed that this is invalidating peer
3748 //key index whenever re-key is done. This is affecting data link.
3749 //It should be ok to ignore del_key.
3750#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303751 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3752 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3754 tCsrRoamSetKey setKey;
3755 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303756
Jeff Johnson295189b2012-06-20 16:38:30 -07003757 ENTER();
3758
3759 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3760 __func__,pAdapter->device_mode);
3761
3762 if (CSR_MAX_NUM_KEY <= key_index)
3763 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303764 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 key_index);
3766
3767 return -EINVAL;
3768 }
3769
3770 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3771 setKey.keyId = key_index;
3772
3773 if (mac_addr)
3774 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3775 else
3776 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3777
3778 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3779
3780 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303782 )
3783 {
3784
3785 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3787 if( pHostapdState->bssState == BSS_START)
3788 {
3789 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303790
Jeff Johnson295189b2012-06-20 16:38:30 -07003791 if ( status != eHAL_STATUS_SUCCESS )
3792 {
3793 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3794 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3795 __LINE__, status );
3796 }
3797 }
3798 }
3799 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303800 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 )
3802 {
3803 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3804
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303805 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3806
3807 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303809 __func__, setKey.peerMac[0], setKey.peerMac[1],
3810 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303812 if(pAdapter->sessionCtx.station.conn_info.connState ==
3813 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303815 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 if ( 0 != status )
3819 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303820 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 "%s: sme_RoamSetKey failure, returned %d",
3822 __func__, status);
3823 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3824 return -EINVAL;
3825 }
3826 }
3827 }
3828#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003829 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 return status;
3831}
3832
3833/*
3834 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3835 * This function is used to set the default tx key index
3836 */
3837#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3838static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3839 struct net_device *ndev,
3840 u8 key_index,
3841 bool unicast, bool multicast)
3842#else
3843static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3844 struct net_device *ndev,
3845 u8 key_index)
3846#endif
3847{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303848 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303849 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303850 hdd_wext_state_t *pWextState;
3851 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303852 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003853
3854 ENTER();
3855
Gopichand Nakkala29149562013-05-10 21:43:41 +05303856 if ((NULL == pAdapter))
3857 {
3858 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3859 "invalid adapter");
3860 return -EINVAL;
3861 }
3862
3863 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3864 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3865
3866 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3867 {
3868 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3869 "invalid Wext state or HDD context");
3870 return -EINVAL;
3871 }
3872
Jeff Johnson295189b2012-06-20 16:38:30 -07003873 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3874 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303875
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 if (CSR_MAX_NUM_KEY <= key_index)
3877 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303878 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 key_index);
3880
3881 return -EINVAL;
3882 }
3883
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303884 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3885 status = wlan_hdd_validate_context(pHddCtx);
3886
3887 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003888 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303889 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3890 "%s: HDD context is not valid", __func__);
3891 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003892 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303896 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303898 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08003899 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303900 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08003901 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303903 {
3904 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003905 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303906
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 tCsrRoamSetKey setKey;
3908 v_U32_t roamId= 0xFF;
3909 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303910
3911 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 Keys->defaultIndex = (u8)key_index;
3915 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3916 setKey.keyId = key_index;
3917 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303918
3919 vos_mem_copy(&setKey.Key[0],
3920 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303922
Gopichand Nakkala29149562013-05-10 21:43:41 +05303923 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303924
3925 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 &pHddStaCtx->conn_info.bssId[0],
3927 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303928
Gopichand Nakkala29149562013-05-10 21:43:41 +05303929 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3930 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3931 eCSR_ENCRYPT_TYPE_WEP104)
3932 {
3933 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3934 even though ap is configured for WEP-40 encryption. In this canse the key length
3935 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3936 type(104) and switching encryption type to 40*/
3937 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3938 eCSR_ENCRYPT_TYPE_WEP40;
3939 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3940 eCSR_ENCRYPT_TYPE_WEP40;
3941 }
3942
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303943 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303945
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303947 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303949
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 if ( 0 != status )
3951 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303952 hddLog(VOS_TRACE_LEVEL_ERROR,
3953 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 status);
3955 return -EINVAL;
3956 }
3957 }
3958 }
3959
3960 /* In SoftAp mode setting key direction for default mode */
3961 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3962 {
3963 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3964 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3965 (eCSR_ENCRYPT_TYPE_AES !=
3966 pWextState->roamProfile.EncryptionType.encryptionType[0])
3967 )
3968 {
3969 /* Saving key direction for default key index to TX default */
3970 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3971 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3972 }
3973 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303974
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 return status;
3976}
3977
Jeff Johnson295189b2012-06-20 16:38:30 -07003978/*
3979 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3980 * This function is used to inform the BSS details to nl80211 interface.
3981 */
3982static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3983 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3984{
3985 struct net_device *dev = pAdapter->dev;
3986 struct wireless_dev *wdev = dev->ieee80211_ptr;
3987 struct wiphy *wiphy = wdev->wiphy;
3988 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
3989 int chan_no;
3990 int ie_length;
3991 const char *ie;
3992 unsigned int freq;
3993 struct ieee80211_channel *chan;
3994 int rssi = 0;
3995 struct cfg80211_bss *bss = NULL;
3996
3997 ENTER();
3998
3999 if( NULL == pBssDesc )
4000 {
4001 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
4002 return bss;
4003 }
4004
4005 chan_no = pBssDesc->channelId;
4006 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4007 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4008
4009 if( NULL == ie )
4010 {
4011 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
4012 return bss;
4013 }
4014
4015#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4016 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4017 {
4018 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4019 }
4020 else
4021 {
4022 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4023 }
4024#else
4025 freq = ieee80211_channel_to_frequency(chan_no);
4026#endif
4027
4028 chan = __ieee80211_get_channel(wiphy, freq);
4029
4030 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4031 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4032 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4033 if (bss == NULL)
4034 {
4035 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4036
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304037 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4038 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 pBssDesc->capabilityInfo,
4040 pBssDesc->beaconInterval, ie, ie_length,
4041 rssi, GFP_KERNEL ));
4042}
4043 else
4044 {
4045 return bss;
4046 }
4047}
4048
4049
4050
4051/*
4052 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4053 * This function is used to inform the BSS details to nl80211 interface.
4054 */
4055struct cfg80211_bss*
4056wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4057 tSirBssDescription *bss_desc
4058 )
4059{
4060 /*
4061 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4062 already exists in bss data base of cfg80211 for that particular BSS ID.
4063 Using cfg80211_inform_bss_frame to update the bss entry instead of
4064 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4065 now there is no possibility to get the mgmt(probe response) frame from PE,
4066 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4067 cfg80211_inform_bss_frame.
4068 */
4069 struct net_device *dev = pAdapter->dev;
4070 struct wireless_dev *wdev = dev->ieee80211_ptr;
4071 struct wiphy *wiphy = wdev->wiphy;
4072 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004073#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4074 qcom_ie_age *qie_age = NULL;
4075 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4076#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004078#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 const char *ie =
4080 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4081 unsigned int freq;
4082 struct ieee80211_channel *chan;
4083 struct ieee80211_mgmt *mgmt =
4084 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4085 struct cfg80211_bss *bss_status = NULL;
4086 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4087 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004088 hdd_context_t *pHddCtx;
4089 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004090#ifdef WLAN_OPEN_SOURCE
4091 struct timespec ts;
4092#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004093
4094 ENTER();
4095
Wilson Yangf80a0542013-10-07 13:02:37 -07004096 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4097 status = wlan_hdd_validate_context(pHddCtx);
4098
4099 /*bss_update is not allowed during wlan driver loading or unloading*/
4100 if (pHddCtx->isLoadUnloadInProgress)
4101 {
4102 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4103 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4104 return NULL;
4105 }
4106
4107
4108 if (0 != status)
4109 {
4110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4111 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004112 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004113 }
4114
4115
4116 if (!mgmt)
4117 {
4118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4119 "%s: memory allocation failed ", __func__);
4120 return NULL;
4121 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004122
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004124
4125#ifdef WLAN_OPEN_SOURCE
4126 /* Android does not want the timestamp from the frame.
4127 Instead it wants a monotonic increasing value */
4128 get_monotonic_boottime(&ts);
4129 mgmt->u.probe_resp.timestamp =
4130 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4131#else
4132 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4134 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004135
4136#endif
4137
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4139 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004140
4141#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4142 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4143 /* Assuming this is the last IE, copy at the end */
4144 ie_length -=sizeof(qcom_ie_age);
4145 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4146 qie_age->element_id = QCOM_VENDOR_IE_ID;
4147 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4148 qie_age->oui_1 = QCOM_OUI1;
4149 qie_age->oui_2 = QCOM_OUI2;
4150 qie_age->oui_3 = QCOM_OUI3;
4151 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4152 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4153#endif
4154
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304156 if (bss_desc->fProbeRsp)
4157 {
4158 mgmt->frame_control |=
4159 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4160 }
4161 else
4162 {
4163 mgmt->frame_control |=
4164 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004166
4167#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304168 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4170 {
4171 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4172 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304173 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004174 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4175
4176 {
4177 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4178 }
4179 else
4180 {
4181 kfree(mgmt);
4182 return NULL;
4183 }
4184#else
4185 freq = ieee80211_channel_to_frequency(chan_no);
4186#endif
4187 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004188 /*when the band is changed on the fly using the GUI, three things are done
4189 * 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)
4190 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4191 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4192 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4193 * and discards the channels correponding to previous band and calls back with zero bss results.
4194 * 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
4195 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4196 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4197 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4198 * So drop the bss and continue to next bss.
4199 */
4200 if(chan == NULL)
4201 {
4202 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004203 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004204 return NULL;
4205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304207 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 * */
4209 if (( eConnectionState_Associated ==
4210 pAdapter->sessionCtx.station.conn_info.connState ) &&
4211 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4212 pAdapter->sessionCtx.station.conn_info.bssId,
4213 WNI_CFG_BSSID_LEN)))
4214 {
4215 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4216 rssi = (pAdapter->rssi * 100);
4217 }
4218 else
4219 {
4220 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4221 }
4222
4223 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4224 frame_len, rssi, GFP_KERNEL);
4225 kfree(mgmt);
4226 return bss_status;
4227}
4228
4229/*
4230 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4231 * This function is used to update the BSS data base of CFG8011
4232 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304233struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 tCsrRoamInfo *pRoamInfo
4235 )
4236{
4237 tCsrRoamConnectedProfile roamProfile;
4238 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4239 struct cfg80211_bss *bss = NULL;
4240
4241 ENTER();
4242
4243 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4244 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4245
4246 if (NULL != roamProfile.pBssDesc)
4247 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304248 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 &roamProfile);
4250
4251 if (NULL == bss)
4252 {
4253 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4254 __func__);
4255 }
4256
4257 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4258 }
4259 else
4260 {
4261 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4262 __func__);
4263 }
4264 return bss;
4265}
4266
4267/*
4268 * FUNCTION: wlan_hdd_cfg80211_update_bss
4269 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304270static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4271 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304273{
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4275 tCsrScanResultInfo *pScanResult;
4276 eHalStatus status = 0;
4277 tScanResultHandle pResult;
4278 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004279 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004280
4281 ENTER();
4282
Wilson Yangf80a0542013-10-07 13:02:37 -07004283 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4284
4285 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004287 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4288 "%s:LOGP in Progress. Ignore!!!",__func__);
4289 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 }
4291
Wilson Yangf80a0542013-10-07 13:02:37 -07004292
4293 /*bss_update is not allowed during wlan driver loading or unloading*/
4294 if (pHddCtx->isLoadUnloadInProgress)
4295 {
4296 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4297 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4298 return VOS_STATUS_E_PERM;
4299 }
4300
4301
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 /*
4303 * start getting scan results and populate cgf80211 BSS database
4304 */
4305 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4306
4307 /* no scan results */
4308 if (NULL == pResult)
4309 {
4310 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4311 return status;
4312 }
4313
4314 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4315
4316 while (pScanResult)
4317 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304318 /*
4319 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4320 * entry already exists in bss data base of cfg80211 for that
4321 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4322 * bss entry instead of cfg80211_inform_bss, But this call expects
4323 * mgmt packet as input. As of now there is no possibility to get
4324 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 * ieee80211_mgmt(probe response) and passing to c
4326 * fg80211_inform_bss_frame.
4327 * */
4328
4329 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4330 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304331
Jeff Johnson295189b2012-06-20 16:38:30 -07004332
4333 if (NULL == bss_status)
4334 {
4335 hddLog(VOS_TRACE_LEVEL_INFO,
4336 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4337 }
4338 else
4339 {
Yue Maf49ba872013-08-19 12:04:25 -07004340 cfg80211_put_bss(
4341#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4342 wiphy,
4343#endif
4344 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004345 }
4346
4347 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4348 }
4349
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304350 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304352 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004353}
4354
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004355void
4356hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4357{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304358 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004359 "%02X:%02X:%02X:%02X:%02X:%02X\n",
4360 macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4],
4361 macAddr[5]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004362} /****** end hddPrintMacAddr() ******/
4363
4364void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004365hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004366{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304367 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004368 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4369 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4370 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4371 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004372} /****** end hddPrintPmkId() ******/
4373
4374//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4375//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4376
4377//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4378//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4379
4380#define dump_bssid(bssid) \
4381 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004382 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4383 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4384 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004385 }
4386
4387#define dump_pmkid(pMac, pmkid) \
4388 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004389 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4390 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4391 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004392 }
4393
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004394#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004395/*
4396 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4397 * This function is used to notify the supplicant of a new PMKSA candidate.
4398 */
4399int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304400 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004401 int index, bool preauth )
4402{
Jeff Johnsone7245742012-09-05 17:12:55 -07004403#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004404 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004405 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004406
4407 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004408 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004409
4410 if( NULL == pRoamInfo )
4411 {
4412 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4413 return -EINVAL;
4414 }
4415
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004416 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4417 {
4418 dump_bssid(pRoamInfo->bssid);
4419 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004420 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004421 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004422#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304423 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004424}
4425#endif //FEATURE_WLAN_LFR
4426
Yue Maef608272013-04-08 23:09:17 -07004427#ifdef FEATURE_WLAN_LFR_METRICS
4428/*
4429 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4430 * 802.11r/LFR metrics reporting function to report preauth initiation
4431 *
4432 */
4433#define MAX_LFR_METRICS_EVENT_LENGTH 100
4434VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4435 tCsrRoamInfo *pRoamInfo)
4436{
4437 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4438 union iwreq_data wrqu;
4439
4440 ENTER();
4441
4442 if (NULL == pAdapter)
4443 {
4444 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4445 return VOS_STATUS_E_FAILURE;
4446 }
4447
4448 /* create the event */
4449 memset(&wrqu, 0, sizeof(wrqu));
4450 memset(metrics_notification, 0, sizeof(metrics_notification));
4451
4452 wrqu.data.pointer = metrics_notification;
4453 wrqu.data.length = scnprintf(metrics_notification,
4454 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4455 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4456
4457 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4458
4459 EXIT();
4460
4461 return VOS_STATUS_SUCCESS;
4462}
4463
4464/*
4465 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4466 * 802.11r/LFR metrics reporting function to report preauth completion
4467 * or failure
4468 */
4469VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4470 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4471{
4472 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4473 union iwreq_data wrqu;
4474
4475 ENTER();
4476
4477 if (NULL == pAdapter)
4478 {
4479 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4480 return VOS_STATUS_E_FAILURE;
4481 }
4482
4483 /* create the event */
4484 memset(&wrqu, 0, sizeof(wrqu));
4485 memset(metrics_notification, 0, sizeof(metrics_notification));
4486
4487 scnprintf(metrics_notification, sizeof(metrics_notification),
4488 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4489 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4490
4491 if (1 == preauth_status)
4492 strncat(metrics_notification, " TRUE", 5);
4493 else
4494 strncat(metrics_notification, " FALSE", 6);
4495
4496 wrqu.data.pointer = metrics_notification;
4497 wrqu.data.length = strlen(metrics_notification);
4498
4499 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4500
4501 EXIT();
4502
4503 return VOS_STATUS_SUCCESS;
4504}
4505
4506/*
4507 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4508 * 802.11r/LFR metrics reporting function to report handover initiation
4509 *
4510 */
4511VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4512 tCsrRoamInfo *pRoamInfo)
4513{
4514 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4515 union iwreq_data wrqu;
4516
4517 ENTER();
4518
4519 if (NULL == pAdapter)
4520 {
4521 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4522 return VOS_STATUS_E_FAILURE;
4523 }
4524
4525 /* create the event */
4526 memset(&wrqu, 0, sizeof(wrqu));
4527 memset(metrics_notification, 0, sizeof(metrics_notification));
4528
4529 wrqu.data.pointer = metrics_notification;
4530 wrqu.data.length = scnprintf(metrics_notification,
4531 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4532 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4533
4534 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4535
4536 EXIT();
4537
4538 return VOS_STATUS_SUCCESS;
4539}
4540#endif
4541
Jeff Johnson295189b2012-06-20 16:38:30 -07004542/*
4543 * FUNCTION: hdd_cfg80211_scan_done_callback
4544 * scanning callback function, called after finishing scan
4545 *
4546 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304547static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4549{
4550 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304551 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004552 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004553 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4554 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 struct cfg80211_scan_request *req = NULL;
4556 int ret = 0;
4557
4558 ENTER();
4559
4560 hddLog(VOS_TRACE_LEVEL_INFO,
4561 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304562 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 __func__, halHandle, pContext, (int) scanId, (int) status);
4564
Kiet Lamac06e2c2013-10-23 16:25:07 +05304565 pScanInfo->mScanPendingCounter = 0;
4566
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 //Block on scan req completion variable. Can't wait forever though.
4568 ret = wait_for_completion_interruptible_timeout(
4569 &pScanInfo->scan_req_completion_event,
4570 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4571 if (!ret)
4572 {
4573 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004574 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 }
4576
Yue Maef608272013-04-08 23:09:17 -07004577 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 {
4579 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004580 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 }
4582
4583 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304584 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 {
4586 hddLog(VOS_TRACE_LEVEL_INFO,
4587 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304588 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004589 (int) scanId);
4590 }
4591
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304592 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 pAdapter);
4594
4595 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304596 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004597
4598
4599 /* If any client wait scan result through WEXT
4600 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004601 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 {
4603 /* The other scan request waiting for current scan finish
4604 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004605 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004607 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 }
4609 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004610 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 {
4612 struct net_device *dev = pAdapter->dev;
4613 union iwreq_data wrqu;
4614 int we_event;
4615 char *msg;
4616
4617 memset(&wrqu, '\0', sizeof(wrqu));
4618 we_event = SIOCGIWSCAN;
4619 msg = NULL;
4620 wireless_send_event(dev, we_event, &wrqu, msg);
4621 }
4622 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004623 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004624
4625 /* Get the Scan Req */
4626 req = pAdapter->request;
4627
4628 if (!req)
4629 {
4630 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004631 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004632 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 }
4634
4635 /*
4636 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304637 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 req->n_ssids = 0;
4639 req->n_channels = 0;
4640 req->ie = 0;
4641
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004643 /* Scan is no longer pending */
4644 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004645
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004646 /*
4647 * cfg80211_scan_done informing NL80211 about completion
4648 * of scanning
4649 */
4650 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004651 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004652
Jeff Johnsone7245742012-09-05 17:12:55 -07004653allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004654 /* release the wake lock at the end of the scan*/
4655 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004656
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004657 /* Acquire wakelock to handle the case where APP's tries to suspend
4658 * immediatly after the driver gets connect request(i.e after scan)
4659 * from supplicant, this result in app's is suspending and not able
4660 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004661 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004662
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004663#ifdef FEATURE_WLAN_TDLS
4664 wlan_hdd_tdls_scan_done_callback(pAdapter);
4665#endif
4666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 EXIT();
4668 return 0;
4669}
4670
4671/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004672 * FUNCTION: hdd_isScanAllowed
4673 * Go through each adapter and check if scan allowed
4674 *
4675 */
4676v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4677{
4678 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4679 hdd_station_ctx_t *pHddStaCtx = NULL;
4680 hdd_adapter_t *pAdapter = NULL;
4681 VOS_STATUS status = 0;
4682 v_U8_t staId = 0;
4683 v_U8_t *staMac = NULL;
4684
4685 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4686
4687 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4688 {
4689 pAdapter = pAdapterNode->pAdapter;
4690
4691 if( pAdapter )
4692 {
4693 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304694 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004695 __func__, pAdapter->device_mode);
4696 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4697 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4698 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4699 {
4700 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4701 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4702 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4703 {
4704 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4705 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004706 "%s: client " MAC_ADDRESS_STR
4707 " is in the middle of WPS/EAPOL exchange.", __func__,
4708 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004709 return VOS_FALSE;
4710 }
4711 }
4712 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4713 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4714 {
4715 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4716 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304717 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004718 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4719 {
4720 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4721
4722 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004723 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
4724 "middle of WPS/EAPOL exchange.", __func__,
4725 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004726 return VOS_FALSE;
4727 }
4728 }
4729 }
4730 }
4731 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4732 pAdapterNode = pNext;
4733 }
4734 hddLog(VOS_TRACE_LEVEL_INFO,
4735 "%s: Scan allowed", __func__);
4736 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304737}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004738
4739/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 * FUNCTION: wlan_hdd_cfg80211_scan
4741 * this scan respond to scan trigger and update cfg80211 scan database
4742 * later, scan dump command can be used to recieve scan results
4743 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004744int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4745#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4746 struct net_device *dev,
4747#endif
4748 struct cfg80211_scan_request *request)
4749{
4750#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4751 struct net_device *dev = request->wdev->netdev;
4752#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304753 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4755 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304756 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 tCsrScanRequest scanRequest;
4758 tANI_U8 *channelList = NULL, i;
4759 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304760 int status;
4761 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004763
4764 ENTER();
4765
4766 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4767 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004768
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304769 status = wlan_hdd_validate_context(pHddCtx);
4770
4771 if (0 != status)
4772 {
4773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4774 "%s: HDD context is not valid", __func__);
4775 return status;
4776 }
4777
4778 cfg_param = pHddCtx->cfg_ini;
4779 pScanInfo = &pHddCtx->scan_info;
4780
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004781 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004782 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004783 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004784 {
4785 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004786 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4787 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004788 return -EBUSY;
4789 }
4790
Jeff Johnson295189b2012-06-20 16:38:30 -07004791#ifdef WLAN_BTAMP_FEATURE
4792 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004793 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004795 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 "%s: No scanning when AMP is on", __func__);
4797 return -EOPNOTSUPP;
4798 }
4799#endif
4800 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004801 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004803 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 "%s: Not scanning on device_mode = %d",
4805 __func__, pAdapter->device_mode);
4806 return -EOPNOTSUPP;
4807 }
4808
4809 if (TRUE == pScanInfo->mScanPending)
4810 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304811 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
4812 {
4813 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
4814 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004815 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 }
4817
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304818 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004819 //Channel and action frame is pending
4820 //Otherwise Cancel Remain On Channel and allow Scan
4821 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004822 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004823 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304824 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004825 return -EBUSY;
4826 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004827#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004828 /* if tdls disagree scan right now, return immediately.
4829 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4830 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4831 */
4832 status = wlan_hdd_tdls_scan_callback (pAdapter,
4833 wiphy,
4834#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4835 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004836#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004837 request);
4838 if(status <= 0)
4839 {
4840 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4841 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004842 }
4843#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4846 {
4847 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004848 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004851 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4852 {
4853 hddLog(VOS_TRACE_LEVEL_WARN,
4854 "%s: MAX TM Level Scan not allowed", __func__);
4855 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304856 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004857 }
4858 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4859
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004860 /* Check if scan is allowed at this point of time.
4861 */
4862 if (!hdd_isScanAllowed(pHddCtx))
4863 {
4864 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4865 return -EBUSY;
4866 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304867
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4869
4870 if (NULL != request)
4871 {
4872 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304873 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004874
4875 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4876 * Becasue of this, driver is assuming that this is not wildcard scan and so
4877 * is not aging out the scan results.
4878 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004879 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 {
4881 request->n_ssids = 0;
4882 }
4883
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004884 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 {
4886 tCsrSSIDInfo *SsidInfo;
4887 int j;
4888 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4889 /* Allocate num_ssid tCsrSSIDInfo structure */
4890 SsidInfo = scanRequest.SSIDs.SSIDList =
4891 ( tCsrSSIDInfo *)vos_mem_malloc(
4892 request->n_ssids*sizeof(tCsrSSIDInfo));
4893
4894 if(NULL == scanRequest.SSIDs.SSIDList)
4895 {
4896 hddLog(VOS_TRACE_LEVEL_ERROR,
4897 "memory alloc failed SSIDInfo buffer");
4898 return -ENOMEM;
4899 }
4900
4901 /* copy all the ssid's and their length */
4902 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4903 {
4904 /* get the ssid length */
4905 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4906 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4907 SsidInfo->SSID.length);
4908 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4909 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4910 j, SsidInfo->SSID.ssId);
4911 }
4912 /* set the scan type to active */
4913 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4914 }
4915 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4916 {
4917 /* set the scan type to active */
4918 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4919 }
4920 else
4921 {
4922 /*Set the scan type to default type, in this case it is ACTIVE*/
4923 scanRequest.scanType = pScanInfo->scan_mode;
4924 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304925 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4927 }
4928 else
4929 {
4930 /* set the scan type to active */
4931 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4932 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4933
4934 /* set min and max channel time to zero */
4935 scanRequest.minChnTime = 0;
4936 scanRequest.maxChnTime = 0;
4937 }
4938
4939 /* set BSSType to default type */
4940 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4941
4942 /*TODO: scan the requested channels only*/
4943
4944 /*Right now scanning all the channels */
4945 if( request )
4946 {
4947 if( request->n_channels )
4948 {
4949 channelList = vos_mem_malloc( request->n_channels );
4950 if( NULL == channelList )
4951 {
4952 status = -ENOMEM;
4953 goto free_mem;
4954 }
4955
4956 for( i = 0 ; i < request->n_channels ; i++ )
4957 channelList[i] = request->channels[i]->hw_value;
4958 }
4959
4960 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4961 scanRequest.ChannelInfo.ChannelList = channelList;
4962
4963 /* set requestType to full scan */
4964 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304965
4966 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004967 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304968 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004969 */
4970
4971 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304972 * and in that case driver shoudnt flush scan results. If
4973 * driver flushes the scan results here and unfortunately if
4974 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004975 * fails which is not desired
4976 */
4977
4978 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4979 {
4980 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4981 pAdapter->sessionId );
4982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004983
4984 if( request->ie_len )
4985 {
4986 /* save this for future association (join requires this) */
4987 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4988 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4989 pScanInfo->scanAddIE.length = request->ie_len;
4990
4991 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07004992 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4993 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 )
4995 {
4996 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
4997 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
4998 }
4999
5000 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5001 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5002
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5004 request->ie_len);
5005 if (pP2pIe != NULL)
5006 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005007#ifdef WLAN_FEATURE_P2P_DEBUG
5008 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5009 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5010 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5011 {
5012 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5013 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5014 "Go nego completed to Connection is started");
5015 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5016 "for 8way Handshake");
5017 }
5018 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5019 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5020 {
5021 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5022 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5023 "Disconnected state to Connection is started");
5024 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5025 "for 4way Handshake");
5026 }
5027#endif
5028
Jeff Johnsone7245742012-09-05 17:12:55 -07005029 /* no_cck will be set during p2p find to disable 11b rates */
5030 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005031 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 hddLog(VOS_TRACE_LEVEL_INFO,
5033 "%s: This is a P2P Search", __func__);
5034 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005035
Jeff Johnsone7245742012-09-05 17:12:55 -07005036 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5037 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005038 /* set requestType to P2P Discovery */
5039 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005040 }
5041
5042 /*
5043 Skip Dfs Channel in case of P2P Search
5044 if it is set in ini file
5045 */
5046 if(cfg_param->skipDfsChnlInP2pSearch)
5047 {
5048 scanRequest.skipDfsChnlInP2pSearch = 1;
5049 }
5050 else
5051 {
5052 scanRequest.skipDfsChnlInP2pSearch = 0;
5053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005054
Jeff Johnson295189b2012-06-20 16:38:30 -07005055 }
5056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 }
5058 }
5059
5060 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5061
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005062 /* acquire the wakelock to avoid the apps suspend during the scan. To
5063 * address the following issues.
5064 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5065 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5066 * for long time, this result in apps running at full power for long time.
5067 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5068 * be stuck in full power because of resume BMPS
5069 */
5070 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005071
5072 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005073 pAdapter->sessionId, &scanRequest, &scanId,
5074 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005075
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 if (eHAL_STATUS_SUCCESS != status)
5077 {
5078 hddLog(VOS_TRACE_LEVEL_ERROR,
5079 "%s: sme_ScanRequest returned error %d", __func__, status);
5080 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005081 if(eHAL_STATUS_RESOURCES == status)
5082 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07005083 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 -07005084 status = -EBUSY;
5085 } else {
5086 status = -EIO;
5087 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005088 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005089 goto free_mem;
5090 }
5091
5092 pScanInfo->mScanPending = TRUE;
5093 pAdapter->request = request;
5094 pScanInfo->scanId = scanId;
5095
5096 complete(&pScanInfo->scan_req_completion_event);
5097
5098free_mem:
5099 if( scanRequest.SSIDs.SSIDList )
5100 {
5101 vos_mem_free(scanRequest.SSIDs.SSIDList);
5102 }
5103
5104 if( channelList )
5105 vos_mem_free( channelList );
5106
5107 EXIT();
5108
5109 return status;
5110}
5111
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005112
5113void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5114{
5115 v_U8_t iniDot11Mode =
5116 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5117 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5118
5119 switch ( iniDot11Mode )
5120 {
5121 case eHDD_DOT11_MODE_AUTO:
5122 case eHDD_DOT11_MODE_11ac:
5123 case eHDD_DOT11_MODE_11ac_ONLY:
5124#ifdef WLAN_FEATURE_11AC
5125 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5126#else
5127 hddDot11Mode = eHDD_DOT11_MODE_11n;
5128#endif
5129 break;
5130 case eHDD_DOT11_MODE_11n:
5131 case eHDD_DOT11_MODE_11n_ONLY:
5132 hddDot11Mode = eHDD_DOT11_MODE_11n;
5133 break;
5134 default:
5135 hddDot11Mode = iniDot11Mode;
5136 break;
5137 }
5138 /* This call decides required channel bonding mode */
5139 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5140 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5141 operationChannel);
5142}
5143
Jeff Johnson295189b2012-06-20 16:38:30 -07005144/*
5145 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305146 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005147 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305148int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005149 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005150{
5151 int status = 0;
5152 hdd_wext_state_t *pWextState;
5153 v_U32_t roamId;
5154 tCsrRoamProfile *pRoamProfile;
5155 eMib_dot11DesiredBssType connectedBssType;
5156 eCsrAuthType RSNAuthType;
5157
5158 ENTER();
5159
5160 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305161
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5163 {
5164 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5165 return -EINVAL;
5166 }
5167
5168 pRoamProfile = &pWextState->roamProfile;
5169
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305170 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005171 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005172 int ret = 0;
5173 hdd_station_ctx_t *pHddStaCtx;
5174 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5175 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5176
5177 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5178 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5179 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005180 {
5181 /* Issue disconnect to CSR */
5182 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305183 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5185 pAdapter->sessionId,
5186 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5187 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005188 ret = wait_for_completion_interruptible_timeout(
5189 &pAdapter->disconnect_comp_var,
5190 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5191 if (0 == ret)
5192 {
5193 VOS_ASSERT(0);
5194 }
5195 }
5196 }
5197 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5198 {
5199 ret = wait_for_completion_interruptible_timeout(
5200 &pAdapter->disconnect_comp_var,
5201 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5202 if (0 == ret)
5203 {
5204 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 }
5206 }
5207
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305208 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005209 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5210 {
5211 /*QoS not enabled in cfg file*/
5212 pRoamProfile->uapsd_mask = 0;
5213 }
5214 else
5215 {
5216 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305217 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005218 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5219 }
5220
5221 pRoamProfile->SSIDs.numOfSSIDs = 1;
5222 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5223 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305224 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005225 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5226 ssid, ssid_len);
5227
5228 if (bssid)
5229 {
5230 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5231 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5232 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305233 /* Save BSSID in seperate variable as well, as RoamProfile
5234 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 case of join failure we should send valid BSSID to supplicant
5236 */
5237 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5238 WNI_CFG_BSSID_LEN);
5239 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005240 else
5241 {
5242 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5243 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005244
5245 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5246 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305247 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 /*set gen ie*/
5249 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5250 /*set auth*/
5251 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005253#ifdef FEATURE_WLAN_WAPI
5254 if (pAdapter->wapi_info.nWapiMode)
5255 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005256 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005257 switch (pAdapter->wapi_info.wapiAuthMode)
5258 {
5259 case WAPI_AUTH_MODE_PSK:
5260 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005261 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 pAdapter->wapi_info.wapiAuthMode);
5263 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5264 break;
5265 }
5266 case WAPI_AUTH_MODE_CERT:
5267 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005268 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 pAdapter->wapi_info.wapiAuthMode);
5270 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5271 break;
5272 }
5273 } // End of switch
5274 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5275 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5276 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005277 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 pRoamProfile->AuthType.numEntries = 1;
5279 pRoamProfile->EncryptionType.numEntries = 1;
5280 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5281 pRoamProfile->mcEncryptionType.numEntries = 1;
5282 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5283 }
5284 }
5285#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305286#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305287 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305288 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5289 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5290 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305291 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5292 sizeof (tSirGtkOffloadParams));
5293 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305294 }
5295#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 pRoamProfile->csrPersona = pAdapter->device_mode;
5297
Jeff Johnson32d95a32012-09-10 13:15:23 -07005298 if( operatingChannel )
5299 {
5300 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5301 pRoamProfile->ChannelInfo.numOfChannels = 1;
5302 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005303 else
5304 {
5305 pRoamProfile->ChannelInfo.ChannelList = NULL;
5306 pRoamProfile->ChannelInfo.numOfChannels = 0;
5307 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005308 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5309 {
5310 hdd_select_cbmode(pAdapter,operatingChannel);
5311 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005312 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5313 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305314 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005315 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005316 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5317 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305318 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5319 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005320 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5321 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305322
5323 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 pAdapter->sessionId, pRoamProfile, &roamId);
5325
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305326 if ((eHAL_STATUS_SUCCESS != status) &&
5327 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5328 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305329
5330 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005331 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5332 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5333 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305334 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005335 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305336 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005337
5338 pRoamProfile->ChannelInfo.ChannelList = NULL;
5339 pRoamProfile->ChannelInfo.numOfChannels = 0;
5340
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 }
5342 else
5343 {
5344 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5345 return -EINVAL;
5346 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005347 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 return status;
5349}
5350
5351/*
5352 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5353 * This function is used to set the authentication type (OPEN/SHARED).
5354 *
5355 */
5356static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5357 enum nl80211_auth_type auth_type)
5358{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305359 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5361
5362 ENTER();
5363
5364 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305365 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005366 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305368 hddLog(VOS_TRACE_LEVEL_INFO,
5369 "%s: set authentication type to AUTOSWITCH", __func__);
5370 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5371 break;
5372
5373 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005374#ifdef WLAN_FEATURE_VOWIFI_11R
5375 case NL80211_AUTHTYPE_FT:
5376#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305377 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 "%s: set authentication type to OPEN", __func__);
5379 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5380 break;
5381
5382 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305383 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005384 "%s: set authentication type to SHARED", __func__);
5385 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5386 break;
5387#ifdef FEATURE_WLAN_CCX
5388 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305389 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005390 "%s: set authentication type to CCKM WPA", __func__);
5391 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5392 break;
5393#endif
5394
5395
5396 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305397 hddLog(VOS_TRACE_LEVEL_ERROR,
5398 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 auth_type);
5400 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5401 return -EINVAL;
5402 }
5403
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305404 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 pHddStaCtx->conn_info.authType;
5406 return 0;
5407}
5408
5409/*
5410 * FUNCTION: wlan_hdd_set_akm_suite
5411 * This function is used to set the key mgmt type(PSK/8021x).
5412 *
5413 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305414static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 u32 key_mgmt
5416 )
5417{
5418 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5419 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305420
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 /*set key mgmt type*/
5422 switch(key_mgmt)
5423 {
5424 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305425#ifdef WLAN_FEATURE_VOWIFI_11R
5426 case WLAN_AKM_SUITE_FT_PSK:
5427#endif
5428 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005429 __func__);
5430 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5431 break;
5432
5433 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305434#ifdef WLAN_FEATURE_VOWIFI_11R
5435 case WLAN_AKM_SUITE_FT_8021X:
5436#endif
5437 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 __func__);
5439 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5440 break;
5441#ifdef FEATURE_WLAN_CCX
5442#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5443#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5444 case WLAN_AKM_SUITE_CCKM:
5445 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5446 __func__);
5447 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5448 break;
5449#endif
5450
5451 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305452 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 __func__, key_mgmt);
5454 return -EINVAL;
5455
5456 }
5457 return 0;
5458}
5459
5460/*
5461 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305462 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 * (NONE/WEP40/WEP104/TKIP/CCMP).
5464 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305465static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5466 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005467 bool ucast
5468 )
5469{
5470 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305471 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005472 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5473
5474 ENTER();
5475
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305476 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305478 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005479 __func__, cipher);
5480 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5481 }
5482 else
5483 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305484
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305486 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 {
5488 case IW_AUTH_CIPHER_NONE:
5489 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5490 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305491
Jeff Johnson295189b2012-06-20 16:38:30 -07005492 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305493 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005494 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305495
Jeff Johnson295189b2012-06-20 16:38:30 -07005496 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305497 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005498 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305499
Jeff Johnson295189b2012-06-20 16:38:30 -07005500 case WLAN_CIPHER_SUITE_TKIP:
5501 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5502 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 case WLAN_CIPHER_SUITE_CCMP:
5505 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5506 break;
5507#ifdef FEATURE_WLAN_WAPI
5508 case WLAN_CIPHER_SUITE_SMS4:
5509 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5510 break;
5511#endif
5512
5513#ifdef FEATURE_WLAN_CCX
5514 case WLAN_CIPHER_SUITE_KRK:
5515 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5516 break;
5517#endif
5518 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 __func__, cipher);
5521 return -EOPNOTSUPP;
5522 }
5523 }
5524
5525 if (ucast)
5526 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305527 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 __func__, encryptionType);
5529 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5530 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305531 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 encryptionType;
5533 }
5534 else
5535 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305536 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005537 __func__, encryptionType);
5538 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5539 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5540 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5541 }
5542
5543 return 0;
5544}
5545
5546
5547/*
5548 * FUNCTION: wlan_hdd_cfg80211_set_ie
5549 * This function is used to parse WPA/RSN IE's.
5550 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305551int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5552 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 size_t ie_len
5554 )
5555{
5556 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5557 u8 *genie = ie;
5558 v_U16_t remLen = ie_len;
5559#ifdef FEATURE_WLAN_WAPI
5560 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5561 u16 *tmp;
5562 v_U16_t akmsuiteCount;
5563 int *akmlist;
5564#endif
5565 ENTER();
5566
5567 /* clear previous assocAddIE */
5568 pWextState->assocAddIE.length = 0;
5569 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5570
5571 while (remLen >= 2)
5572 {
5573 v_U16_t eLen = 0;
5574 v_U8_t elementId;
5575 elementId = *genie++;
5576 eLen = *genie++;
5577 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305578
5579 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005580 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305581
5582 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305584 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005585 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 -07005586 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305587 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 "%s: Invalid WPA IE", __func__);
5589 return -EINVAL;
5590 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305591 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 {
5593 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305594 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005595 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305596
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5598 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005599 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5600 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 VOS_ASSERT(0);
5602 return -ENOMEM;
5603 }
5604 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5605 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5606 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305607
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5609 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5610 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5611 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305612 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5613 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005614 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5615 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5616 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5617 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5618 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5619 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305620 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05305621 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 {
5623 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305624 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305626
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5628 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005629 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5630 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 VOS_ASSERT(0);
5632 return -ENOMEM;
5633 }
5634 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5635 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5636 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305637
Jeff Johnson295189b2012-06-20 16:38:30 -07005638 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5639 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005641#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305642 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5643 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 /*Consider WFD IE, only for P2P Client */
5645 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5646 {
5647 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305648 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305650
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5652 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005653 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5654 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 VOS_ASSERT(0);
5656 return -ENOMEM;
5657 }
5658 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5659 // WPS IE + P2P IE + WFD IE
5660 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5661 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305662
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5664 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5665 }
5666#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005667 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305668 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005669 HS20_OUI_TYPE_SIZE)) )
5670 {
5671 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305672 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005673 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005674
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005675 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5676 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005677 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5678 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005679 VOS_ASSERT(0);
5680 return -ENOMEM;
5681 }
5682 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5683 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005684
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005685 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5686 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5687 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005688
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005689 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5690
5691 /* populating as ADDIE in beacon frames */
5692 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5693 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5694 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5695 {
5696 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5697 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5698 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5699 {
5700 hddLog(LOGE,
5701 "Coldn't pass "
5702 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5703 }
5704 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5705 else
5706 hddLog(LOGE,
5707 "Could not pass on "
5708 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5709
5710 /* IBSS mode doesn't contain params->proberesp_ies still
5711 beaconIE's need to be populated in probe response frames */
5712 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5713 {
5714 u16 rem_probe_resp_ie_len = eLen + 2;
5715 u8 probe_rsp_ie_len[3] = {0};
5716 u8 counter = 0;
5717
5718 /* Check Probe Resp Length if it is greater then 255 then
5719 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5720 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5721 not able Store More then 255 bytes into One Variable */
5722
5723 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5724 {
5725 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5726 {
5727 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5728 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5729 }
5730 else
5731 {
5732 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5733 rem_probe_resp_ie_len = 0;
5734 }
5735 }
5736
5737 rem_probe_resp_ie_len = 0;
5738
5739 if (probe_rsp_ie_len[0] > 0)
5740 {
5741 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5742 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5743 (tANI_U8*)(genie - 2),
5744 probe_rsp_ie_len[0], NULL,
5745 eANI_BOOLEAN_FALSE)
5746 == eHAL_STATUS_FAILURE)
5747 {
5748 hddLog(LOGE,
5749 "Could not pass"
5750 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5751 }
5752 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5753 }
5754
5755 if (probe_rsp_ie_len[1] > 0)
5756 {
5757 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5758 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5759 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5760 probe_rsp_ie_len[1], NULL,
5761 eANI_BOOLEAN_FALSE)
5762 == eHAL_STATUS_FAILURE)
5763 {
5764 hddLog(LOGE,
5765 "Could not pass"
5766 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5767 }
5768 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5769 }
5770
5771 if (probe_rsp_ie_len[2] > 0)
5772 {
5773 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5774 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5775 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5776 probe_rsp_ie_len[2], NULL,
5777 eANI_BOOLEAN_FALSE)
5778 == eHAL_STATUS_FAILURE)
5779 {
5780 hddLog(LOGE,
5781 "Could not pass"
5782 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5783 }
5784 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5785 }
5786
5787 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5788 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5789 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5790 {
5791 hddLog(LOGE,
5792 "Could not pass"
5793 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5794 }
5795 }
5796 else
5797 {
5798 // Reset WNI_CFG_PROBE_RSP Flags
5799 wlan_hdd_reset_prob_rspies(pAdapter);
5800
5801 hddLog(VOS_TRACE_LEVEL_INFO,
5802 "%s: No Probe Response IE received in set beacon",
5803 __func__);
5804 }
5805 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 break;
5807 case DOT11F_EID_RSN:
5808 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5809 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5810 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5811 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5812 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5813 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005814 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5815 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305816 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005817 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305818 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005819 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305820
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005821 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5822 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005823 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5824 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005825 VOS_ASSERT(0);
5826 return -ENOMEM;
5827 }
5828 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5829 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305830
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005831 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5832 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5833 break;
5834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005835#ifdef FEATURE_WLAN_WAPI
5836 case WLAN_EID_WAPI:
5837 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005838 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 pAdapter->wapi_info.nWapiMode);
5840 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305841 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005842 akmsuiteCount = WPA_GET_LE16(tmp);
5843 tmp = tmp + 1;
5844 akmlist = (int *)(tmp);
5845 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5846 {
5847 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5848 }
5849 else
5850 {
5851 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5852 VOS_ASSERT(0);
5853 return -EINVAL;
5854 }
5855
5856 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5857 {
5858 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005859 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305863 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005865 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005866 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5867 }
5868 break;
5869#endif
5870 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305871 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005873 /* when Unknown IE is received we should break and continue
5874 * to the next IE in the buffer instead we were returning
5875 * so changing this to break */
5876 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 }
5878 genie += eLen;
5879 remLen -= eLen;
5880 }
5881 EXIT();
5882 return 0;
5883}
5884
5885/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305886 * FUNCTION: hdd_isWPAIEPresent
5887 * Parse the received IE to find the WPA IE
5888 *
5889 */
5890static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5891{
5892 v_U8_t eLen = 0;
5893 v_U16_t remLen = ie_len;
5894 v_U8_t elementId = 0;
5895
5896 while (remLen >= 2)
5897 {
5898 elementId = *ie++;
5899 eLen = *ie++;
5900 remLen -= 2;
5901 if (eLen > remLen)
5902 {
5903 hddLog(VOS_TRACE_LEVEL_ERROR,
5904 "%s: IE length is wrong %d", __func__, eLen);
5905 return FALSE;
5906 }
5907 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5908 {
5909 /* OUI - 0x00 0X50 0XF2
5910 WPA Information Element - 0x01
5911 WPA version - 0x01*/
5912 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5913 return TRUE;
5914 }
5915 ie += eLen;
5916 remLen -= eLen;
5917 }
5918 return FALSE;
5919}
5920
5921/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305923 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005924 * parameters during connect operation.
5925 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305926int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 struct cfg80211_connect_params *req
5928 )
5929{
5930 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305931 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 ENTER();
5933
5934 /*set wpa version*/
5935 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5936
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305937 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305939 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005940 {
5941 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5942 }
5943 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5944 {
5945 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5946 }
5947 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305948
5949 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 pWextState->wpaVersion);
5951
5952 /*set authentication type*/
5953 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5954
5955 if (0 > status)
5956 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305957 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005958 "%s: failed to set authentication type ", __func__);
5959 return status;
5960 }
5961
5962 /*set key mgmt type*/
5963 if (req->crypto.n_akm_suites)
5964 {
5965 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5966 if (0 > status)
5967 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305968 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 __func__);
5970 return status;
5971 }
5972 }
5973
5974 /*set pairwise cipher type*/
5975 if (req->crypto.n_ciphers_pairwise)
5976 {
5977 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5978 req->crypto.ciphers_pairwise[0], true);
5979 if (0 > status)
5980 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305981 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 "%s: failed to set unicast cipher type", __func__);
5983 return status;
5984 }
5985 }
5986 else
5987 {
5988 /*Reset previous cipher suite to none*/
5989 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
5990 if (0 > status)
5991 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305992 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005993 "%s: failed to set unicast cipher type", __func__);
5994 return status;
5995 }
5996 }
5997
5998 /*set group cipher type*/
5999 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6000 false);
6001
6002 if (0 > status)
6003 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306004 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 __func__);
6006 return status;
6007 }
6008
Chet Lanctot186b5732013-03-18 10:26:30 -07006009#ifdef WLAN_FEATURE_11W
6010 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6011#endif
6012
Jeff Johnson295189b2012-06-20 16:38:30 -07006013 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6014 if (req->ie_len)
6015 {
6016 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6017 if ( 0 > status)
6018 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306019 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006020 __func__);
6021 return status;
6022 }
6023 }
6024
6025 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306026 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 {
6028 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6029 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6030 )
6031 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306032 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006033 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6034 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306035 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 __func__);
6037 return -EOPNOTSUPP;
6038 }
6039 else
6040 {
6041 u8 key_len = req->key_len;
6042 u8 key_idx = req->key_idx;
6043
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306044 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006045 && (CSR_MAX_NUM_KEY > key_idx)
6046 )
6047 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306048 hddLog(VOS_TRACE_LEVEL_INFO,
6049 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 __func__, key_idx, key_len);
6051 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306052 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306054 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 (u8)key_len;
6056 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6057 }
6058 }
6059 }
6060 }
6061
6062 return status;
6063}
6064
6065/*
6066 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306067 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 * parameters during connect operation.
6069 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306070static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 struct net_device *ndev,
6072 struct cfg80211_connect_params *req
6073 )
6074{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306075 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306076 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
6078 hdd_context_t *pHddCtx = NULL;
6079
6080 ENTER();
6081
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306082 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6084
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306085 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6086 status = wlan_hdd_validate_context(pHddCtx);
6087
6088 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306090 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6091 "%s: HDD context is not valid", __func__);
6092 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 }
6094
6095#ifdef WLAN_BTAMP_FEATURE
6096 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306097 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306099 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006101 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 }
6103#endif
6104 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306105 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006106
6107 if ( 0 > status)
6108 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306109 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 __func__);
6111 return status;
6112 }
6113
6114 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006115 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6117 (vos_concurrent_sessions_running()))
6118 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306119 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 }
6121
Mohit Khanna765234a2012-09-11 15:08:35 -07006122 if ( req->channel )
6123 {
6124 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6125 req->ssid_len, req->bssid,
6126 req->channel->hw_value);
6127 }
6128 else
6129 {
6130 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306131 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006133
6134 if (0 > status)
6135 {
6136 //ReEnable BMPS if disabled
6137 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6138 (NULL != pHddCtx))
6139 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306140 if (pHddCtx->hdd_wlan_suspended)
6141 {
6142 hdd_set_pwrparams(pHddCtx);
6143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 //ReEnable Bmps and Imps back
6145 hdd_enable_bmps_imps(pHddCtx);
6146 }
6147
6148 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6149 return status;
6150 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306151 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006152 EXIT();
6153 return status;
6154}
6155
6156
6157/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306158 * FUNCTION: wlan_hdd_disconnect
6159 * This function is used to issue a disconnect request to SME
6160 */
6161int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6162{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306163 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306164 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306165 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6166
6167 status = wlan_hdd_validate_context(pHddCtx);
6168
6169 if (0 != status)
6170 {
6171 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6172 "%s: HDD context is not valid", __func__);
6173 return status;
6174 }
6175
6176 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306177 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306178 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306179
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306180 /*issue disconnect*/
6181 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6182 pAdapter->sessionId, reason);
6183
6184 if ( 0 != status )
6185 {
6186 hddLog(VOS_TRACE_LEVEL_ERROR,
6187 "%s csrRoamDisconnect failure, returned %d \n",
6188 __func__, (int)status );
6189 return -EINVAL;
6190 }
6191 wait_for_completion_interruptible_timeout(
6192 &pAdapter->disconnect_comp_var,
6193 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6194 /*stop tx queues*/
6195 netif_tx_disable(pAdapter->dev);
6196 netif_carrier_off(pAdapter->dev);
6197 return status;
6198}
6199
6200
6201/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006202 * FUNCTION: wlan_hdd_cfg80211_disconnect
6203 * This function is used to issue a disconnect request to SME
6204 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306205static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 struct net_device *dev,
6207 u16 reason
6208 )
6209{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306210 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6211 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306213 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006215 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306216#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006217 tANI_U8 staIdx;
6218#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306219
Jeff Johnson295189b2012-06-20 16:38:30 -07006220 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306221
6222 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 __func__,pAdapter->device_mode);
6224
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306225 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6226 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006227
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306228 status = wlan_hdd_validate_context(pHddCtx);
6229
6230 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6233 "%s: HDD context is not valid", __func__);
6234 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306236
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 if (NULL != pRoamProfile)
6238 {
6239 /*issue disconnect request to SME, if station is in connected state*/
6240 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6241 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306242 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306244 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 switch(reason)
6246 {
6247 case WLAN_REASON_MIC_FAILURE:
6248 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6249 break;
6250
6251 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6252 case WLAN_REASON_DISASSOC_AP_BUSY:
6253 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6254 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6255 break;
6256
6257 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6258 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6259 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6260 break;
6261
6262 case WLAN_REASON_DEAUTH_LEAVING:
6263 default:
6264 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6265 break;
6266 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306267 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6268 pScanInfo = &pHddCtx->scan_info;
6269 if (pScanInfo->mScanPending)
6270 {
6271 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6272 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306273 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006275
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006276#ifdef FEATURE_WLAN_TDLS
6277 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006278 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006279 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006280 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6281 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006282 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006283 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006284 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006285 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006286 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006287 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006288 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006289 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006290 pAdapter->sessionId,
6291 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006292 }
6293 }
6294#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306295 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6296 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 {
6298 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306299 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 __func__, (int)status );
6301 return -EINVAL;
6302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006303 }
6304 }
6305 else
6306 {
6307 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6308 }
6309
6310 return status;
6311}
6312
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306313
Jeff Johnson295189b2012-06-20 16:38:30 -07006314/*
6315 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306316 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006317 * settings in IBSS mode.
6318 */
6319static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306320 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006321 struct cfg80211_ibss_params *params
6322 )
6323{
6324 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306325 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6327 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306328
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 ENTER();
6330
6331 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006332 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006333
6334 if (params->ie_len && ( NULL != params->ie) )
6335 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006336 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6337 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 {
6339 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6340 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6341 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006342 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006344 tDot11fIEWPA dot11WPAIE;
6345 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006346 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006347
Wilson Yang00256342013-10-10 23:13:38 -07006348 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006349 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6350 params->ie_len, DOT11F_EID_WPA);
6351 if ( NULL != ie )
6352 {
6353 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6354 // Unpack the WPA IE
6355 //Skip past the EID byte and length byte - and four byte WiFi OUI
6356 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6357 &ie[2+4],
6358 ie[1] - 4,
6359 &dot11WPAIE);
6360 /*Extract the multicast cipher, the encType for unicast
6361 cipher for wpa-none is none*/
6362 encryptionType =
6363 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006366
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6368
6369 if (0 > status)
6370 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306371 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 __func__);
6373 return status;
6374 }
6375 }
6376
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306377 pWextState->roamProfile.AuthType.authType[0] =
6378 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006379 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6380
6381 if (params->privacy)
6382 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306383 /* Security enabled IBSS, At this time there is no information available
6384 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006385 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306386 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306388 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 *enable privacy bit in beacons */
6390
6391 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6392 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006393 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6394 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6396 pWextState->roamProfile.EncryptionType.numEntries = 1;
6397 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 return status;
6399}
6400
6401/*
6402 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306403 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306405static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006406 struct net_device *dev,
6407 struct cfg80211_ibss_params *params
6408 )
6409{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306410 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6412 tCsrRoamProfile *pRoamProfile;
6413 int status;
krunal sonie9002db2013-11-25 14:24:17 -08006414 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006415 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306416 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006417
6418 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306419
6420 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6422
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306423 status = wlan_hdd_validate_context(pHddCtx);
6424
6425 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006426 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6428 "%s: HDD context is not valid", __func__);
6429 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006430 }
6431
6432 if (NULL == pWextState)
6433 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306434 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 __func__);
6436 return -EIO;
6437 }
6438
6439 pRoamProfile = &pWextState->roamProfile;
6440
6441 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6442 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306443 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006444 "%s Interface type is not set to IBSS \n", __func__);
6445 return -EINVAL;
6446 }
6447
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006448 /* BSSID is provided by upper layers hence no need to AUTO generate */
6449 if (NULL != params->bssid) {
6450 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6451 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
6452 hddLog (VOS_TRACE_LEVEL_ERROR,
6453 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6454 return -EIO;
6455 }
6456 }
krunal sonie9002db2013-11-25 14:24:17 -08006457 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
6458 {
6459 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6460 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6461 {
6462 hddLog (VOS_TRACE_LEVEL_ERROR,
6463 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6464 return -EIO;
6465 }
6466 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
6467 if (!params->bssid)
6468 {
6469 hddLog (VOS_TRACE_LEVEL_ERROR,
6470 "%s:Failed memory allocation", __func__);
6471 return -EIO;
6472 }
6473 vos_mem_copy((v_U8_t *)params->bssid,
6474 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
6475 VOS_MAC_ADDR_SIZE);
6476 alloc_bssid = VOS_TRUE;
6477 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006478
Jeff Johnson295189b2012-06-20 16:38:30 -07006479 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006480 if (NULL !=
6481#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6482 params->chandef.chan)
6483#else
6484 params->channel)
6485#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 {
6487 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006488 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6489 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6490 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6491 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006492
6493 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306494 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006495 ieee80211_frequency_to_channel(
6496#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6497 params->chandef.chan->center_freq);
6498#else
6499 params->channel->center_freq);
6500#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006501
6502 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6503 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006504 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006505 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6506 __func__);
6507 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006509
6510 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006512 if (channelNum == validChan[indx])
6513 {
6514 break;
6515 }
6516 }
6517 if (indx >= numChans)
6518 {
6519 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 __func__, channelNum);
6521 return -EINVAL;
6522 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006523 /* Set the Operational Channel */
6524 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6525 channelNum);
6526 pRoamProfile->ChannelInfo.numOfChannels = 1;
6527 pHddStaCtx->conn_info.operationChannel = channelNum;
6528 pRoamProfile->ChannelInfo.ChannelList =
6529 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 }
6531
6532 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306533 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006534 if (status < 0)
6535 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306536 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 __func__);
6538 return status;
6539 }
6540
6541 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306542 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006543 params->ssid_len, params->bssid,
6544 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006545
6546 if (0 > status)
6547 {
6548 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6549 return status;
6550 }
6551
krunal sonie9002db2013-11-25 14:24:17 -08006552 if (NULL != params->bssid &&
6553 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
6554 alloc_bssid == VOS_TRUE)
6555 {
6556 vos_mem_free(params->bssid);
6557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006558 return 0;
6559}
6560
6561/*
6562 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306563 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306565static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006566 struct net_device *dev
6567 )
6568{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306569 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006570 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6571 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306572 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6573 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006574
6575 ENTER();
6576
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306577 status = wlan_hdd_validate_context(pHddCtx);
6578
6579 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006580 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306581 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6582 "%s: HDD context is not valid", __func__);
6583 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006584 }
6585
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6587 if (NULL == pWextState)
6588 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306589 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006590 __func__);
6591 return -EIO;
6592 }
6593
6594 pRoamProfile = &pWextState->roamProfile;
6595
6596 /* Issue disconnect only if interface type is set to IBSS */
6597 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306599 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 __func__);
6601 return -EINVAL;
6602 }
6603
6604 /* Issue Disconnect request */
6605 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6606 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6607 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6608
6609 return 0;
6610}
6611
6612/*
6613 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6614 * This function is used to set the phy parameters
6615 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6616 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306617static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 u32 changed)
6619{
6620 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6621 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306622 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006623
6624 ENTER();
6625
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306626 status = wlan_hdd_validate_context(pHddCtx);
6627
6628 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006629 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6631 "%s: HDD context is not valid", __func__);
6632 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006633 }
6634
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6636 {
6637 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6638 WNI_CFG_RTS_THRESHOLD_STAMAX :
6639 wiphy->rts_threshold;
6640
6641 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306642 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306644 hddLog(VOS_TRACE_LEVEL_ERROR,
6645 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006646 __func__, rts_threshold);
6647 return -EINVAL;
6648 }
6649
6650 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6651 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306652 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306654 hddLog(VOS_TRACE_LEVEL_ERROR,
6655 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 __func__, rts_threshold);
6657 return -EIO;
6658 }
6659
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306660 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 rts_threshold);
6662 }
6663
6664 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6665 {
6666 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6667 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6668 wiphy->frag_threshold;
6669
6670 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306671 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006672 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306673 hddLog(VOS_TRACE_LEVEL_ERROR,
6674 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006675 frag_threshold);
6676 return -EINVAL;
6677 }
6678
6679 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6680 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306681 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306683 hddLog(VOS_TRACE_LEVEL_ERROR,
6684 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 __func__, frag_threshold);
6686 return -EIO;
6687 }
6688
6689 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6690 frag_threshold);
6691 }
6692
6693 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6694 || (changed & WIPHY_PARAM_RETRY_LONG))
6695 {
6696 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6697 wiphy->retry_short :
6698 wiphy->retry_long;
6699
6700 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6701 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6702 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306703 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 __func__, retry_value);
6705 return -EINVAL;
6706 }
6707
6708 if (changed & WIPHY_PARAM_RETRY_SHORT)
6709 {
6710 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6711 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306712 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306714 hddLog(VOS_TRACE_LEVEL_ERROR,
6715 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 __func__, retry_value);
6717 return -EIO;
6718 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306719 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006720 __func__, retry_value);
6721 }
6722 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6723 {
6724 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6725 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306726 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306728 hddLog(VOS_TRACE_LEVEL_ERROR,
6729 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 __func__, retry_value);
6731 return -EIO;
6732 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306733 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 __func__, retry_value);
6735 }
6736 }
6737
6738 return 0;
6739}
6740
6741/*
6742 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6743 * This function is used to set the txpower
6744 */
6745static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006746#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6747 struct wireless_dev *wdev,
6748#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006749#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306750 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006751#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306752 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006753#endif
6754 int dbm)
6755{
6756 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306757 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006758 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6759 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306760 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006761
6762 ENTER();
6763
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306764 status = wlan_hdd_validate_context(pHddCtx);
6765
6766 if (0 != status)
6767 {
6768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6769 "%s: HDD context is not valid", __func__);
6770 return status;
6771 }
6772
6773 hHal = pHddCtx->hHal;
6774
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306775 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6776 dbm, ccmCfgSetCallback,
6777 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006778 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306779 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006780 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6781 return -EIO;
6782 }
6783
6784 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6785 dbm);
6786
6787 switch(type)
6788 {
6789 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6790 /* Fall through */
6791 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6792 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6793 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306794 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6795 __func__);
6796 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006797 }
6798 break;
6799 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306800 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 __func__);
6802 return -EOPNOTSUPP;
6803 break;
6804 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306805 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6806 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 return -EIO;
6808 }
6809
6810 return 0;
6811}
6812
6813/*
6814 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6815 * This function is used to read the txpower
6816 */
Yue Maf49ba872013-08-19 12:04:25 -07006817static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6818#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6819 struct wireless_dev *wdev,
6820#endif
6821 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006822{
6823
6824 hdd_adapter_t *pAdapter;
6825 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306826 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006827
Jeff Johnsone7245742012-09-05 17:12:55 -07006828 ENTER();
6829
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306830 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006831
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306832 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006833 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6835 "%s: HDD context is not valid", __func__);
6836 *dbm = 0;
6837 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006838 }
6839
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6841 if (NULL == pAdapter)
6842 {
6843 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6844 return -ENOENT;
6845 }
6846
6847 wlan_hdd_get_classAstats(pAdapter);
6848 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6849
Jeff Johnsone7245742012-09-05 17:12:55 -07006850 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 return 0;
6852}
6853
6854static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6855 u8* mac, struct station_info *sinfo)
6856{
6857 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6858 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6859 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6860 tANI_U8 rate_flags;
6861
6862 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6863 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006864
6865 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6866 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6867 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6868 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6869 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6870 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6871 tANI_U16 maxRate = 0;
6872 tANI_U16 myRate;
6873 tANI_U16 currentRate = 0;
6874 tANI_U8 maxSpeedMCS = 0;
6875 tANI_U8 maxMCSIdx = 0;
6876 tANI_U8 rateFlag = 1;
6877 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006878 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306879 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006880
Leo Chang6f8870f2013-03-26 18:11:36 -07006881#ifdef WLAN_FEATURE_11AC
6882 tANI_U32 vht_mcs_map;
6883 eDataRate11ACMaxMcs vhtMaxMcs;
6884#endif /* WLAN_FEATURE_11AC */
6885
Jeff Johnsone7245742012-09-05 17:12:55 -07006886 ENTER();
6887
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6889 (0 == ssidlen))
6890 {
6891 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6892 " Invalid ssidlen, %d", __func__, ssidlen);
6893 /*To keep GUI happy*/
6894 return 0;
6895 }
6896
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306897 status = wlan_hdd_validate_context(pHddCtx);
6898
6899 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006900 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306901 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6902 "%s: HDD context is not valid", __func__);
6903 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006904 }
6905
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006906 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006907 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6908
Kiet Lam3b17fc82013-09-27 05:24:08 +05306909 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6910 sinfo->filled |= STATION_INFO_SIGNAL;
6911
Jeff Johnson295189b2012-06-20 16:38:30 -07006912 //convert to the UI units of 100kbps
6913 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6914
6915#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006916 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 -07006917 sinfo->signal,
6918 pCfg->reportMaxLinkSpeed,
6919 myRate,
6920 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006921 (int) pCfg->linkSpeedRssiMid,
6922 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006923 (int) rate_flags,
6924 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006925#endif //LINKSPEED_DEBUG_ENABLED
6926
6927 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6928 {
6929 // we do not want to necessarily report the current speed
6930 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6931 {
6932 // report the max possible speed
6933 rssidx = 0;
6934 }
6935 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6936 {
6937 // report the max possible speed with RSSI scaling
6938 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6939 {
6940 // report the max possible speed
6941 rssidx = 0;
6942 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006943 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006944 {
6945 // report middle speed
6946 rssidx = 1;
6947 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006948 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6949 {
6950 // report middle speed
6951 rssidx = 2;
6952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006953 else
6954 {
6955 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006956 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 }
6958 }
6959 else
6960 {
6961 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6962 hddLog(VOS_TRACE_LEVEL_ERROR,
6963 "%s: Invalid value for reportMaxLinkSpeed: %u",
6964 __func__, pCfg->reportMaxLinkSpeed);
6965 rssidx = 0;
6966 }
6967
6968 maxRate = 0;
6969
6970 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306971 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6972 OperationalRates, &ORLeng))
6973 {
6974 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6975 /*To keep GUI happy*/
6976 return 0;
6977 }
6978
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 for (i = 0; i < ORLeng; i++)
6980 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006981 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006982 {
6983 /* Validate Rate Set */
6984 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6985 {
6986 currentRate = supported_data_rate[j].supported_rate[rssidx];
6987 break;
6988 }
6989 }
6990 /* Update MAX rate */
6991 maxRate = (currentRate > maxRate)?currentRate:maxRate;
6992 }
6993
6994 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306995 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
6996 ExtendedRates, &ERLeng))
6997 {
6998 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6999 /*To keep GUI happy*/
7000 return 0;
7001 }
7002
Jeff Johnson295189b2012-06-20 16:38:30 -07007003 for (i = 0; i < ERLeng; i++)
7004 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007005 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 {
7007 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7008 {
7009 currentRate = supported_data_rate[j].supported_rate[rssidx];
7010 break;
7011 }
7012 }
7013 /* Update MAX rate */
7014 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7015 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307016 /* Get MCS Rate Set --
7017 only if we are connected at MCS rates (or)
7018 if we are always reporting max speed (or)
7019 if we have good rssi */
7020 if (((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) ||
7021 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307023 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7024 MCSRates, &MCSLeng))
7025 {
7026 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7027 /*To keep GUI happy*/
7028 return 0;
7029 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007030 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007031#ifdef WLAN_FEATURE_11AC
7032 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307033 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007034 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007035 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307036 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007037 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007039 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007041 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007043 maxMCSIdx = 7;
7044 }
7045 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7046 {
7047 maxMCSIdx = 8;
7048 }
7049 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7050 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307051 //VHT20 is supporting 0~8
7052 if (rate_flags & eHAL_TX_RATE_VHT20)
7053 maxMCSIdx = 8;
7054 else
7055 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007056 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307057
7058 if (rate_flags & eHAL_TX_RATE_VHT80)
7059 {
7060 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7061 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7062 }
7063 else if (rate_flags & eHAL_TX_RATE_VHT40)
7064 {
7065 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7066 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7067 }
7068 else if (rate_flags & eHAL_TX_RATE_VHT20)
7069 {
7070 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7071 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7072 }
7073
Leo Chang6f8870f2013-03-26 18:11:36 -07007074 maxSpeedMCS = 1;
7075 if (currentRate > maxRate)
7076 {
7077 maxRate = currentRate;
7078 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307079
Leo Chang6f8870f2013-03-26 18:11:36 -07007080 }
7081 else
7082#endif /* WLAN_FEATURE_11AC */
7083 {
7084 if (rate_flags & eHAL_TX_RATE_HT40)
7085 {
7086 rateFlag |= 1;
7087 }
7088 if (rate_flags & eHAL_TX_RATE_SGI)
7089 {
7090 rateFlag |= 2;
7091 }
7092
7093 for (i = 0; i < MCSLeng; i++)
7094 {
7095 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7096 for (j = 0; j < temp; j++)
7097 {
7098 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7099 {
7100 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7101 break;
7102 }
7103 }
7104 if ((j < temp) && (currentRate > maxRate))
7105 {
7106 maxRate = currentRate;
7107 maxSpeedMCS = 1;
7108 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7109 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007110 }
7111 }
7112 }
7113
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307114 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7115 {
7116 maxRate = myRate;
7117 maxSpeedMCS = 1;
7118 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7119 }
7120
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007122 if (((maxRate < myRate) && (0 == rssidx)) ||
7123 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 {
7125 maxRate = myRate;
7126 if (rate_flags & eHAL_TX_RATE_LEGACY)
7127 {
7128 maxSpeedMCS = 0;
7129 }
7130 else
7131 {
7132 maxSpeedMCS = 1;
7133 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7134 }
7135 }
7136
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307137 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007138 {
7139 sinfo->txrate.legacy = maxRate;
7140#ifdef LINKSPEED_DEBUG_ENABLED
7141 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7142#endif //LINKSPEED_DEBUG_ENABLED
7143 }
7144 else
7145 {
7146 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007147#ifdef WLAN_FEATURE_11AC
7148 sinfo->txrate.nss = 1;
7149 if (rate_flags & eHAL_TX_RATE_VHT80)
7150 {
7151 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307152 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007153 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307154 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007155 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307156 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7157 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7158 }
7159 else if (rate_flags & eHAL_TX_RATE_VHT20)
7160 {
7161 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7162 }
7163#endif /* WLAN_FEATURE_11AC */
7164 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7165 {
7166 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7167 if (rate_flags & eHAL_TX_RATE_HT40)
7168 {
7169 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7170 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 if (rate_flags & eHAL_TX_RATE_SGI)
7173 {
7174 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7175 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307176
Jeff Johnson295189b2012-06-20 16:38:30 -07007177#ifdef LINKSPEED_DEBUG_ENABLED
7178 pr_info("Reporting MCS rate %d flags %x\n",
7179 sinfo->txrate.mcs,
7180 sinfo->txrate.flags );
7181#endif //LINKSPEED_DEBUG_ENABLED
7182 }
7183 }
7184 else
7185 {
7186 // report current rate instead of max rate
7187
7188 if (rate_flags & eHAL_TX_RATE_LEGACY)
7189 {
7190 //provide to the UI in units of 100kbps
7191 sinfo->txrate.legacy = myRate;
7192#ifdef LINKSPEED_DEBUG_ENABLED
7193 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7194#endif //LINKSPEED_DEBUG_ENABLED
7195 }
7196 else
7197 {
7198 //must be MCS
7199 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007200#ifdef WLAN_FEATURE_11AC
7201 sinfo->txrate.nss = 1;
7202 if (rate_flags & eHAL_TX_RATE_VHT80)
7203 {
7204 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7205 }
7206 else
7207#endif /* WLAN_FEATURE_11AC */
7208 {
7209 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 if (rate_flags & eHAL_TX_RATE_SGI)
7212 {
7213 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7214 }
7215 if (rate_flags & eHAL_TX_RATE_HT40)
7216 {
7217 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7218 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007219#ifdef WLAN_FEATURE_11AC
7220 else if (rate_flags & eHAL_TX_RATE_VHT80)
7221 {
7222 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7223 }
7224#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007225#ifdef LINKSPEED_DEBUG_ENABLED
7226 pr_info("Reporting actual MCS rate %d flags %x\n",
7227 sinfo->txrate.mcs,
7228 sinfo->txrate.flags );
7229#endif //LINKSPEED_DEBUG_ENABLED
7230 }
7231 }
7232 sinfo->filled |= STATION_INFO_TX_BITRATE;
7233
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007234 sinfo->tx_packets =
7235 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7236 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7237 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7238 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7239
7240 sinfo->tx_retries =
7241 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7242 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7243 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7244 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7245
7246 sinfo->tx_failed =
7247 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7248 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7249 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7250 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7251
7252 sinfo->filled |=
7253 STATION_INFO_TX_PACKETS |
7254 STATION_INFO_TX_RETRIES |
7255 STATION_INFO_TX_FAILED;
7256
7257 EXIT();
7258 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007259}
7260
7261static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007262 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007263{
7264 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307265 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307267 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007268
Jeff Johnsone7245742012-09-05 17:12:55 -07007269 ENTER();
7270
Jeff Johnson295189b2012-06-20 16:38:30 -07007271 if (NULL == pAdapter)
7272 {
7273 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7274 return -ENODEV;
7275 }
7276
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307277 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307278 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307279
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307280 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307281 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7283 "%s: HDD context is not valid", __func__);
7284 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307285 }
7286
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307287 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7288 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7289 (pHddCtx->cfg_ini->fhostArpOffload) &&
7290 (eConnectionState_Associated ==
7291 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7292 {
Amar Singhald53568e2013-09-26 11:03:45 -07007293
7294 hddLog(VOS_TRACE_LEVEL_INFO,
7295 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307296 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307297 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7298 {
7299 hddLog(VOS_TRACE_LEVEL_INFO,
7300 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7301 __func__, vos_status);
7302 }
7303 }
7304
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 /**The get power cmd from the supplicant gets updated by the nl only
7306 *on successful execution of the function call
7307 *we are oppositely mapped w.r.t mode in the driver
7308 **/
7309 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7310
Jeff Johnsone7245742012-09-05 17:12:55 -07007311 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 if (VOS_STATUS_E_FAILURE == vos_status)
7313 {
7314 return -EINVAL;
7315 }
7316 return 0;
7317}
7318
7319
7320#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7321static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7322 struct net_device *netdev,
7323 u8 key_index)
7324{
Jeff Johnsone7245742012-09-05 17:12:55 -07007325 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007326 return 0;
7327}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307328#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007329
7330#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7331static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7332 struct net_device *dev,
7333 struct ieee80211_txq_params *params)
7334{
Jeff Johnsone7245742012-09-05 17:12:55 -07007335 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 return 0;
7337}
7338#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7339static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7340 struct ieee80211_txq_params *params)
7341{
Jeff Johnsone7245742012-09-05 17:12:55 -07007342 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007343 return 0;
7344}
7345#endif //LINUX_VERSION_CODE
7346
7347static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7348 struct net_device *dev, u8 *mac)
7349{
7350 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307351 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007352 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307353 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007354 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007355
Jeff Johnsone7245742012-09-05 17:12:55 -07007356 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307357 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307359 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 return -EINVAL;
7361 }
7362
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307363 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7364 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007365
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307366 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007367 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7369 "%s: HDD context is not valid", __func__);
7370 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007371 }
7372
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007374 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007375 )
7376 {
7377 if( NULL == mac )
7378 {
7379 v_U16_t i;
7380 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7381 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007382 if ((pAdapter->aStaInfo[i].isUsed) &&
7383 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 {
7385 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7386 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007387 "%s: Delete STA with MAC::"
7388 MAC_ADDRESS_STR,
7389 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007390 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7391 if (VOS_IS_STATUS_SUCCESS(vos_status))
7392 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 }
7394 }
7395 }
7396 else
7397 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007398
7399 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7400 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7401 {
7402 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007403 "%s: Skip this DEL STA as this is not used::"
7404 MAC_ADDRESS_STR,
7405 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007406 return -ENOENT;
7407 }
7408
7409 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7410 {
7411 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007412 "%s: Skip this DEL STA as deauth is in progress::"
7413 MAC_ADDRESS_STR,
7414 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007415 return -ENOENT;
7416 }
7417
7418 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7419
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 hddLog(VOS_TRACE_LEVEL_INFO,
7421 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007422 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007423 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007424 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007425
7426 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7427 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7428 {
7429 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7430 hddLog(VOS_TRACE_LEVEL_INFO,
7431 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007432 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007433 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007434 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007435 return -ENOENT;
7436 }
7437
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 }
7439 }
7440
7441 EXIT();
7442
7443 return 0;
7444}
7445
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007446static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7447 struct net_device *dev, u8 *mac, struct station_parameters *params)
7448{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007449 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007450#ifdef FEATURE_WLAN_TDLS
7451 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007452 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007453 mask = params->sta_flags_mask;
7454
7455 set = params->sta_flags_set;
7456
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007457#ifdef WLAN_FEATURE_TDLS_DEBUG
7458 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7459 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7460 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7461#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007462
7463 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7464 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007465 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007466 }
7467 }
7468#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007469 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007470}
7471
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007472
7473#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007474#define MAX_PMKSAIDS_IN_CACHE 8
7475
7476static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7477static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7478
7479
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007480static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007481 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007482{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307483 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007484 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7485 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307486 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307487 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007488 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307489 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307490
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007491 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7492 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007493
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307494 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307495 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007496 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307497 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007498 return -EINVAL;
7499 }
7500
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307501 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7502 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007503
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307504 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007505 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307506 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7507 "%s: HDD context is not valid", __func__);
7508 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007509 }
7510
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307511 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007512 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7513
Wilson Yang6507c4e2013-10-01 20:11:19 -07007514 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007515 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307516 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007517 pmksa->bssid, WNI_CFG_BSSID_LEN))
7518 {
7519 /* BSSID matched previous entry. Overwrite it. */
7520 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307521 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007522 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307523 vos_mem_copy(PMKIDCache[j].PMKID,
7524 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007525 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307526 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007527 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007528 dump_bssid(pmksa->bssid);
7529 dump_pmkid(halHandle, pmksa->pmkid);
7530 break;
7531 }
7532 }
7533
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007534 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007535 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007536
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007537 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307538 {
7539 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007540 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307541 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007542 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307543 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007544 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307545 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007546 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007547 dump_bssid(pmksa->bssid);
7548 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307549 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007550 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007551 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007552 }
7553
7554
7555 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307556 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007557 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307558 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007559 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007560 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307561 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7562 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007563 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007564 return 0;
7565}
7566
7567
Wilson Yang6507c4e2013-10-01 20:11:19 -07007568
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007569static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007570 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007571{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007572 tANI_U32 j=0;
7573 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7574 tHalHandle halHandle;
7575 int status;
7576 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07007577 hdd_context_t *pHddCtx;
7578 int result = 0;
7579
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007580 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
7581 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007582
7583 /* Validate pAdapter */
7584 if (NULL == pAdapter)
7585 {
7586 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7587 return -EINVAL;
7588 }
7589
7590 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7591 status = wlan_hdd_validate_context(pHddCtx);
7592
7593 if (0 != status)
7594 {
7595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7596 "%s: HDD context is not valid", __func__);
7597 return status;
7598 }
7599
7600 /*Retrieve halHandle*/
7601 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7602
7603 /*in case index is 0,no entry to delete*/
7604 if (0 == PMKIDCacheIndex)
7605 {
7606 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7607 __func__);
7608 return -EINVAL;
7609 }
7610
7611 /*find the matching PMKSA entry from j=0 to (index-1),
7612 * and delete the matched one
7613 */
7614 for (j = 0; j<PMKIDCacheIndex; j++)
7615 {
7616 if (vos_mem_compare(PMKIDCache[j].BSSID,
7617 pmksa->bssid,
7618 WNI_CFG_BSSID_LEN))
7619 {
7620 /* BSSID matched entry */
7621 BSSIDMatched = 1;
7622
7623 if (j<PMKIDCacheIndex-1)
7624 {
7625 /*replace the matching entry with the last entry in HDD local cache*/
7626 vos_mem_copy(PMKIDCache[j].BSSID,
7627 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7628 WNI_CFG_BSSID_LEN);
7629 vos_mem_copy(PMKIDCache[j].PMKID,
7630 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7631 CSR_RSN_PMKID_SIZE);
7632 }
7633
7634 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07007635 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7636 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7637
7638 /*reduce the PMKID array index*/
7639 PMKIDCacheIndex--;
7640
7641 /*delete the last PMKID cache in CSR*/
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307642 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007643 if (0 != result)
7644 {
7645 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7646 __func__,PMKIDCacheIndex);
7647 }
7648
7649 dump_bssid(pmksa->bssid);
7650 dump_pmkid(halHandle,pmksa->pmkid);
7651
7652 break;
7653 }
7654 }
7655
7656 /* we compare all entries,but cannot find matching entry */
7657 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7658 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007659 hddLog(VOS_TRACE_LEVEL_FATAL,
7660 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
7661 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007662 dump_bssid(pmksa->bssid);
7663 dump_pmkid(halHandle, pmksa->pmkid);
7664 return -EINVAL;
7665 }
7666 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007667}
7668
Wilson Yang6507c4e2013-10-01 20:11:19 -07007669
7670
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007671static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7672{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007673 tANI_U32 j=0;
7674 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7675 tHalHandle halHandle;
7676 hdd_context_t *pHddCtx;
7677 tANI_U8 *pBSSId;
7678 int status;
7679 int result;
7680
7681 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7682
7683 /* Validate pAdapter */
7684 if (NULL == pAdapter)
7685 {
7686 hddLog(VOS_TRACE_LEVEL_ERROR,
7687 "%s: Invalid Adapter" ,__func__);
7688 return -EINVAL;
7689 }
7690
7691 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7692 status = wlan_hdd_validate_context(pHddCtx);
7693
7694 if (0 != status)
7695 {
7696 hddLog(VOS_TRACE_LEVEL_ERROR,
7697 "%s: HDD context is not valid", __func__);
7698 return status;
7699 }
7700
7701 /*Retrieve halHandle*/
7702 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7703
7704 /*in case index is 0,no entry to delete*/
7705 if (0 == PMKIDCacheIndex)
7706 {
7707 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7708 __func__);
7709 return -EINVAL;
7710 }
7711
7712 /*delete all the PMKSA one by one */
7713 for (j = 0; j<PMKIDCacheIndex; j++)
7714 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07007715 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007716
7717 /*delete the PMKID in CSR*/
7718 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7719
7720 if (0!= result)
7721 {
7722 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7723 __func__,j);
7724 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307725 /*clear the entry in HDD cache 0--index-1 */
7726 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7727 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007728 }
7729
7730 PMKIDCacheIndex = 0;
7731 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007732}
7733#endif
7734
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007735#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307736static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007737 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7738{
7739 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7740 hdd_station_ctx_t *pHddStaCtx;
7741
7742 if (NULL == pAdapter)
7743 {
7744 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7745 return -ENODEV;
7746 }
7747
7748 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7749
7750 // Added for debug on reception of Re-assoc Req.
7751 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7752 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307753 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007754 ftie->ie_len);
7755 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7756 }
7757
7758#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307759 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007760 ftie->ie_len);
7761#endif
7762
7763 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307764 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7765 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007766 ftie->ie_len);
7767 return 0;
7768}
7769#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007770
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307771#ifdef FEATURE_WLAN_SCAN_PNO
7772
7773void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7774 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7775{
7776 int ret;
7777 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7778 hdd_context_t *pHddCtx;
7779
7780 if (NULL == pAdapter)
7781 {
7782 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7783 "%s: HDD adapter is Null", __func__);
7784 return ;
7785 }
7786
7787 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7788 if (NULL == pHddCtx)
7789 {
7790 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7791 "%s: HDD context is Null!!!", __func__);
7792 return ;
7793 }
7794
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307795 spin_lock(&pHddCtx->schedScan_lock);
7796 if (TRUE == pHddCtx->isWiphySuspended)
7797 {
7798 pHddCtx->isSchedScanUpdatePending = TRUE;
7799 spin_unlock(&pHddCtx->schedScan_lock);
7800 hddLog(VOS_TRACE_LEVEL_INFO,
7801 "%s: Update cfg80211 scan database after it resume", __func__);
7802 return ;
7803 }
7804 spin_unlock(&pHddCtx->schedScan_lock);
7805
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307806 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7807
7808 if (0 > ret)
7809 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7810
7811 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7813 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307814}
7815
7816/*
7817 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7818 * NL interface to enable PNO
7819 */
7820static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7821 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7822{
7823 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7824 tpSirPNOScanReq pPnoRequest = NULL;
7825 hdd_context_t *pHddCtx;
7826 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307827 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307828 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7829 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7830 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7831 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307832 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307833
7834 if (NULL == pAdapter)
7835 {
7836 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7837 "%s: HDD adapter is Null", __func__);
7838 return -ENODEV;
7839 }
7840
7841 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307842 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307843
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307844 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307845 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307846 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7847 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307848 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307849 }
7850
7851 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7852 if (NULL == hHal)
7853 {
7854 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7855 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307856 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307857 }
7858
7859 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7860 if (NULL == pPnoRequest)
7861 {
7862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7863 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307864 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307865 }
7866
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307867 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307868 pPnoRequest->enable = 1; /*Enable PNO */
7869 pPnoRequest->ucNetworksCount = request->n_match_sets;
7870
7871 if (( !pPnoRequest->ucNetworksCount ) ||
7872 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7873 {
7874 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7875 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307876 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307877 goto error;
7878 }
7879
7880 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7881 {
7882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7883 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307884 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307885 goto error;
7886 }
7887
7888 /* Framework provides one set of channels(all)
7889 * common for all saved profile */
7890 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7891 channels_allowed, &num_channels_allowed))
7892 {
7893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7894 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307895 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307896 goto error;
7897 }
7898 /* Checking each channel against allowed channel list */
7899 num_ch = 0;
7900 for (i = 0; i < request->n_channels; i++)
7901 {
7902 for (indx = 0; indx < num_channels_allowed; indx++)
7903 {
7904 if (request->channels[i]->hw_value == channels_allowed[indx])
7905 {
7906 valid_ch[num_ch++] = request->channels[i]->hw_value;
7907 break ;
7908 }
7909 }
7910 }
7911
7912 /* Filling per profile params */
7913 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7914 {
7915 pPnoRequest->aNetworks[i].ssId.length =
7916 request->match_sets[i].ssid.ssid_len;
7917
7918 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7919 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7920 {
7921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7922 "SSID Len %d is not correct for network %d",
7923 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307924 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307925 goto error;
7926 }
7927
7928 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7929 request->match_sets[i].ssid.ssid,
7930 request->match_sets[i].ssid.ssid_len);
7931 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7932 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7933 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7934
7935 /*Copying list of valid channel into request */
7936 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7937 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7938
7939 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7940 }
7941
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307942 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7943 "request->ie_len = %d", request->ie_len);
7944 if ((0 < request->ie_len) && (NULL != request->ie))
7945 {
7946 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7947 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7948 pPnoRequest->us24GProbeTemplateLen);
7949
7950 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7951 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7952 pPnoRequest->us5GProbeTemplateLen);
7953 }
7954
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307955 /* Driver gets only one time interval which is hardcoded in
7956 * supplicant for 10000ms. Taking power consumption into account 6 timers
7957 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7958 * 80,160,320 secs. And number of scan cycle for each timer
7959 * is configurable through INI param gPNOScanTimerRepeatValue.
7960 * If it is set to 0 only one timer will be used and PNO scan cycle
7961 * will be repeated after each interval specified by supplicant
7962 * till PNO is disabled.
7963 */
7964 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7965 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7966 else
7967 pPnoRequest->scanTimers.ucScanTimersCount =
7968 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7969
7970 tempInterval = (request->interval)/1000;
7971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7972 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7973 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7974 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7975 {
7976 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7977 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7978 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7979 tempInterval *= 2;
7980 }
7981 //Repeat last timer until pno disabled.
7982 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7983
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307984 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307985
7986 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7987 pPnoRequest, pAdapter->sessionId,
7988 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7989 if (eHAL_STATUS_SUCCESS != status)
7990 {
7991 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7992 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307993 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307994 goto error;
7995 }
7996
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307997 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7998 "PNO scanRequest offloaded");
7999
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308000error:
8001 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308002 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308003}
8004
8005/*
8006 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8007 * NL interface to disable PNO
8008 */
8009static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8010 struct net_device *dev)
8011{
8012 eHalStatus status = eHAL_STATUS_FAILURE;
8013 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8014 hdd_context_t *pHddCtx;
8015 tHalHandle hHal;
8016 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308017 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308018
8019 ENTER();
8020
8021 if (NULL == pAdapter)
8022 {
8023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8024 "%s: HDD adapter is Null", __func__);
8025 return -ENODEV;
8026 }
8027
8028 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308029
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308030 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308031 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308032 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308033 "%s: HDD context is Null", __func__);
8034 return -ENODEV;
8035 }
8036
8037 /* The return 0 is intentional when isLogpInProgress and
8038 * isLoadUnloadInProgress. We did observe a crash due to a return of
8039 * failure in sched_scan_stop , especially for a case where the unload
8040 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8041 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8042 * success. If it returns a failure , then its next invocation due to the
8043 * clean up of the second interface will have the dev pointer corresponding
8044 * to the first one leading to a crash.
8045 */
8046 if (pHddCtx->isLogpInProgress)
8047 {
8048 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8049 "%s: LOGP in Progress. Ignore!!!", __func__);
8050 return ret;
8051 }
8052
8053 if (pHddCtx->isLoadUnloadInProgress)
8054 {
8055 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8056 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8057 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308058 }
8059
8060 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8061 if (NULL == hHal)
8062 {
8063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8064 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308065 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308066 }
8067
8068 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8069 if (NULL == pPnoRequest)
8070 {
8071 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8072 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308073 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308074 }
8075
8076 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8077 pPnoRequest->enable = 0; /* Disable PNO */
8078 pPnoRequest->ucNetworksCount = 0;
8079
8080 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8081 pAdapter->sessionId,
8082 NULL, pAdapter);
8083 if (eHAL_STATUS_SUCCESS != status)
8084 {
8085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8086 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308087 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308088 }
8089
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308090 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8091 "%s: PNO scan disabled", __func__);
8092
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308093 vos_mem_free(pPnoRequest);
8094
8095 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308096 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308097}
8098
8099#endif /*FEATURE_WLAN_SCAN_PNO*/
8100
8101
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008102#ifdef FEATURE_WLAN_TDLS
8103static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8104 u8 *peer, u8 action_code, u8 dialog_token,
8105 u16 status_code, const u8 *buf, size_t len)
8106{
8107
8108 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8109 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008110 u8 peerMac[6];
8111 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008112 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008113 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008114 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008115
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008116 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008117 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308118 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008119 "Invalid arguments");
8120 return -EINVAL;
8121 }
8122
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008123 if (pHddCtx->isLogpInProgress)
8124 {
8125 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8126 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008127 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008128 return -EBUSY;
8129 }
8130
Hoonki Lee27511902013-03-14 18:19:06 -07008131 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008132 {
Hoonki Lee27511902013-03-14 18:19:06 -07008133 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8134 "%s: TDLS mode is disabled OR not enabled in FW."
8135 MAC_ADDRESS_STR " action %d declined.",
8136 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008137 return -ENOTSUPP;
8138 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008139
Hoonki Lee27511902013-03-14 18:19:06 -07008140 /* other than teardown frame, other mgmt frames are not sent if disabled */
8141 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8142 {
8143 /* if tdls_mode is disabled to respond to peer's request */
8144 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8145 {
8146 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8147 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008148 " TDLS mode is disabled. action %d declined.",
8149 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008150
8151 return -ENOTSUPP;
8152 }
8153 }
8154
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008155 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8156 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308157 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008158 {
8159 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008160 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008161 " TDLS setup is ongoing. action %d declined.",
8162 __func__, MAC_ADDR_ARRAY(peer), action_code);
8163 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008164 }
8165 }
8166
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008167 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8168 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008169 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008170 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008171 {
8172 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8173 we return error code at 'add_station()'. Hence we have this
8174 check again in addtion to add_station().
8175 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008176 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008177 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8179 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008180 " TDLS Max peer already connected. action %d declined.",
8181 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008182 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008183 }
8184 else
8185 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008186 /* maximum reached. tweak to send error code to peer and return
8187 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008188 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008189 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8190 "%s: " MAC_ADDRESS_STR
8191 " TDLS Max peer already connected send response status %d",
8192 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008193 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008194 /* fall through to send setup resp with failure status
8195 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008196 }
8197 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008198 else
8199 {
8200 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308201 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008202 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008203 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008204 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008205 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8206 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008207 return -EPERM;
8208 }
8209 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008210 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008211 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008212
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008213#ifdef WLAN_FEATURE_TDLS_DEBUG
8214 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008215 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8216 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8217 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008218#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008219
Hoonki Leea34dd892013-02-05 22:56:02 -08008220 /*Except teardown responder will not be used so just make 0*/
8221 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008222 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008223 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008224
8225 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308226 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008227
8228 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8229 responder = pTdlsPeer->is_responder;
8230 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008231 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008232 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8233 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8234 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8235 dialog_token, status_code, len);
8236 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008237 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008238 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008239
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308240 /* For explicit trigger of DIS_REQ come out of BMPS for
8241 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008242 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308243 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8244 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008245 {
8246 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8247 {
8248 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308249 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008250 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8251 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308252 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8253 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008254 }
8255
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008256 /* make sure doesn't call send_mgmt() while it is pending */
8257 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8258 {
8259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8260 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8261 __func__, MAC_ADDR_ARRAY(peer), action_code);
8262 return -EBUSY;
8263 }
8264
8265 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008266 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8267
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008268 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008269 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008270
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008271 if (VOS_STATUS_SUCCESS != status)
8272 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8274 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008275 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008276 wlan_hdd_tdls_check_bmps(pAdapter);
8277 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008278 }
8279
Hoonki Leed37cbb32013-04-20 00:31:14 -07008280 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8281 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8282
8283 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008284 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008285 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008286 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008287 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008288 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008289 wlan_hdd_tdls_check_bmps(pAdapter);
8290 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008291 }
8292
Gopichand Nakkala05922802013-03-14 12:23:19 -07008293 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008294 {
8295 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008296 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008297 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008298
Hoonki Leea34dd892013-02-05 22:56:02 -08008299 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8300 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008301 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008302 }
8303 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8304 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008305 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008306 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008307
8308 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008309error:
8310 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8311 because we already know that this transaction will be failed,
8312 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8313 to be safe, do not change the state mahine.
8314 */
8315 if(max_sta_failed == 0 &&
8316 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8317 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8318 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008319}
8320
8321static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8322 u8 *peer, enum nl80211_tdls_operation oper)
8323{
8324 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8325 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308326 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008327#ifdef WLAN_FEATURE_TDLS_DEBUG
8328 const char *tdls_oper_str[]= {
8329 "NL80211_TDLS_DISCOVERY_REQ",
8330 "NL80211_TDLS_SETUP",
8331 "NL80211_TDLS_TEARDOWN",
8332 "NL80211_TDLS_ENABLE_LINK",
8333 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308334 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008335#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008336 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008337
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308338 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008339 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008340 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008341 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008342 return -EINVAL;
8343 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008344
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308345 status = wlan_hdd_validate_context(pHddCtx);
8346
8347 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008348 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308349 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8350 "%s: HDD context is not valid", __func__);
8351 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008352 }
8353
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308354 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008355
8356 if ( NULL == pTdlsPeer ) {
8357 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8358 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8359 return -EINVAL;
8360 }
8361
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008362#ifdef WLAN_FEATURE_TDLS_DEBUG
8363 if((int)oper > 4)
8364 oper = 5;
8365
8366 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008367 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8368 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008369 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008370#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008371
8372 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008373 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008374 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008375 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008376 "TDLS Disabled in INI OR not enabled in FW. "
8377 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008378 return -ENOTSUPP;
8379 }
8380
8381 switch (oper) {
8382 case NL80211_TDLS_ENABLE_LINK:
8383 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008384 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308385 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008386
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008387 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8388 {
8389 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8390 MAC_ADDRESS_STR " failed",
8391 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8392 return -EINVAL;
8393 }
8394
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008395 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008396 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308397 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308398 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308399
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308400 if (0 != wlan_hdd_tdls_get_link_establish_params(
8401 pAdapter, peer,&tdlsLinkEstablishParams)) {
8402 return -EINVAL;
8403 }
8404 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308405
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308406 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8407 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8408 /* Send TDLS peer UAPSD capabilities to the firmware and
8409 * register with the TL on after the response for this operation
8410 * is received .
8411 */
8412 ret = wait_for_completion_interruptible_timeout(
8413 &pAdapter->tdls_link_establish_req_comp,
8414 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8415 if (ret <= 0)
8416 {
8417 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8418 "%s: Link Establish Request Faled Status %ld",
8419 __func__, ret);
8420 return -EINVAL;
8421 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308422 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008423 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308424 /* Mark TDLS client Authenticated .*/
8425 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8426 pTdlsPeer->staId,
8427 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008428 if (VOS_STATUS_SUCCESS == status)
8429 {
Hoonki Lee14621352013-04-16 17:51:19 -07008430 if (pTdlsPeer->is_responder == 0)
8431 {
8432 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8433
8434 wlan_hdd_tdls_timer_restart(pAdapter,
8435 &pTdlsPeer->initiatorWaitTimeoutTimer,
8436 WAIT_TIME_TDLS_INITIATOR);
8437 /* suspend initiator TX until it receives direct packet from the
8438 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8439 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8440 &staId, NULL);
8441 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008442 wlan_hdd_tdls_increment_peer_count(pAdapter);
8443 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008444 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308445
8446 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308447 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8448 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308449 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308450 int ac;
8451 uint8 ucAc[4] = { WLANTL_AC_VO,
8452 WLANTL_AC_VI,
8453 WLANTL_AC_BK,
8454 WLANTL_AC_BE };
8455 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8456 for(ac=0; ac < 4; ac++)
8457 {
8458 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8459 pTdlsPeer->staId, ucAc[ac],
8460 tlTid[ac], tlTid[ac], 0, 0,
8461 WLANTL_BI_DIR );
8462 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308463 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008464 }
8465
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008466 }
8467 break;
8468 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008469 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008470 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008471 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008472 long status;
8473
8474 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8475
Lee Hoonkic1262f22013-01-24 21:59:00 -08008476 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8477 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008478
8479 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8480 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8481 if (status <= 0)
8482 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008483 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008484 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8485 "%s: Del station failed status %ld",
8486 __func__, status);
8487 return -EPERM;
8488 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008489 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008490 }
8491 else
8492 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008493 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8494 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008495 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008496 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008497 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008498 case NL80211_TDLS_TEARDOWN:
8499 case NL80211_TDLS_SETUP:
8500 case NL80211_TDLS_DISCOVERY_REQ:
8501 /* We don't support in-driver setup/teardown/discovery */
8502 return -ENOTSUPP;
8503 default:
8504 return -ENOTSUPP;
8505 }
8506 return 0;
8507}
Chilam NG571c65a2013-01-19 12:27:36 +05308508
8509int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8510 struct net_device *dev, u8 *peer)
8511{
8512 hddLog(VOS_TRACE_LEVEL_INFO, "tdls send discover req: %x %x %x %x %x %x",
8513 peer[0], peer[1], peer[2], peer[3], peer[4], peer[5]);
8514
8515 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8516 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8517}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008518#endif
8519
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308520#ifdef WLAN_FEATURE_GTK_OFFLOAD
8521/*
8522 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8523 * Callback rountine called upon receiving response for
8524 * get offload info
8525 */
8526void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8527 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8528{
8529
8530 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308531 tANI_U8 tempReplayCounter[8];
8532 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308533
8534 ENTER();
8535
8536 if (NULL == pAdapter)
8537 {
8538 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8539 "%s: HDD adapter is Null", __func__);
8540 return ;
8541 }
8542
8543 if (NULL == pGtkOffloadGetInfoRsp)
8544 {
8545 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8546 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8547 return ;
8548 }
8549
8550 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8551 {
8552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8553 "%s: wlan Failed to get replay counter value",
8554 __func__);
8555 return ;
8556 }
8557
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308558 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8559 /* Update replay counter */
8560 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8561 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8562
8563 {
8564 /* changing from little to big endian since supplicant
8565 * works on big endian format
8566 */
8567 int i;
8568 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8569
8570 for (i = 0; i < 8; i++)
8571 {
8572 tempReplayCounter[7-i] = (tANI_U8)p[i];
8573 }
8574 }
8575
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308576 /* Update replay counter to NL */
8577 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308578 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308579}
8580
8581/*
8582 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8583 * This function is used to offload GTK rekeying job to the firmware.
8584 */
8585int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8586 struct cfg80211_gtk_rekey_data *data)
8587{
8588 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8589 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8590 hdd_station_ctx_t *pHddStaCtx;
8591 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308592 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308593 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308594 eHalStatus status = eHAL_STATUS_FAILURE;
8595
8596 ENTER();
8597
8598 if (NULL == pAdapter)
8599 {
8600 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8601 "%s: HDD adapter is Null", __func__);
8602 return -ENODEV;
8603 }
8604
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308605 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308606
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308607 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308608 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308609 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8610 "%s: HDD context is not valid", __func__);
8611 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308612 }
8613
8614 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8615 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8616 if (NULL == hHal)
8617 {
8618 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8619 "%s: HAL context is Null!!!", __func__);
8620 return -EAGAIN;
8621 }
8622
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308623 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8624 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8625 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8626 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308627 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308628 {
8629 /* changing from big to little endian since driver
8630 * works on little endian format
8631 */
8632 tANI_U8 *p =
8633 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8634 int i;
8635
8636 for (i = 0; i < 8; i++)
8637 {
8638 p[7-i] = data->replay_ctr[i];
8639 }
8640 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308641
8642 if (TRUE == pHddCtx->hdd_wlan_suspended)
8643 {
8644 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308645 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8646 sizeof (tSirGtkOffloadParams));
8647 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308648 pAdapter->sessionId);
8649
8650 if (eHAL_STATUS_SUCCESS != status)
8651 {
8652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8653 "%s: sme_SetGTKOffload failed, returned %d",
8654 __func__, status);
8655 return status;
8656 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308657 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8658 "%s: sme_SetGTKOffload successfull", __func__);
8659 }
8660 else
8661 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308662 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8663 "%s: wlan not suspended GTKOffload request is stored",
8664 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308665 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308666
8667 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308668}
8669#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8670
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308671/*
8672 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8673 * This function is used to set access control policy
8674 */
8675static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8676 struct net_device *dev, const struct cfg80211_acl_data *params)
8677{
8678 int i;
8679 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8680 hdd_hostapd_state_t *pHostapdState;
8681 tsap_Config_t *pConfig;
8682 v_CONTEXT_t pVosContext = NULL;
8683 hdd_context_t *pHddCtx;
8684 int status;
8685
8686 ENTER();
8687
8688 if (NULL == pAdapter)
8689 {
8690 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8691 "%s: HDD adapter is Null", __func__);
8692 return -ENODEV;
8693 }
8694
8695 if (NULL == params)
8696 {
8697 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8698 "%s: params is Null", __func__);
8699 return -EINVAL;
8700 }
8701
8702 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8703 status = wlan_hdd_validate_context(pHddCtx);
8704
8705 if (0 != status)
8706 {
8707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8708 "%s: HDD context is not valid", __func__);
8709 return status;
8710 }
8711
8712 pVosContext = pHddCtx->pvosContext;
8713 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8714
8715 if (NULL == pHostapdState)
8716 {
8717 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8718 "%s: pHostapdState is Null", __func__);
8719 return -EINVAL;
8720 }
8721
8722 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8723 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8724
8725 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8726 {
8727 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8728
8729 /* default value */
8730 pConfig->num_accept_mac = 0;
8731 pConfig->num_deny_mac = 0;
8732
8733 /**
8734 * access control policy
8735 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8736 * listed in hostapd.deny file.
8737 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8738 * listed in hostapd.accept file.
8739 */
8740 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8741 {
8742 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8743 }
8744 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8745 {
8746 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8747 }
8748 else
8749 {
8750 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8751 "%s:Acl Policy : %d is not supported",
8752 __func__, params->acl_policy);
8753 return -ENOTSUPP;
8754 }
8755
8756 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8757 {
8758 pConfig->num_accept_mac = params->n_acl_entries;
8759 for (i = 0; i < params->n_acl_entries; i++)
8760 {
8761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8762 "** Add ACL MAC entry %i in WhiletList :"
8763 MAC_ADDRESS_STR, i,
8764 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8765
8766 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8767 sizeof(qcmacaddr));
8768 }
8769 }
8770 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8771 {
8772 pConfig->num_deny_mac = params->n_acl_entries;
8773 for (i = 0; i < params->n_acl_entries; i++)
8774 {
8775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8776 "** Add ACL MAC entry %i in BlackList :"
8777 MAC_ADDRESS_STR, i,
8778 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8779
8780 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8781 sizeof(qcmacaddr));
8782 }
8783 }
8784
8785 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8786 {
8787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8788 "%s: SAP Set Mac Acl fail", __func__);
8789 return -EINVAL;
8790 }
8791 }
8792 else
8793 {
8794 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8795 "%s: Invalid device_mode = %d",
8796 __func__, pAdapter->device_mode);
8797 return -EINVAL;
8798 }
8799
8800 return 0;
8801}
8802
Leo Chang9056f462013-08-01 19:21:11 -07008803#ifdef WLAN_NL80211_TESTMODE
8804#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008805void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008806(
8807 void *pAdapter,
8808 void *indCont
8809)
8810{
Leo Changd9df8aa2013-09-26 13:32:26 -07008811 tSirLPHBInd *lphbInd;
8812 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008813
8814 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008815 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008816
8817 if (NULL == indCont)
8818 {
8819 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008820 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008821 return;
8822 }
8823
Leo Changd9df8aa2013-09-26 13:32:26 -07008824 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008825 skb = cfg80211_testmode_alloc_event_skb(
8826 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008827 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008828 GFP_ATOMIC);
8829 if (!skb)
8830 {
8831 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8832 "LPHB timeout, NL buffer alloc fail");
8833 return;
8834 }
8835
Leo Changac3ba772013-10-07 09:47:04 -07008836 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07008837 {
8838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8839 "WLAN_HDD_TM_ATTR_CMD put fail");
8840 goto nla_put_failure;
8841 }
Leo Changac3ba772013-10-07 09:47:04 -07008842 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07008843 {
8844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8845 "WLAN_HDD_TM_ATTR_TYPE put fail");
8846 goto nla_put_failure;
8847 }
Leo Changac3ba772013-10-07 09:47:04 -07008848 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07008849 sizeof(tSirLPHBInd), lphbInd))
8850 {
8851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8852 "WLAN_HDD_TM_ATTR_DATA put fail");
8853 goto nla_put_failure;
8854 }
Leo Chang9056f462013-08-01 19:21:11 -07008855 cfg80211_testmode_event(skb, GFP_ATOMIC);
8856 return;
8857
8858nla_put_failure:
8859 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8860 "NLA Put fail");
8861 kfree_skb(skb);
8862
8863 return;
8864}
8865#endif /* FEATURE_WLAN_LPHB */
8866
8867static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8868{
8869 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8870 int err = 0;
8871#ifdef FEATURE_WLAN_LPHB
8872 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008873 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008874#endif /* FEATURE_WLAN_LPHB */
8875
8876 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8877 if (err)
8878 {
8879 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8880 "%s Testmode INV ATTR", __func__);
8881 return err;
8882 }
8883
8884 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8885 {
8886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8887 "%s Testmode INV CMD", __func__);
8888 return -EINVAL;
8889 }
8890
8891 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8892 {
8893#ifdef FEATURE_WLAN_LPHB
8894 /* Low Power Heartbeat configuration request */
8895 case WLAN_HDD_TM_CMD_WLAN_HB:
8896 {
8897 int buf_len;
8898 void *buf;
8899 tSirLPHBReq *hb_params = NULL;
8900
8901 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8902 {
8903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8904 "%s Testmode INV DATA", __func__);
8905 return -EINVAL;
8906 }
8907
8908 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8909 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8910 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8911 if (NULL == hb_params)
8912 {
8913 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8914 "%s Request Buffer Alloc Fail", __func__);
8915 return -EINVAL;
8916 }
8917
8918 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008919 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8920 hb_params,
8921 wlan_hdd_cfg80211_lphb_ind_handler);
8922 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008923 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8925 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008926 vos_mem_free(hb_params);
8927 }
Leo Chang9056f462013-08-01 19:21:11 -07008928 return 0;
8929 }
8930#endif /* FEATURE_WLAN_LPHB */
8931 default:
8932 return -EOPNOTSUPP;
8933 }
8934
8935 return err;
8936}
8937#endif /* CONFIG_NL80211_TESTMODE */
8938
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308939static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8940 struct net_device *dev,
8941 int idx, struct survey_info *survey)
8942{
8943 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8944 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308945 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308946 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308947 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308948 v_S7_t snr,rssi;
8949 int status, i, j, filled = 0;
8950
8951 ENTER();
8952
8953
8954 if (NULL == pAdapter)
8955 {
8956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8957 "%s: HDD adapter is Null", __func__);
8958 return -ENODEV;
8959 }
8960
8961 if (NULL == wiphy)
8962 {
8963 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8964 "%s: wiphy is Null", __func__);
8965 return -ENODEV;
8966 }
8967
8968 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8969 status = wlan_hdd_validate_context(pHddCtx);
8970
8971 if (0 != status)
8972 {
8973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8974 "%s: HDD context is not valid", __func__);
8975 return status;
8976 }
8977
Mihir Sheted9072e02013-08-21 17:02:29 +05308978 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8979
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308980 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308981 0 != pAdapter->survey_idx ||
8982 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308983 {
8984 /* The survey dump ops when implemented completely is expected to
8985 * return a survey of all channels and the ops is called by the
8986 * kernel with incremental values of the argument 'idx' till it
8987 * returns -ENONET. But we can only support the survey for the
8988 * operating channel for now. survey_idx is used to track
8989 * that the ops is called only once and then return -ENONET for
8990 * the next iteration
8991 */
8992 pAdapter->survey_idx = 0;
8993 return -ENONET;
8994 }
8995
8996 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
8997
8998 wlan_hdd_get_snr(pAdapter, &snr);
8999 wlan_hdd_get_rssi(pAdapter, &rssi);
9000
9001 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9002 hdd_wlan_get_freq(channel, &freq);
9003
9004
9005 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9006 {
9007 if (NULL == wiphy->bands[i])
9008 {
9009 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9010 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9011 continue;
9012 }
9013
9014 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9015 {
9016 struct ieee80211_supported_band *band = wiphy->bands[i];
9017
9018 if (band->channels[j].center_freq == (v_U16_t)freq)
9019 {
9020 survey->channel = &band->channels[j];
9021 /* The Rx BDs contain SNR values in dB for the received frames
9022 * while the supplicant expects noise. So we calculate and
9023 * return the value of noise (dBm)
9024 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9025 */
9026 survey->noise = rssi - snr;
9027 survey->filled = SURVEY_INFO_NOISE_DBM;
9028 filled = 1;
9029 }
9030 }
9031 }
9032
9033 if (filled)
9034 pAdapter->survey_idx = 1;
9035 else
9036 {
9037 pAdapter->survey_idx = 0;
9038 return -ENONET;
9039 }
9040
9041 return 0;
9042}
9043
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309044/*
9045 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9046 * this is called when cfg80211 driver resume
9047 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9048 */
9049int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9050{
9051 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9052 hdd_adapter_t *pAdapter;
9053 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9054 VOS_STATUS status = VOS_STATUS_SUCCESS;
9055
9056 ENTER();
9057
9058 if ( NULL == pHddCtx )
9059 {
9060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9061 "%s: HddCtx validation failed", __func__);
9062 return 0;
9063 }
9064
9065 if (pHddCtx->isLogpInProgress)
9066 {
9067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9068 "%s: LOGP in Progress. Ignore!!!", __func__);
9069 return 0;
9070 }
9071
9072 if (pHddCtx->isLoadUnloadInProgress)
9073 {
9074 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9075 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9076 return 0;
9077 }
9078
9079 spin_lock(&pHddCtx->schedScan_lock);
9080 pHddCtx->isWiphySuspended = FALSE;
9081 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9082 {
9083 spin_unlock(&pHddCtx->schedScan_lock);
9084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9085 "%s: Return resume is not due to PNO indication", __func__);
9086 return 0;
9087 }
9088 // Reset flag to avoid updatating cfg80211 data old results again
9089 pHddCtx->isSchedScanUpdatePending = FALSE;
9090 spin_unlock(&pHddCtx->schedScan_lock);
9091
9092 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9093
9094 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9095 {
9096 pAdapter = pAdapterNode->pAdapter;
9097 if ( (NULL != pAdapter) &&
9098 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9099 {
9100 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
9101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9102 "%s: NO SCAN result", __func__);
9103 else
9104 cfg80211_sched_scan_results(pHddCtx->wiphy);
9105
9106 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9107 "%s : cfg80211 scan result database updated", __func__);
9108
9109 return 0;
9110
9111 }
9112 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9113 pAdapterNode = pNext;
9114 }
9115
9116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9117 "%s: Failed to find Adapter", __func__);
9118 return 0;
9119}
9120
9121/*
9122 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9123 * this is called when cfg80211 driver suspends
9124 */
9125int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9126 struct cfg80211_wowlan *wow)
9127{
9128 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9129
9130 ENTER();
9131 if (NULL == pHddCtx)
9132 {
9133 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9134 "%s: HddCtx validation failed", __func__);
9135 return 0;
9136 }
9137
9138 pHddCtx->isWiphySuspended = TRUE;
9139
9140 EXIT();
9141
9142 return 0;
9143}
9144
Jeff Johnson295189b2012-06-20 16:38:30 -07009145/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309146static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009147{
9148 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9149 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9150 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9151 .change_station = wlan_hdd_change_station,
9152#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9153 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9154 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9155 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009156#else
9157 .start_ap = wlan_hdd_cfg80211_start_ap,
9158 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9159 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009160#endif
9161 .change_bss = wlan_hdd_cfg80211_change_bss,
9162 .add_key = wlan_hdd_cfg80211_add_key,
9163 .get_key = wlan_hdd_cfg80211_get_key,
9164 .del_key = wlan_hdd_cfg80211_del_key,
9165 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009166#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009168#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009169 .scan = wlan_hdd_cfg80211_scan,
9170 .connect = wlan_hdd_cfg80211_connect,
9171 .disconnect = wlan_hdd_cfg80211_disconnect,
9172 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9173 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9174 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9175 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9176 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009177 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9178 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9179 .mgmt_tx = wlan_hdd_action,
9180#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9181 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9182 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9183 .set_txq_params = wlan_hdd_set_txq_params,
9184#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 .get_station = wlan_hdd_cfg80211_get_station,
9186 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9187 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009188 .add_station = wlan_hdd_cfg80211_add_station,
9189#ifdef FEATURE_WLAN_LFR
9190 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9191 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9192 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9193#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009194#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9195 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9196#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009197#ifdef FEATURE_WLAN_TDLS
9198 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9199 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9200#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309201#ifdef WLAN_FEATURE_GTK_OFFLOAD
9202 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9203#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309204#ifdef FEATURE_WLAN_SCAN_PNO
9205 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9206 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9207#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309208 .resume = wlan_hdd_cfg80211_resume_wlan,
9209 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309210 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009211#ifdef WLAN_NL80211_TESTMODE
9212 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9213#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309214 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009215};
9216