blob: 76abade1cf722e1d44581ca431b50ebe88e55d6a [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
Hardik Kantilal Patel3dfd8792013-11-13 20:34:57 +0530681 if (pCfg->configPNOScanSupport)
682 {
683 wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
684 wiphy->max_sched_scan_ssids = SIR_PNO_MAX_SUPP_NETWORKS;
685 wiphy->max_match_sets = SIR_PNO_MAX_SUPP_NETWORKS;
686 wiphy->max_sched_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
687 }
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +0530688#endif/*FEATURE_WLAN_SCAN_PNO*/
Mohit Khanna698ba2a2012-12-04 15:08:18 -0800689
Amar Singhalfddc28c2013-09-05 13:03:40 -0700690#ifdef CONFIG_ENABLE_LINUX_REG
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700691 /* even with WIPHY_FLAG_CUSTOM_REGULATORY,
692 driver can still register regulatory callback and
Amar Singhalfddc28c2013-09-05 13:03:40 -0700693 it will get regulatory settings in wiphy->band[], but
Madan Mohan Koyyalamudic3a240c2012-09-28 15:34:08 -0700694 driver need to determine what to do with both
695 regulatory settings */
Amar Singhalfddc28c2013-09-05 13:03:40 -0700696
697 wiphy->reg_notifier = wlan_hdd_linux_reg_notifier;
Amar Singhala49cbc52013-10-08 18:37:44 -0700698#else
699 wiphy->reg_notifier = wlan_hdd_crda_reg_notifier;
Amar Singhalfddc28c2013-09-05 13:03:40 -0700700#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700701
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530702 wiphy->max_scan_ssids = MAX_SCAN_SSID;
703
Madan Mohan Koyyalamudi6815b162013-07-19 17:17:46 +0530704 wiphy->max_scan_ie_len = SIR_MAC_MAX_IE_LENGTH;
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +0530706 wiphy->max_acl_mac_addrs = MAX_ACL_MAC_ADDRESS;
707
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 /* Supports STATION & AD-HOC modes right now */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530709 wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 | BIT(NL80211_IFTYPE_ADHOC)
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 | BIT(NL80211_IFTYPE_P2P_CLIENT)
712 | BIT(NL80211_IFTYPE_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 | BIT(NL80211_IFTYPE_AP);
714
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800715#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800716 if( pCfg->enableMCC )
717 {
718 /* Currently, supports up to two channels */
719 wlan_hdd_iface_combination.num_different_channels = 2;
720
721 if( !pCfg->allowMCCGODiffBI )
722 wlan_hdd_iface_combination.beacon_int_infra_match = true;
723
724 }
725 wiphy->iface_combinations = &wlan_hdd_iface_combination;
726 wiphy->n_iface_combinations = 1;
727#endif
Sudhir Sattayappa Kohalli278eee52013-01-16 17:35:13 -0800728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 /* Before registering we need to update the ht capabilitied based
730 * on ini values*/
731 if( !pCfg->ShortGI20MhzEnable )
732 {
733 wlan_hdd_band_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
734 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
735 wlan_hdd_band_p2p_2_4_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_20;
736 }
737
738 if( !pCfg->ShortGI40MhzEnable )
739 {
740 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
741 }
742
743 if( !pCfg->nChannelBondingMode5GHz )
744 {
745 wlan_hdd_band_5_GHZ.ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
746 }
747
Gopichand Nakkala1f7a64f2013-04-01 18:37:17 +0530748 wiphy->bands[IEEE80211_BAND_2GHZ] = &wlan_hdd_band_2_4_GHZ;
749 wiphy->bands[IEEE80211_BAND_5GHZ] = &wlan_hdd_band_5_GHZ;
750
751 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
752 {
753
754 if (NULL == wiphy->bands[i])
755 {
756 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[i] is NULL, i = %d",
757 __func__, i);
758 continue;
759 }
760
761 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
762 {
763 struct ieee80211_supported_band *band = wiphy->bands[i];
764
765 if (IEEE80211_BAND_2GHZ == i && eCSR_BAND_5G == pCfg->nBandCapability) // 5G only
766 {
767 // Enable social channels for P2P
768 if (WLAN_HDD_IS_SOCIAL_CHANNEL(band->channels[j].center_freq))
769 band->channels[j].flags &= ~IEEE80211_CHAN_DISABLED;
770 else
771 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
772 continue;
773 }
774 else if (IEEE80211_BAND_5GHZ == i && eCSR_BAND_24 == pCfg->nBandCapability) // 2G only
775 {
776 band->channels[j].flags |= IEEE80211_CHAN_DISABLED;
777 continue;
778 }
779 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 }
781 /*Initialise the supported cipher suite details*/
782 wiphy->cipher_suites = hdd_cipher_suites;
783 wiphy->n_cipher_suites = ARRAY_SIZE(hdd_cipher_suites);
784
785 /*signal strength in mBm (100*dBm) */
786 wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
787
788#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 wiphy->max_remain_on_channel_duration = 1000;
790#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700791
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530792 EXIT();
793 return 0;
794}
795
796/* In this function we are registering wiphy. */
797int wlan_hdd_cfg80211_register(struct wiphy *wiphy)
798{
799 ENTER();
800 /* Register our wiphy dev with cfg80211 */
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 if (0 > wiphy_register(wiphy))
802 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530803 /* print error */
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy register failed", __func__);
805 return -EIO;
806 }
807
808 EXIT();
809 return 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530810}
Jeff Johnson295189b2012-06-20 16:38:30 -0700811
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530812/* In this function we are updating channel list when,
813 regulatory domain is FCC and country code is US.
814 Here In FCC standard 5GHz UNII-1 Bands are indoor only.
815 As per FCC smart phone is not a indoor device.
816 GO should not opeate on indoor channels */
817void wlan_hdd_cfg80211_update_reg_info(struct wiphy *wiphy)
818{
819 int j;
820 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
821 tANI_U8 defaultCountryCode[3] = SME_INVALID_COUNTRY_CODE;
822 //Default counrtycode from NV at the time of wiphy initialization.
823 if (eHAL_STATUS_SUCCESS != sme_GetDefaultCountryCodeFrmNv(pHddCtx->hHal,
824 &defaultCountryCode[0]))
825 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700826 hddLog(LOGE, FL("Failed to get default country code from NV"));
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530827 }
828 if ((defaultCountryCode[0]== 'U') && (defaultCountryCode[1]=='S'))
829 {
Madan Mohan Koyyalamudi71278262013-04-12 22:00:48 +0530830 if (NULL == wiphy->bands[IEEE80211_BAND_5GHZ])
831 {
832 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: wiphy->bands[IEEE80211_BAND_5GHZ] is NULL",__func__ );
833 return;
834 }
835 for (j = 0; j < wiphy->bands[IEEE80211_BAND_5GHZ]->n_channels; j++)
836 {
837 struct ieee80211_supported_band *band = wiphy->bands[IEEE80211_BAND_5GHZ];
838 // Mark UNII -1 band channel as passive
839 if (WLAN_HDD_CHANNEL_IN_UNII_1_BAND(band->channels[j].center_freq))
840 band->channels[j].flags |= IEEE80211_CHAN_PASSIVE_SCAN;
841 }
842 }
843}
844
Jeff Johnson295189b2012-06-20 16:38:30 -0700845/* In this function we will do all post VOS start initialization.
846 In this function we will register for all frame in which supplicant
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530847 is interested.
Jeff Johnson295189b2012-06-20 16:38:30 -0700848*/
849void wlan_hdd_cfg80211_post_voss_start(hdd_adapter_t* pAdapter)
850{
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
852 /* Register for all P2P action, public action etc frames */
853 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
854
Jeff Johnsone7245742012-09-05 17:12:55 -0700855 ENTER();
856
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 /* Right now we are registering these frame when driver is getting
858 initialized. Once we will move to 2.6.37 kernel, in which we have
859 frame register ops, we will move this code as a part of that */
860 /* GAS Initial Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530861 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
863
864 /* GAS Initial Response */
865 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
866 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530867
Jeff Johnson295189b2012-06-20 16:38:30 -0700868 /* GAS Comeback Request */
869 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
870 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
871
872 /* GAS Comeback Response */
873 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
874 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
875
876 /* P2P Public Action */
877 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530878 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 P2P_PUBLIC_ACTION_FRAME_SIZE );
880
881 /* P2P Action */
882 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
883 (v_U8_t*)P2P_ACTION_FRAME,
884 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700885
Gopichand Nakkalae3d56e72013-04-21 23:33:32 +0530886 /* WNM BSS Transition Request frame */
887 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
888 (v_U8_t*)WNM_BSS_ACTION_FRAME,
889 WNM_BSS_ACTION_FRAME_SIZE );
890
Chet Lanctot186b5732013-03-18 10:26:30 -0700891#ifdef WLAN_FEATURE_11W
892 /* SA Query Response Action Frame */
893 sme_RegisterMgmtFrame(hHal, pAdapter->sessionId, type,
894 (v_U8_t*)SA_QUERY_FRAME_RSP,
895 SA_QUERY_FRAME_RSP_SIZE );
896#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700897}
898
899void wlan_hdd_cfg80211_pre_voss_stop(hdd_adapter_t* pAdapter)
900{
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
902 /* Register for all P2P action, public action etc frames */
903 v_U16_t type = (SIR_MAC_MGMT_FRAME << 2) | ( SIR_MAC_MGMT_ACTION << 4);
904
Jeff Johnsone7245742012-09-05 17:12:55 -0700905 ENTER();
906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 /* Right now we are registering these frame when driver is getting
908 initialized. Once we will move to 2.6.37 kernel, in which we have
909 frame register ops, we will move this code as a part of that */
910 /* GAS Initial Request */
911
912 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
913 (v_U8_t*)GAS_INITIAL_REQ, GAS_INITIAL_REQ_SIZE );
914
915 /* GAS Initial Response */
916 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
917 (v_U8_t*)GAS_INITIAL_RSP, GAS_INITIAL_RSP_SIZE );
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530918
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 /* GAS Comeback Request */
920 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
921 (v_U8_t*)GAS_COMEBACK_REQ, GAS_COMEBACK_REQ_SIZE );
922
923 /* GAS Comeback Response */
924 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
925 (v_U8_t*)GAS_COMEBACK_RSP, GAS_COMEBACK_RSP_SIZE );
926
927 /* P2P Public Action */
928 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
Gopichand Nakkala747461f2013-04-24 19:24:45 +0530929 (v_U8_t*)P2P_PUBLIC_ACTION_FRAME,
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 P2P_PUBLIC_ACTION_FRAME_SIZE );
931
932 /* P2P Action */
933 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
934 (v_U8_t*)P2P_ACTION_FRAME,
935 P2P_ACTION_FRAME_SIZE );
Chet Lanctot186b5732013-03-18 10:26:30 -0700936
937#ifdef WLAN_FEATURE_11W
938 /* SA Query Response Action Frame */
939 sme_DeregisterMgmtFrame(hHal, pAdapter->sessionId, type,
940 (v_U8_t*)SA_QUERY_FRAME_RSP,
941 SA_QUERY_FRAME_RSP_SIZE );
942#endif /* WLAN_FEATURE_11W */
Jeff Johnson295189b2012-06-20 16:38:30 -0700943}
944
945#ifdef FEATURE_WLAN_WAPI
946void wlan_hdd_cfg80211_set_key_wapi(hdd_adapter_t* pAdapter, u8 key_index,
947 const u8 *mac_addr, u8 *key , int key_Len)
948{
949 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
950 tCsrRoamSetKey setKey;
951 v_BOOL_t isConnected = TRUE;
952 int status = 0;
953 v_U32_t roamId= 0xFF;
954 tANI_U8 *pKeyPtr = NULL;
955 int n = 0;
956
957 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
958 __func__,pAdapter->device_mode);
959
Gopichand Nakkalae7480202013-02-11 15:24:22 +0530960 vos_mem_zero(&setKey, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 setKey.keyId = key_index; // Store Key ID
962 setKey.encType = eCSR_ENCRYPT_TYPE_WPI; // SET WAPI Encryption
963 setKey.keyDirection = eSIR_TX_RX; // Key Directionn both TX and RX
964 setKey.paeRole = 0 ; // the PAE role
965 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
966 {
967 vos_set_macaddr_broadcast( (v_MACADDR_t *)setKey.peerMac );
968 }
969 else
970 {
971 isConnected = hdd_connIsConnected(pHddStaCtx);
972 vos_mem_copy(setKey.peerMac,&pHddStaCtx->conn_info.bssId,WNI_CFG_BSSID_LEN);
973 }
974 setKey.keyLength = key_Len;
975 pKeyPtr = setKey.Key;
976 memcpy( pKeyPtr, key, key_Len);
977
978 hddLog(VOS_TRACE_LEVEL_INFO,"\n%s: WAPI KEY LENGTH:0x%04x",
979 __func__, key_Len);
980 for (n = 0 ; n < key_Len; n++)
981 hddLog(VOS_TRACE_LEVEL_INFO, "%s WAPI KEY Data[%d]:%02x ",
982 __func__,n,setKey.Key[n]);
983
984 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
985 if ( isConnected )
986 {
987 status= sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
988 pAdapter->sessionId, &setKey, &roamId );
989 }
990 if ( status != 0 )
991 {
992 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
993 "[%4d] sme_RoamSetKey returned ERROR status= %d",
994 __LINE__, status );
995 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
996 }
997}
998#endif /* FEATURE_WLAN_WAPI*/
999
1000#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301001int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001002 beacon_data_t **ppBeacon,
1003 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001004#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301005int wlan_hdd_cfg80211_alloc_new_beacon(hdd_adapter_t *pAdapter,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001006 beacon_data_t **ppBeacon,
1007 struct cfg80211_beacon_data *params,
1008 int dtim_period)
1009#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301010{
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 int size;
1012 beacon_data_t *beacon = NULL;
1013 beacon_data_t *old = NULL;
1014 int head_len,tail_len;
1015
Jeff Johnsone7245742012-09-05 17:12:55 -07001016 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 if (params->head && !params->head_len)
1018 return -EINVAL;
1019
1020 old = pAdapter->sessionCtx.ap.beacon;
1021
1022 if (!params->head && !old)
1023 return -EINVAL;
1024
Jeff Johnson295189b2012-06-20 16:38:30 -07001025#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,38))
1026 /* Kernel 3.0 is not updating dtim_period for set beacon */
1027 if (!params->dtim_period)
1028 return -EINVAL;
1029#endif
1030
1031 if(params->head)
1032 head_len = params->head_len;
1033 else
1034 head_len = old->head_len;
1035
1036 if(params->tail || !old)
1037 tail_len = params->tail_len;
1038 else
1039 tail_len = old->tail_len;
1040
1041 size = sizeof(beacon_data_t) + head_len + tail_len;
1042
1043 beacon = kzalloc(size, GFP_KERNEL);
1044
1045 if( beacon == NULL )
1046 return -ENOMEM;
1047
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001048#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 if(params->dtim_period || !old )
1050 beacon->dtim_period = params->dtim_period;
1051 else
1052 beacon->dtim_period = old->dtim_period;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001053#else
1054 if(dtim_period || !old )
1055 beacon->dtim_period = dtim_period;
1056 else
1057 beacon->dtim_period = old->dtim_period;
1058#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301059
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 beacon->head = ((u8 *) beacon) + sizeof(beacon_data_t);
1061 beacon->tail = beacon->head + head_len;
1062 beacon->head_len = head_len;
1063 beacon->tail_len = tail_len;
1064
1065 if(params->head) {
1066 memcpy (beacon->head,params->head,beacon->head_len);
1067 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301068 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001069 if(old)
1070 memcpy (beacon->head,old->head,beacon->head_len);
1071 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301072
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 if(params->tail) {
1074 memcpy (beacon->tail,params->tail,beacon->tail_len);
1075 }
1076 else {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301077 if(old)
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 memcpy (beacon->tail,old->tail,beacon->tail_len);
1079 }
1080
1081 *ppBeacon = beacon;
1082
1083 kfree(old);
1084
1085 return 0;
1086
1087}
Jeff Johnson295189b2012-06-20 16:38:30 -07001088
1089v_U8_t* wlan_hdd_cfg80211_get_ie_ptr(v_U8_t *pIes, int length, v_U8_t eid)
1090{
1091 int left = length;
1092 v_U8_t *ptr = pIes;
1093 v_U8_t elem_id,elem_len;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 while(left >= 2)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301096 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 elem_id = ptr[0];
1098 elem_len = ptr[1];
1099 left -= 2;
1100 if(elem_len > left)
1101 {
1102 hddLog(VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001103 FL("****Invalid IEs eid = %d elem_len=%d left=%d*****"),
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 eid,elem_len,left);
1105 return NULL;
1106 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301107 if (elem_id == eid)
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 {
1109 return ptr;
1110 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301111
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 left -= elem_len;
1113 ptr += (elem_len + 2);
1114 }
1115 return NULL;
1116}
1117
Jeff Johnson295189b2012-06-20 16:38:30 -07001118/* Check if rate is 11g rate or not */
1119static int wlan_hdd_rate_is_11g(u8 rate)
1120{
Sanjay Devnani28322e22013-06-21 16:13:40 -07001121 static const u8 gRateArray[8] = {12, 18, 24, 36, 48, 72, 96, 108}; /* actual rate * 2 */
Jeff Johnson295189b2012-06-20 16:38:30 -07001122 u8 i;
1123 for (i = 0; i < 8; i++)
1124 {
1125 if(rate == gRateArray[i])
1126 return TRUE;
1127 }
1128 return FALSE;
1129}
1130
1131/* Check for 11g rate and set proper 11g only mode */
1132static void wlan_hdd_check_11gmode(u8 *pIe, u8* require_ht,
1133 u8* pCheckRatesfor11g, eSapPhyMode* pSapHw_mode)
1134{
1135 u8 i, num_rates = pIe[0];
1136
1137 pIe += 1;
1138 for ( i = 0; i < num_rates; i++)
1139 {
1140 if( *pCheckRatesfor11g && (TRUE == wlan_hdd_rate_is_11g(pIe[i] & RATE_MASK)))
1141 {
1142 /* If rate set have 11g rate than change the mode to 11G */
1143 *pSapHw_mode = eSAP_DOT11_MODE_11g;
1144 if (pIe[i] & BASIC_RATE_MASK)
1145 {
1146 /* If we have 11g rate as basic rate, it means mode
1147 is 11g only mode.
1148 */
1149 *pSapHw_mode = eSAP_DOT11_MODE_11g_ONLY;
1150 *pCheckRatesfor11g = FALSE;
1151 }
1152 }
1153 else if((BASIC_RATE_MASK | WLAN_BSS_MEMBERSHIP_SELECTOR_HT_PHY) == pIe[i])
1154 {
1155 *require_ht = TRUE;
1156 }
1157 }
1158 return;
1159}
1160
1161static void wlan_hdd_set_sapHwmode(hdd_adapter_t *pHostapdAdapter)
1162{
1163 tsap_Config_t *pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1164 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1165 struct ieee80211_mgmt *pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1166 u8 checkRatesfor11g = TRUE;
1167 u8 require_ht = FALSE;
1168 u8 *pIe=NULL;
1169
1170 pConfig->SapHw_mode= eSAP_DOT11_MODE_11b;
1171
1172 pIe = wlan_hdd_cfg80211_get_ie_ptr(&pMgmt_frame->u.beacon.variable[0],
1173 pBeacon->head_len, WLAN_EID_SUPP_RATES);
1174 if (pIe != NULL)
1175 {
1176 pIe += 1;
1177 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1178 &pConfig->SapHw_mode);
1179 }
1180
1181 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1182 WLAN_EID_EXT_SUPP_RATES);
1183 if (pIe != NULL)
1184 {
1185
1186 pIe += 1;
1187 wlan_hdd_check_11gmode(pIe, &require_ht, &checkRatesfor11g,
1188 &pConfig->SapHw_mode);
1189 }
1190
1191 if( pConfig->channel > 14 )
1192 {
1193 pConfig->SapHw_mode= eSAP_DOT11_MODE_11a;
1194 }
1195
1196 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
1197 WLAN_EID_HT_CAPABILITY);
1198
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301199 if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 {
1201 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n;
1202 if(require_ht)
1203 pConfig->SapHw_mode= eSAP_DOT11_MODE_11n_ONLY;
1204 }
1205}
1206
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301207static int wlan_hdd_add_ie(hdd_adapter_t* pHostapdAdapter, v_U8_t *genie,
1208 v_U8_t *total_ielen, v_U8_t *oui, v_U8_t oui_size)
1209{
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001210 v_U16_t ielen = 0;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301211 v_U8_t *pIe = NULL;
1212 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1213
1214 pIe = wlan_hdd_get_vendor_oui_ie_ptr(oui, oui_size,
1215 pBeacon->tail, pBeacon->tail_len);
1216
1217 if (pIe)
1218 {
1219 ielen = pIe[1] + 2;
1220 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1221 {
1222 vos_mem_copy(&genie[*total_ielen], pIe, ielen);
1223 }
1224 else
1225 {
1226 hddLog( VOS_TRACE_LEVEL_ERROR, "**Ie Length is too big***");
1227 return -EINVAL;
1228 }
1229 *total_ielen += ielen;
1230 }
1231 return 0;
1232}
1233
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001234static void wlan_hdd_add_hostapd_conf_vsie(hdd_adapter_t* pHostapdAdapter,
1235 v_U8_t *genie, v_U8_t *total_ielen)
1236{
1237 beacon_data_t *pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1238 int left = pBeacon->tail_len;
1239 v_U8_t *ptr = pBeacon->tail;
1240 v_U8_t elem_id, elem_len;
1241 v_U16_t ielen = 0;
1242
1243 if ( NULL == ptr || 0 == left )
1244 return;
1245
1246 while (left >= 2)
1247 {
1248 elem_id = ptr[0];
1249 elem_len = ptr[1];
1250 left -= 2;
1251 if (elem_len > left)
1252 {
1253 hddLog( VOS_TRACE_LEVEL_ERROR,
1254 "****Invalid IEs eid = %d elem_len=%d left=%d*****",
1255 elem_id, elem_len, left);
1256 return;
1257 }
1258 if (IE_EID_VENDOR == elem_id)
1259 {
1260 /* skipping the VSIE's which we don't want to include or
1261 * it will be included by existing code
1262 */
1263 if ((memcmp( &ptr[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) != 0 ) &&
1264#ifdef WLAN_FEATURE_WFD
1265 (memcmp( &ptr[2], WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE) != 0) &&
1266#endif
1267 (memcmp( &ptr[2], WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1268 (memcmp( &ptr[2], BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1269 (memcmp( &ptr[2], "\x00\x50\xf2\x02", WPA_OUI_TYPE_SIZE) != 0) &&
1270 (memcmp( &ptr[2], WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE) != 0) &&
1271 (memcmp( &ptr[2], P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE) != 0))
1272 {
1273 ielen = ptr[1] + 2;
1274 if ((*total_ielen + ielen) <= MAX_GENIE_LEN)
1275 {
1276 vos_mem_copy(&genie[*total_ielen], ptr, ielen);
1277 *total_ielen += ielen;
1278 }
1279 else
1280 {
1281 hddLog( VOS_TRACE_LEVEL_ERROR,
1282 "IE Length is too big "
1283 "IEs eid=%d elem_len=%d total_ie_lent=%d",
1284 elem_id, elem_len, *total_ielen);
1285 }
1286 }
1287 }
1288
1289 left -= elem_len;
1290 ptr += (elem_len + 2);
1291 }
1292 return;
1293}
1294
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001295#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001296static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1297 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001298#else
1299static int wlan_hdd_cfg80211_update_apies(hdd_adapter_t* pHostapdAdapter,
1300 struct cfg80211_beacon_data *params)
1301#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001302{
1303 v_U8_t *genie;
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301304 v_U8_t total_ielen = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 v_U8_t addIE[1] = {0};
Jeff Johnsone7245742012-09-05 17:12:55 -07001306 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001307
1308 genie = vos_mem_malloc(MAX_GENIE_LEN);
1309
1310 if(genie == NULL) {
1311
1312 return -ENOMEM;
1313 }
1314
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301315 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1316 &total_ielen, WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301318 ret = -EINVAL;
1319 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 }
1321
1322#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301323 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1324 &total_ielen, WFD_OUI_TYPE, WFD_OUI_TYPE_SIZE))
1325 {
1326 ret = -EINVAL;
1327 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 }
1329#endif
1330
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301331 if (0 != wlan_hdd_add_ie(pHostapdAdapter, genie,
1332 &total_ielen, P2P_OUI_TYPE, P2P_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 {
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301334 ret = -EINVAL;
1335 goto done;
1336 }
1337
1338 if (WLAN_HDD_SOFTAP == pHostapdAdapter->device_mode)
1339 {
Arif Hussaine7f3ea52013-09-12 21:56:36 -07001340 wlan_hdd_add_hostapd_conf_vsie(pHostapdAdapter, genie, &total_ielen);
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001342
1343 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1344 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie, total_ielen, NULL,
1345 eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
1346 {
1347 hddLog(LOGE,
1348 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001349 ret = -EINVAL;
1350 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 }
1352
1353 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1354 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
1355 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1356 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1357 ==eHAL_STATUS_FAILURE)
1358 {
1359 hddLog(LOGE,
1360 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001361 ret = -EINVAL;
1362 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001363 }
1364
1365 // Added for ProResp IE
1366 if ( (params->proberesp_ies != NULL) && (params->proberesp_ies_len != 0) )
1367 {
1368 u16 rem_probe_resp_ie_len = params->proberesp_ies_len;
1369 u8 probe_rsp_ie_len[3] = {0};
1370 u8 counter = 0;
1371 /* Check Probe Resp Length if it is greater then 255 then Store
1372 Probe Resp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1 &
1373 WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are not able
1374 Store More then 255 bytes into One Variable.
1375 */
1376 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
1377 {
1378 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
1379 {
1380 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
1381 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
1382 }
1383 else
1384 {
1385 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
1386 rem_probe_resp_ie_len = 0;
1387 }
1388 }
1389
1390 rem_probe_resp_ie_len = 0;
1391
1392 if (probe_rsp_ie_len[0] > 0)
1393 {
1394 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1395 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
1396 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1397 probe_rsp_ie_len[0], NULL,
1398 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1399 {
1400 hddLog(LOGE,
1401 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001402 ret = -EINVAL;
1403 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 }
1405 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
1406 }
1407
1408 if (probe_rsp_ie_len[1] > 0)
1409 {
1410 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1411 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
1412 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1413 probe_rsp_ie_len[1], NULL,
1414 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1415 {
1416 hddLog(LOGE,
1417 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001418 ret = -EINVAL;
1419 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 }
1421 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
1422 }
1423
1424 if (probe_rsp_ie_len[2] > 0)
1425 {
1426 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1427 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
1428 (tANI_U8*)&params->proberesp_ies[rem_probe_resp_ie_len],
1429 probe_rsp_ie_len[2], NULL,
1430 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1431 {
1432 hddLog(LOGE,
1433 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001434 ret = -EINVAL;
1435 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 }
1437 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
1438 }
1439
1440 if (probe_rsp_ie_len[1] == 0 )
1441 {
1442 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1443 WNI_CFG_PROBE_RSP_ADDNIE_DATA2, (tANI_U8*)addIE, 0, NULL,
1444 eANI_BOOLEAN_FALSE) )
1445 {
1446 hddLog(LOGE,
1447 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM\n");
1448 }
1449 }
1450
1451 if (probe_rsp_ie_len[2] == 0 )
1452 {
1453 if ( eHAL_STATUS_FAILURE == ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1454 WNI_CFG_PROBE_RSP_ADDNIE_DATA3, (tANI_U8*)addIE, 0, NULL,
1455 eANI_BOOLEAN_FALSE) )
1456 {
1457 hddLog(LOGE,
1458 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM\n");
1459 }
1460 }
1461
1462 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1463 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
1464 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1465 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1466 == eHAL_STATUS_FAILURE)
1467 {
1468 hddLog(LOGE,
1469 "Could not pass on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001470 ret = -EINVAL;
1471 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001472 }
1473 }
1474 else
1475 {
1476 // Reset WNI_CFG_PROBE_RSP Flags
1477 wlan_hdd_reset_prob_rspies(pHostapdAdapter);
1478
1479 hddLog(VOS_TRACE_LEVEL_INFO,
1480 "%s: No Probe Response IE received in set beacon",
1481 __func__);
1482 }
1483
1484 // Added for AssocResp IE
1485 if ( (params->assocresp_ies != NULL) && (params->assocresp_ies_len != 0) )
1486 {
1487 if (ccmCfgSetStr((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1488 WNI_CFG_ASSOC_RSP_ADDNIE_DATA, (tANI_U8*)params->assocresp_ies,
1489 params->assocresp_ies_len, NULL,
1490 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
1491 {
1492 hddLog(LOGE,
1493 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_DATA to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001494 ret = -EINVAL;
1495 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001496 }
1497
1498 if (ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1499 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 1, NULL,
1500 test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags) ?
1501 eANI_BOOLEAN_TRUE : eANI_BOOLEAN_FALSE)
1502 == eHAL_STATUS_FAILURE)
1503 {
1504 hddLog(LOGE,
1505 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM");
Jeff Johnsone7245742012-09-05 17:12:55 -07001506 ret = -EINVAL;
1507 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 }
1509 }
1510 else
1511 {
1512 hddLog(VOS_TRACE_LEVEL_INFO,
1513 "%s: No Assoc Response IE received in set beacon",
1514 __func__);
1515
1516 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt((WLAN_HDD_GET_CTX(pHostapdAdapter))->hHal,
1517 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
1518 eANI_BOOLEAN_FALSE) )
1519 {
1520 hddLog(LOGE,
1521 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
1522 }
1523 }
1524
Jeff Johnsone7245742012-09-05 17:12:55 -07001525done:
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 vos_mem_free(genie);
Gopichand Nakkala2b25f4e2013-03-21 19:14:07 +05301527 return ret;
Jeff Johnson295189b2012-06-20 16:38:30 -07001528}
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301530/*
Jeff Johnson295189b2012-06-20 16:38:30 -07001531 * FUNCTION: wlan_hdd_validate_operation_channel
1532 * called by wlan_hdd_cfg80211_start_bss() and
1533 * wlan_hdd_cfg80211_set_channel()
1534 * This function validates whether given channel is part of valid
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301535 * channel list.
1536 */
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001537VOS_STATUS wlan_hdd_validate_operation_channel(hdd_adapter_t *pAdapter,int channel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001538{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301539
Jeff Johnson295189b2012-06-20 16:38:30 -07001540 v_U32_t num_ch = 0;
1541 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
1542 u32 indx = 0;
1543 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301544 v_U8_t fValidChannel = FALSE, count = 0;
1545 hdd_config_t *hdd_pConfig_ini= (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301546
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1548
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301549 if ( hdd_pConfig_ini->sapAllowAllChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301551 /* Validate the channel */
1552 for (count = RF_CHAN_1 ; count <= RF_CHAN_165 ; count++)
Jeff Johnson295189b2012-06-20 16:38:30 -07001553 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301554 if ( channel == rfChannels[count].channelNum )
1555 {
1556 fValidChannel = TRUE;
1557 break;
1558 }
1559 }
1560 if (fValidChannel != TRUE)
1561 {
1562 hddLog(VOS_TRACE_LEVEL_ERROR,
1563 "%s: Invalid Channel [%d]", __func__, channel);
1564 return VOS_STATUS_E_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 }
1566 }
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301567 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001568 {
Madan Mohan Koyylamudi64267f72013-02-05 14:07:08 +05301569 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
1570 valid_ch, &num_ch))
1571 {
1572 hddLog(VOS_TRACE_LEVEL_ERROR,
1573 "%s: failed to get valid channel list", __func__);
1574 return VOS_STATUS_E_FAILURE;
1575 }
1576 for (indx = 0; indx < num_ch; indx++)
1577 {
1578 if (channel == valid_ch[indx])
1579 {
1580 break;
1581 }
1582 }
1583
1584 if (indx >= num_ch)
1585 {
1586 hddLog(VOS_TRACE_LEVEL_ERROR,
1587 "%s: Invalid Channel [%d]", __func__, channel);
1588 return VOS_STATUS_E_FAILURE;
1589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 }
1591 return VOS_STATUS_SUCCESS;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301592
Jeff Johnson295189b2012-06-20 16:38:30 -07001593}
1594
Viral Modi3a32cc52013-02-08 11:14:52 -08001595/**
1596 * FUNCTION: wlan_hdd_cfg80211_set_channel
1597 * This function is used to set the channel number
1598 */
1599static int wlan_hdd_cfg80211_set_channel( struct wiphy *wiphy, struct net_device *dev,
1600 struct ieee80211_channel *chan,
1601 enum nl80211_channel_type channel_type
1602 )
1603{
1604 v_U32_t num_ch = 0;
Jeff Johnson4416a782013-03-25 14:17:50 -07001605 int channel = 0;
Viral Modi3a32cc52013-02-08 11:14:52 -08001606 hdd_adapter_t *pAdapter = NULL;
1607 int freq = chan->center_freq; /* freq is in MHZ */
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301608 hdd_context_t *pHddCtx;
1609 int status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001610
1611 ENTER();
1612
1613 if( NULL == dev )
1614 {
1615 hddLog(VOS_TRACE_LEVEL_ERROR,
1616 "%s: Called with dev = NULL.\n", __func__);
1617 return -ENODEV;
1618 }
1619 pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
1620
1621 hddLog(VOS_TRACE_LEVEL_INFO,
1622 "%s: device_mode = %d freq = %d \n",__func__,
1623 pAdapter->device_mode, chan->center_freq);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301624
1625 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1626 status = wlan_hdd_validate_context(pHddCtx);
1627
1628 if (0 != status)
Viral Modi3a32cc52013-02-08 11:14:52 -08001629 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1631 "%s: HDD context is not valid", __func__);
1632 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001633 }
1634
1635 /*
1636 * Do freq to chan conversion
1637 * TODO: for 11a
1638 */
1639
1640 channel = ieee80211_frequency_to_channel(freq);
1641
1642 /* Check freq range */
1643 if ((WNI_CFG_CURRENT_CHANNEL_STAMIN > channel) ||
1644 (WNI_CFG_CURRENT_CHANNEL_STAMAX < channel))
1645 {
1646 hddLog(VOS_TRACE_LEVEL_ERROR,
1647 "%s: Channel [%d] is outside valid range from %d to %d\n",
1648 __func__, channel, WNI_CFG_CURRENT_CHANNEL_STAMIN,
1649 WNI_CFG_CURRENT_CHANNEL_STAMAX);
1650 return -EINVAL;
1651 }
1652
1653 num_ch = WNI_CFG_VALID_CHANNEL_LIST_LEN;
1654
Gopichand Nakkala6ab19562013-03-07 13:59:42 +05301655 if ((WLAN_HDD_SOFTAP != pAdapter->device_mode) &&
1656 (WLAN_HDD_P2P_GO != pAdapter->device_mode))
Viral Modi3a32cc52013-02-08 11:14:52 -08001657 {
1658 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pAdapter,channel))
1659 {
1660 hddLog(VOS_TRACE_LEVEL_ERROR,
1661 "%s: Invalid Channel [%d] \n", __func__, channel);
1662 return -EINVAL;
1663 }
1664 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1665 "%s: set channel to [%d] for device mode =%d",
1666 __func__, channel,pAdapter->device_mode);
1667 }
1668 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Viral Modi3a32cc52013-02-08 11:14:52 -08001669 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Viral Modi3a32cc52013-02-08 11:14:52 -08001670 )
1671 {
1672 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
1673 tCsrRoamProfile * pRoamProfile = &pWextState->roamProfile;
1674 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1675
1676 if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState)
1677 {
1678 /* Link is up then return cant set channel*/
1679 hddLog( VOS_TRACE_LEVEL_ERROR,
1680 "%s: IBSS Associated, can't set the channel\n", __func__);
1681 return -EINVAL;
1682 }
1683
1684 num_ch = pRoamProfile->ChannelInfo.numOfChannels = 1;
1685 pHddStaCtx->conn_info.operationChannel = channel;
1686 pRoamProfile->ChannelInfo.ChannelList =
1687 &pHddStaCtx->conn_info.operationChannel;
1688 }
1689 else if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Viral Modi3a32cc52013-02-08 11:14:52 -08001690 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Viral Modi3a32cc52013-02-08 11:14:52 -08001691 )
1692 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301693 if (WLAN_HDD_P2P_GO == pAdapter->device_mode)
1694 {
1695 if(VOS_STATUS_SUCCESS !=
1696 wlan_hdd_validate_operation_channel(pAdapter,channel))
1697 {
1698 hddLog(VOS_TRACE_LEVEL_ERROR,
1699 "%s: Invalid Channel [%d] \n", __func__, channel);
1700 return -EINVAL;
1701 }
1702 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1703 }
1704 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
Viral Modi3a32cc52013-02-08 11:14:52 -08001705 {
1706 hdd_config_t *cfg_param = (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini;
1707
1708 /* If auto channel selection is configured as enable/ 1 then ignore
1709 channel set by supplicant
1710 */
1711 if ( cfg_param->apAutoChannelSelection )
1712 {
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301713 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel =
1714 AUTO_CHANNEL_SELECT;
Viral Modi3a32cc52013-02-08 11:14:52 -08001715 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1716 "%s: set channel to auto channel (0) for device mode =%d",
1717 __func__, pAdapter->device_mode);
1718 }
Gopichand Nakkalac8fa7b62013-03-11 13:56:41 +05301719 else
1720 {
1721 if(VOS_STATUS_SUCCESS !=
1722 wlan_hdd_validate_operation_channel(pAdapter,channel))
1723 {
1724 hddLog(VOS_TRACE_LEVEL_ERROR,
1725 "%s: Invalid Channel [%d] \n", __func__, channel);
1726 return -EINVAL;
1727 }
1728 (WLAN_HDD_GET_AP_CTX_PTR(pAdapter))->sapConfig.channel = channel;
1729 }
Viral Modi3a32cc52013-02-08 11:14:52 -08001730 }
1731 }
1732 else
1733 {
1734 hddLog(VOS_TRACE_LEVEL_FATAL,
1735 "%s: Invalid device mode failed to set valid channel", __func__);
1736 return -EINVAL;
1737 }
1738 EXIT();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05301739 return status;
Viral Modi3a32cc52013-02-08 11:14:52 -08001740}
1741
Jeff Johnson295189b2012-06-20 16:38:30 -07001742#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
1743static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1744 struct beacon_parameters *params)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001745#else
1746static int wlan_hdd_cfg80211_start_bss(hdd_adapter_t *pHostapdAdapter,
1747 struct cfg80211_beacon_data *params,
1748 const u8 *ssid, size_t ssid_len,
1749 enum nl80211_hidden_ssid hidden_ssid)
1750#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001751{
1752 tsap_Config_t *pConfig;
1753 beacon_data_t *pBeacon = NULL;
1754 struct ieee80211_mgmt *pMgmt_frame;
1755 v_U8_t *pIe=NULL;
1756 v_U16_t capab_info;
1757 eCsrAuthType RSNAuthType;
1758 eCsrEncryptionType RSNEncryptType;
1759 eCsrEncryptionType mcRSNEncryptType;
1760 int status = VOS_STATUS_SUCCESS;
1761 tpWLAN_SAPEventCB pSapEventCallback;
1762 hdd_hostapd_state_t *pHostapdState;
1763 v_U8_t wpaRsnIEdata[(SIR_MAC_MAX_IE_LENGTH * 2)+4]; //Max ie length 255 * 2(WPA+RSN) + 2 bytes (vendor specific ID) * 2
1764 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pHostapdAdapter))->pvosContext;
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301765 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 struct qc_mac_acl_entry *acl_entry = NULL;
1767 v_SINT_t i;
Madan Mohan Koyyalamudi543172b2012-12-05 16:40:18 -08001768 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pHostapdAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001769
1770 ENTER();
1771
1772 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pHostapdAdapter);
1773
1774 pConfig = &pHostapdAdapter->sessionCtx.ap.sapConfig;
1775
1776 pBeacon = pHostapdAdapter->sessionCtx.ap.beacon;
1777
1778 pMgmt_frame = (struct ieee80211_mgmt*)pBeacon->head;
1779
1780 pConfig->beacon_int = pMgmt_frame->u.beacon.beacon_int;
1781
1782 //channel is already set in the set_channel Call back
1783 //pConfig->channel = pCommitConfig->channel;
1784
1785 /*Protection parameter to enable or disable*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301786 pConfig->protEnabled =
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtEnabled;
1788
1789 pConfig->dtim_period = pBeacon->dtim_period;
1790
1791 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"****pConfig->dtim_period=%d***\n",
1792 pConfig->dtim_period);
1793
1794
Madan Mohan Koyyalamudie0ca11f2012-11-27 15:57:52 -08001795 if (pHostapdAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson32d95a32012-09-10 13:15:23 -07001796 {
1797 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 WLAN_EID_COUNTRY);
Kiet Lam083504c2013-11-25 14:17:45 +05301799 if(memcmp(pHddCtx->cfg_ini->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0)
1800 {
1801 tANI_BOOLEAN restartNeeded;
1802 pConfig->ieee80211d = 1;
1803 vos_mem_copy(pConfig->countryCode, pHddCtx->cfg_ini->apCntryCode, 3);
1804 sme_setRegInfo(hHal, pConfig->countryCode);
1805 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
1806 }
1807 else if(pIe)
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 {
Jeff Johnson32d95a32012-09-10 13:15:23 -07001809 tANI_BOOLEAN restartNeeded;
Jeff Johnson32d95a32012-09-10 13:15:23 -07001810 pConfig->ieee80211d = 1;
1811 vos_mem_copy(pConfig->countryCode, &pIe[2], 3);
1812 sme_setRegInfo(hHal, pConfig->countryCode);
1813 sme_ResetCountryCodeInformation(hHal, &restartNeeded);
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001815 else
1816 {
1817 pConfig->ieee80211d = 0;
1818 }
Madan Mohan Koyylamudia16d0202013-02-01 11:05:57 +05301819 /*
1820 * If auto channel is configured i.e. channel is 0,
1821 * so skip channel validation.
1822 */
1823 if( AUTO_CHANNEL_SELECT != pConfig->channel )
1824 {
1825 if(VOS_STATUS_SUCCESS != wlan_hdd_validate_operation_channel(pHostapdAdapter,pConfig->channel))
1826 {
1827 hddLog(VOS_TRACE_LEVEL_ERROR,
1828 "%s: Invalid Channel [%d] \n", __func__, pConfig->channel);
1829 return -EINVAL;
1830 }
1831 }
1832 else
1833 {
1834 if(1 != pHddCtx->is_dynamic_channel_range_set)
1835 {
1836 hdd_config_t *hdd_pConfig= (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini;
1837 WLANSAP_SetChannelRange(hHal, hdd_pConfig->apStartChannelNum,
1838 hdd_pConfig->apEndChannelNum,hdd_pConfig->apOperatingBand);
1839 }
1840 pHddCtx->is_dynamic_channel_range_set = 0;
1841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07001843 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001844 {
1845 pConfig->ieee80211d = 0;
1846 }
1847 pConfig->authType = eSAP_AUTO_SWITCH;
1848
1849 capab_info = pMgmt_frame->u.beacon.capab_info;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301850
1851 pConfig->privacy = (pMgmt_frame->u.beacon.capab_info &
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 WLAN_CAPABILITY_PRIVACY) ? VOS_TRUE : VOS_FALSE;
1853
1854 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->uPrivacy = pConfig->privacy;
1855
1856 /*Set wps station to configured*/
1857 pIe = wlan_hdd_get_wps_ie_ptr(pBeacon->tail, pBeacon->tail_len);
1858
1859 if(pIe)
1860 {
1861 if(pIe[1] < (2 + WPS_OUI_TYPE_SIZE))
1862 {
1863 hddLog( VOS_TRACE_LEVEL_ERROR, "**Wps Ie Length is too small***\n");
1864 return -EINVAL;
1865 }
1866 else if(memcmp(&pIe[2], WPS_OUI_TYPE, WPS_OUI_TYPE_SIZE) == 0)
1867 {
Madan Mohan Koyyalamudi8bdd3112012-09-24 13:55:14 -07001868 hddLog( VOS_TRACE_LEVEL_INFO, "** WPS IE(len %d) ***", (pIe[1]+2));
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 /* Check 15 bit of WPS IE as it contain information for wps state
1870 * WPS state
1871 */
1872 if(SAP_WPS_ENABLED_UNCONFIGURED == pIe[15])
1873 {
1874 pConfig->wps_state = SAP_WPS_ENABLED_UNCONFIGURED;
1875 } else if(SAP_WPS_ENABLED_CONFIGURED == pIe[15])
1876 {
1877 pConfig->wps_state = SAP_WPS_ENABLED_CONFIGURED;
1878 }
1879 }
1880 }
1881 else
1882 {
1883 pConfig->wps_state = SAP_WPS_DISABLED;
1884 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301885 pConfig->fwdWPSPBCProbeReq = 1; // Forward WPS PBC probe request frame up
Jeff Johnson295189b2012-06-20 16:38:30 -07001886
1887 pConfig->RSNWPAReqIELength = 0;
1888 pConfig->pRSNWPAReqIE = NULL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301889 pIe = wlan_hdd_cfg80211_get_ie_ptr(pBeacon->tail, pBeacon->tail_len,
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 WLAN_EID_RSN);
1891 if(pIe && pIe[1])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301892 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001893 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1894 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1895 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301896 /* The actual processing may eventually be more extensive than
1897 * this. Right now, just consume any PMKIDs that are sent in
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 * by the app.
1899 * */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301900 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1902 &RSNEncryptType,
1903 &mcRSNEncryptType,
1904 &RSNAuthType,
1905 pConfig->pRSNWPAReqIE[1]+2,
1906 pConfig->pRSNWPAReqIE );
1907
1908 if( VOS_STATUS_SUCCESS == status )
1909 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301910 /* Now copy over all the security attributes you have
1911 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 * */
1913 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1914 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1915 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1916 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301917 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 "EncryptionType = %d mcEncryptionType = %d\n"),
1919 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1920 }
1921 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301922
Jeff Johnson295189b2012-06-20 16:38:30 -07001923 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WPA_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1924 pBeacon->tail, pBeacon->tail_len);
1925
1926 if(pIe && pIe[1] && (pIe[0] == DOT11F_EID_WPA))
1927 {
1928 if (pConfig->pRSNWPAReqIE)
1929 {
1930 /*Mixed mode WPA/WPA2*/
1931 memcpy((&wpaRsnIEdata[0] + pConfig->RSNWPAReqIELength), pIe, pIe[1] + 2);
1932 pConfig->RSNWPAReqIELength += pIe[1] + 2;
1933 }
1934 else
1935 {
1936 pConfig->RSNWPAReqIELength = pIe[1] + 2;
1937 memcpy(&wpaRsnIEdata[0], pIe, pConfig->RSNWPAReqIELength);
1938 pConfig->pRSNWPAReqIE = &wpaRsnIEdata[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301939 status = hdd_softap_unpackIE(
Jeff Johnson295189b2012-06-20 16:38:30 -07001940 vos_get_context( VOS_MODULE_ID_SME, pVosContext),
1941 &RSNEncryptType,
1942 &mcRSNEncryptType,
1943 &RSNAuthType,
1944 pConfig->pRSNWPAReqIE[1]+2,
1945 pConfig->pRSNWPAReqIE );
1946
1947 if( VOS_STATUS_SUCCESS == status )
1948 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301949 /* Now copy over all the security attributes you have
1950 * parsed out
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 * */
1952 pConfig->RSNEncryptType = RSNEncryptType; // Use the cipher type in the RSN IE
1953 pConfig->mcRSNEncryptType = mcRSNEncryptType;
1954 (WLAN_HDD_GET_AP_CTX_PTR(pHostapdAdapter))->ucEncryptType
1955 = RSNEncryptType;
Gopichand Nakkala66c0bd02013-04-10 11:36:29 +05301956 hddLog( LOG1, FL("CSR AuthType = %d, "
Jeff Johnson295189b2012-06-20 16:38:30 -07001957 "EncryptionType = %d mcEncryptionType = %d\n"),
1958 RSNAuthType, RSNEncryptType, mcRSNEncryptType);
1959 }
1960 }
1961 }
1962
Jeff Johnson4416a782013-03-25 14:17:50 -07001963 if (pConfig->RSNWPAReqIELength > sizeof wpaRsnIEdata) {
1964 hddLog( VOS_TRACE_LEVEL_ERROR, "**RSNWPAReqIELength is too large***");
1965 return -EINVAL;
1966 }
1967
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 pConfig->SSIDinfo.ssidHidden = VOS_FALSE;
1969
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001970#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 if (params->ssid != NULL)
1972 {
1973 memcpy(pConfig->SSIDinfo.ssid.ssId, params->ssid, params->ssid_len);
1974 pConfig->SSIDinfo.ssid.length = params->ssid_len;
1975 if (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1976 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1977 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001978#else
1979 if (ssid != NULL)
1980 {
1981 memcpy(pConfig->SSIDinfo.ssid.ssId, ssid, ssid_len);
1982 pConfig->SSIDinfo.ssid.length = ssid_len;
1983 if (hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE)
1984 pConfig->SSIDinfo.ssidHidden = VOS_TRUE;
1985 }
1986#endif
1987
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301988 vos_mem_copy(pConfig->self_macaddr.bytes,
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 pHostapdAdapter->macAddressCurrent.bytes, sizeof(v_MACADDR_t));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05301990
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 /* default value */
1992 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
1993 pConfig->num_accept_mac = 0;
1994 pConfig->num_deny_mac = 0;
1995
1996 pIe = wlan_hdd_get_vendor_oui_ie_ptr(BLACKLIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
1997 pBeacon->tail, pBeacon->tail_len);
1998
1999 /* pIe for black list is following form:
2000 type : 1 byte
2001 length : 1 byte
2002 OUI : 4 bytes
2003 acl type : 1 byte
2004 no of mac addr in black list: 1 byte
2005 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302006 */
2007 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 {
2009 pConfig->SapMacaddr_acl = pIe[6];
2010 pConfig->num_deny_mac = pIe[7];
2011 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no deny mac = %d\n",
2012 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302013 if (pConfig->num_deny_mac > MAX_ACL_MAC_ADDRESS)
2014 pConfig->num_deny_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002015 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2016 for (i = 0; i < pConfig->num_deny_mac; i++)
2017 {
2018 vos_mem_copy(&pConfig->deny_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2019 acl_entry++;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 }
2022 pIe = wlan_hdd_get_vendor_oui_ie_ptr(WHITELIST_OUI_TYPE, WPA_OUI_TYPE_SIZE,
2023 pBeacon->tail, pBeacon->tail_len);
2024
2025 /* pIe for white list is following form:
2026 type : 1 byte
2027 length : 1 byte
2028 OUI : 4 bytes
2029 acl type : 1 byte
2030 no of mac addr in white list: 1 byte
2031 list of mac_acl_entries: variable, 6 bytes per mac address + sizeof(int) for vlan id
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302032 */
2033 if ((pIe != NULL) && (pIe[1] != 0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 {
2035 pConfig->SapMacaddr_acl = pIe[6];
2036 pConfig->num_accept_mac = pIe[7];
2037 hddLog(VOS_TRACE_LEVEL_INFO,"acl type = %d no accept mac = %d\n",
2038 pIe[6], pIe[7]);
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302039 if (pConfig->num_accept_mac > MAX_ACL_MAC_ADDRESS)
2040 pConfig->num_accept_mac = MAX_ACL_MAC_ADDRESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 acl_entry = (struct qc_mac_acl_entry *)(pIe + 8);
2042 for (i = 0; i < pConfig->num_accept_mac; i++)
2043 {
2044 vos_mem_copy(&pConfig->accept_mac[i], acl_entry->addr, sizeof(qcmacaddr));
2045 acl_entry++;
2046 }
2047 }
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05302048
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 wlan_hdd_set_sapHwmode(pHostapdAdapter);
2050
Jeff Johnsone7245742012-09-05 17:12:55 -07002051#ifdef WLAN_FEATURE_11AC
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002052 /* Overwrite the hostapd setting for HW mode only for 11ac.
Kiet Lam0f320422013-11-21 19:29:17 +05302053 * This is valid only if mode is set to 11n in hostapd, either AUTO or
2054 * 11ac in .ini and 11ac is supported by both host and firmware.
2055 * Otherwise, leave whatever is set in hostapd (a OR b OR g OR n mode)
2056 */
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002057 if( ((pConfig->SapHw_mode == eSAP_DOT11_MODE_11n) ||
2058 (pConfig->SapHw_mode == eSAP_DOT11_MODE_11n_ONLY)) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302059 (((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_AUTO) ||
Ravi Kumar Vaishnavbbaebbe2013-01-15 17:09:48 -08002060 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac) ||
Kiet Lam0f320422013-11-21 19:29:17 +05302061 ((WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->dot11Mode == eHDD_DOT11_MODE_11ac_ONLY)) &&
2062 (sme_IsFeatureSupportedByDriver(DOT11AC)) && (sme_IsFeatureSupportedByFW(DOT11AC)) )
Jeff Johnsone7245742012-09-05 17:12:55 -07002063 {
2064 pConfig->SapHw_mode = eSAP_DOT11_MODE_11ac;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002065
2066 /* Disable VHT support in 2.4 GHz band */
2067 if (pConfig->channel <= 14 &&
2068 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->enableVhtFor24GHzBand == FALSE)
2069 {
2070 pConfig->SapHw_mode = eSAP_DOT11_MODE_11n;
2071 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002072 }
2073#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302074
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07002075 if ( AUTO_CHANNEL_SELECT != pConfig->channel )
2076 {
2077 sme_SelectCBMode(hHal,
2078 sapConvertSapPhyModeToCsrPhyMode(pConfig->SapHw_mode),
2079 pConfig->channel);
2080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 // ht_capab is not what the name conveys,this is used for protection bitmap
2082 pConfig->ht_capab =
2083 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apProtection;
2084
2085 if ( 0 != wlan_hdd_cfg80211_update_apies(pHostapdAdapter, params) )
2086 {
2087 hddLog(LOGE, FL("SAP Not able to set AP IEs"));
2088 return -EINVAL;
2089 }
2090
2091 //Uapsd Enabled Bit
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302092 pConfig->UapsdEnable =
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apUapsdEnabled;
2094 //Enable OBSS protection
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302095 pConfig->obssProtEnabled =
2096 (WLAN_HDD_GET_CTX(pHostapdAdapter))->cfg_ini->apOBSSProtEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07002097
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302098 hddLog(LOGW, FL("SOftAP macaddress : "MAC_ADDRESS_STR"\n"),
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 MAC_ADDR_ARRAY(pHostapdAdapter->macAddressCurrent.bytes));
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302100 hddLog(LOGW,FL("ssid =%s\n"), pConfig->SSIDinfo.ssid.ssId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002101 hddLog(LOGW,FL("beaconint=%d, channel=%d\n"), (int)pConfig->beacon_int,
2102 (int)pConfig->channel);
2103 hddLog(LOGW,FL("hw_mode=%x\n"), pConfig->SapHw_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302104 hddLog(LOGW,FL("privacy=%d, authType=%d\n"), pConfig->privacy,
2105 pConfig->authType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 hddLog(LOGW,FL("RSN/WPALen=%d, \n"),(int)pConfig->RSNWPAReqIELength);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302107 hddLog(LOGW,FL("Uapsd = %d\n"),pConfig->UapsdEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 hddLog(LOGW,FL("ProtEnabled = %d, OBSSProtEnabled = %d\n"),
2109 pConfig->protEnabled, pConfig->obssProtEnabled);
2110
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302111 if(test_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags))
Jeff Johnson295189b2012-06-20 16:38:30 -07002112 {
2113 //Bss already started. just return.
2114 //TODO Probably it should update some beacon params.
2115 hddLog( LOGE, "Bss Already started...Ignore the request");
2116 EXIT();
2117 return 0;
2118 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302119
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 pConfig->persona = pHostapdAdapter->device_mode;
2121
2122 pSapEventCallback = hdd_hostapd_SAPEventCB;
2123 if(WLANSAP_StartBss(pVosContext, pSapEventCallback, pConfig,
2124 (v_PVOID_t)pHostapdAdapter->dev) != VOS_STATUS_SUCCESS)
2125 {
2126 hddLog(LOGE,FL("SAP Start Bss fail\n"));
2127 return -EINVAL;
2128 }
2129
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302130 hddLog(LOG1,
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 FL("Waiting for Scan to complete(auto mode) and BSS to start"));
2132
2133 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302134
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 if (!VOS_IS_STATUS_SUCCESS(status))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302136 {
2137 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07002138 ("ERROR: HDD vos wait for single_event failed!!\n"));
Tushnim Bhattacharyyaad37df12013-10-02 12:01:33 -07002139 smeGetCommandQStatus(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002140 VOS_ASSERT(0);
2141 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302142
Jeff Johnson295189b2012-06-20 16:38:30 -07002143 //Succesfully started Bss update the state bit.
2144 set_bit(SOFTAP_BSS_STARTED, &pHostapdAdapter->event_flags);
2145
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002146#ifdef WLAN_FEATURE_P2P_DEBUG
2147 if (pHostapdAdapter->device_mode == WLAN_HDD_P2P_GO)
2148 {
2149 if(globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED)
2150 {
2151 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2152 hddLog(LOGE,"[P2P State] From Go nego completed to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002153 "Non-autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002154 }
2155 else if(globalP2PConnectionStatus == P2P_NOT_ACTIVE)
2156 {
2157 globalP2PConnectionStatus = P2P_GO_COMPLETED_STATE;
2158 hddLog(LOGE,"[P2P State] From Inactive to "
Jeff Johnson1250df42012-12-10 14:31:52 -08002159 "Autonomous Group started");
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002160 }
2161 }
2162#endif
2163
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 pHostapdState->bCommit = TRUE;
2165 EXIT();
2166
2167 return 0;
2168}
2169
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002170#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302171static int wlan_hdd_cfg80211_add_beacon(struct wiphy *wiphy,
2172 struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 struct beacon_parameters *params)
2174{
2175 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302176 hdd_context_t *pHddCtx;
2177 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002178
2179 ENTER();
2180
2181 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "device mode=%d\n",pAdapter->device_mode);
2182
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302183 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2184 status = wlan_hdd_validate_context(pHddCtx);
2185
2186 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002187 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2189 "%s: HDD context is not valid", __func__);
2190 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002191 }
2192
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302193 if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 )
2196 {
2197 beacon_data_t *old,*new;
2198
2199 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302200
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 if (old)
2202 return -EALREADY;
2203
2204 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2205
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302206 if(status != VOS_STATUS_SUCCESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 {
2208 hddLog(VOS_TRACE_LEVEL_FATAL,
2209 "%s:Error!!! Allocating the new beacon\n",__func__);
2210 return -EINVAL;
2211 }
2212
2213 pAdapter->sessionCtx.ap.beacon = new;
2214
2215 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2216 }
2217
2218 EXIT();
2219 return status;
2220}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302221
2222static int wlan_hdd_cfg80211_set_beacon(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 struct net_device *dev,
2224 struct beacon_parameters *params)
2225{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302226 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302227 hdd_context_t *pHddCtx;
2228 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002229
2230 ENTER();
2231
2232 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2233 __func__,pAdapter->device_mode);
2234
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302235 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2236 status = wlan_hdd_validate_context(pHddCtx);
2237
2238 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002239 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2241 "%s: HDD context is not valid", __func__);
2242 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002243 }
2244
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302245 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302247 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002248 {
2249 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302250
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302252
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 if (!old)
2254 return -ENOENT;
2255
2256 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter,&new,params);
2257
2258 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302259 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 "%s: Error!!! Allocating the new beacon\n",__func__);
2261 return -EINVAL;
2262 }
2263
2264 pAdapter->sessionCtx.ap.beacon = new;
2265
2266 status = wlan_hdd_cfg80211_start_bss(pAdapter, params);
2267 }
2268
2269 EXIT();
2270 return status;
2271}
2272
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002273#endif //(LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
2274
2275#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07002276static int wlan_hdd_cfg80211_del_beacon(struct wiphy *wiphy,
2277 struct net_device *dev)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002278#else
2279static int wlan_hdd_cfg80211_stop_ap (struct wiphy *wiphy,
2280 struct net_device *dev)
2281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002282{
2283 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Jeff Johnsone7245742012-09-05 17:12:55 -07002284 hdd_context_t *pHddCtx = NULL;
2285 hdd_scaninfo_t *pScanInfo = NULL;
2286 hdd_adapter_t *staAdapter = NULL;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302287 VOS_STATUS status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002288
2289 ENTER();
2290
2291 if (NULL == pAdapter)
2292 {
2293 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002294 "%s: HDD adapter context is Null", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 return -ENODEV;
2296 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002297
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302298 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2299 status = wlan_hdd_validate_context(pHddCtx);
2300
2301 if (0 != status)
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002302 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302303 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2304 "%s: HDD context is not valid", __func__);
2305 return status;
Jeff Johnson4416a782013-03-25 14:17:50 -07002306 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002307
2308 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_INFRA_STATION);
2309 if (NULL == staAdapter)
2310 {
2311 staAdapter = hdd_get_adapter(pAdapter->pHddCtx, WLAN_HDD_P2P_CLIENT);
2312 if (NULL == staAdapter)
2313 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2315 "%s: HDD adapter context for STA/P2P-CLI is Null",
2316 __func__);
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07002317 }
2318 }
2319
2320 pScanInfo = &pHddCtx->scan_info;
2321
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2323 __func__,pAdapter->device_mode);
2324
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002325 if ((pScanInfo != NULL) && pScanInfo->mScanPending && staAdapter)
Jeff Johnsone7245742012-09-05 17:12:55 -07002326 {
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002327 INIT_COMPLETION(pScanInfo->abortscan_event_var);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05302328 hdd_abort_mac_scan(staAdapter->pHddCtx, pAdapter->sessionId);
Jeff Johnsone7245742012-09-05 17:12:55 -07002329 status = wait_for_completion_interruptible_timeout(
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08002330 &pScanInfo->abortscan_event_var,
Jeff Johnsone7245742012-09-05 17:12:55 -07002331 msecs_to_jiffies(WLAN_WAIT_TIME_ABORTSCAN));
2332 if (!status)
2333 {
Rajesh Chauhan52d885b2013-11-01 10:54:25 -07002334 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson902c9832012-12-10 14:28:09 -08002335 "%s: Timeout occurred while waiting for abortscan" ,
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002336 __func__);
Jeff Johnsone7245742012-09-05 17:12:55 -07002337 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07002338 }
2339 }
2340
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002342 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 )
2344 {
2345 beacon_data_t *old;
2346
2347 old = pAdapter->sessionCtx.ap.beacon;
2348
2349 if (!old)
2350 return -ENOENT;
2351
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 hdd_cleanup_actionframe(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353
2354 mutex_lock(&pHddCtx->sap_lock);
2355 if(test_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags))
2356 {
Jeff Johnson4416a782013-03-25 14:17:50 -07002357 if ( VOS_STATUS_SUCCESS == (status = WLANSAP_StopBss(pHddCtx->pvosContext) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 {
2359 hdd_hostapd_state_t *pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
2360
2361 status = vos_wait_single_event(&pHostapdState->vosEvent, 10000);
2362
2363 if (!VOS_IS_STATUS_SUCCESS(status))
2364 {
2365 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2366 ("ERROR: HDD vos wait for single_event failed!!\n"));
2367 VOS_ASSERT(0);
2368 }
2369 }
2370 clear_bit(SOFTAP_BSS_STARTED, &pAdapter->event_flags);
2371 }
2372 mutex_unlock(&pHddCtx->sap_lock);
2373
2374 if(status != VOS_STATUS_SUCCESS)
2375 {
2376 hddLog(VOS_TRACE_LEVEL_FATAL,
2377 "%s:Error!!! Stopping the BSS\n",__func__);
2378 return -EINVAL;
2379 }
2380
Jeff Johnson4416a782013-03-25 14:17:50 -07002381 if (ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 0,NULL, eANI_BOOLEAN_FALSE)
2383 ==eHAL_STATUS_FAILURE)
2384 {
2385 hddLog(LOGE,
2386 "Could not pass on WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM\n");
2387 }
2388
Jeff Johnson4416a782013-03-25 14:17:50 -07002389 if ( eHAL_STATUS_FAILURE == ccmCfgSetInt(pHddCtx->hHal,
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 WNI_CFG_ASSOC_RSP_ADDNIE_FLAG, 0, NULL,
2391 eANI_BOOLEAN_FALSE) )
2392 {
2393 hddLog(LOGE,
2394 "Could not pass on WNI_CFG_ASSOC_RSP_ADDNIE_FLAG to CCM\n");
2395 }
2396
2397 // Reset WNI_CFG_PROBE_RSP Flags
2398 wlan_hdd_reset_prob_rspies(pAdapter);
2399
2400 pAdapter->sessionCtx.ap.beacon = NULL;
2401 kfree(old);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07002402#ifdef WLAN_FEATURE_P2P_DEBUG
2403 if((pAdapter->device_mode == WLAN_HDD_P2P_GO) &&
2404 (globalP2PConnectionStatus == P2P_GO_COMPLETED_STATE))
2405 {
2406 hddLog(LOGE,"[P2P State] From GO completed to Inactive state "
2407 "GO got removed");
2408 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
2409 }
2410#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002411 }
2412 EXIT();
2413 return status;
2414}
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002415
2416#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2417
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302418static int wlan_hdd_cfg80211_start_ap(struct wiphy *wiphy,
2419 struct net_device *dev,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002420 struct cfg80211_ap_settings *params)
2421{
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302422 hdd_adapter_t *pAdapter;
2423 hdd_context_t *pHddCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302424 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002425
2426 ENTER();
2427
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302428 if (NULL == dev)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002429 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302430 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302431 "%s: Device is Null", __func__);
2432 return -ENODEV;
2433 }
2434
2435 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2436 if (NULL == pAdapter)
2437 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302438 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302439 "%s: HDD adapter is Null", __func__);
2440 return -ENODEV;
2441 }
2442
2443 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
2444 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302445 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302446 "%s: HDD adapter magic is invalid", __func__);
2447 return -ENODEV;
2448 }
2449
2450 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302451 status = wlan_hdd_validate_context(pHddCtx);
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302452
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302453 if (0 != status)
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302454 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2456 "%s: HDD context is not valid", __func__);
2457 return status;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302458 }
2459
2460 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device mode = %d",
2461 __func__, pAdapter->device_mode);
2462
2463 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002464 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002465 )
2466 {
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302467 beacon_data_t *old, *new;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002468
2469 old = pAdapter->sessionCtx.ap.beacon;
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302470
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002471 if (old)
2472 return -EALREADY;
2473
2474 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, &params->beacon, params->dtim_period);
2475
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302476 if (status != 0)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002477 {
2478 hddLog(VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgata0c7f262012-11-22 17:40:24 +05302479 "%s:Error!!! Allocating the new beacon", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002480 return -EINVAL;
2481 }
2482 pAdapter->sessionCtx.ap.beacon = new;
Viral Modi3a32cc52013-02-08 11:14:52 -08002483#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
Yue Maf49ba872013-08-19 12:04:25 -07002484 wlan_hdd_cfg80211_set_channel(wiphy, dev,
2485#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
2486 params->channel, params->channel_type);
2487#else
2488 params->chandef.chan, cfg80211_get_chandef_type(&(params->chandef)));
2489#endif
Viral Modi3a32cc52013-02-08 11:14:52 -08002490#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002491 status = wlan_hdd_cfg80211_start_bss(pAdapter, &params->beacon, params->ssid,
2492 params->ssid_len, params->hidden_ssid);
2493 }
2494
2495 EXIT();
2496 return status;
2497}
2498
2499
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302500static int wlan_hdd_cfg80211_change_beacon(struct wiphy *wiphy,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002501 struct net_device *dev,
2502 struct cfg80211_beacon_data *params)
2503{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302504 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302505 hdd_context_t *pHddCtx;
2506 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002507
2508 ENTER();
2509
2510 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2511 __func__, pAdapter->device_mode);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302512
2513 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2514 status = wlan_hdd_validate_context(pHddCtx);
2515
2516 if (0 != status)
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002517 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302518 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2519 "%s: HDD context is not valid", __func__);
2520 return status;
Madan Mohan Koyyalamudib2c36892012-10-18 20:52:38 -07002521 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002522
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302523 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002524 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302525 )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002526 {
2527 beacon_data_t *old,*new;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302528
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002529 old = pAdapter->sessionCtx.ap.beacon;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302530
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002531 if (!old)
2532 return -ENOENT;
2533
2534 status = wlan_hdd_cfg80211_alloc_new_beacon(pAdapter, &new, params, 0);
2535
2536 if(status != VOS_STATUS_SUCCESS) {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302537 hddLog(VOS_TRACE_LEVEL_FATAL,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002538 "%s: Error!!! Allocating the new beacon\n",__func__);
2539 return -EINVAL;
2540 }
2541
2542 pAdapter->sessionCtx.ap.beacon = new;
2543
2544 status = wlan_hdd_cfg80211_start_bss(pAdapter, params, NULL, 0, 0);
2545 }
2546
2547 EXIT();
2548 return status;
2549}
2550
2551#endif //(LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0))
2552
Jeff Johnson295189b2012-06-20 16:38:30 -07002553
2554static int wlan_hdd_cfg80211_change_bss (struct wiphy *wiphy,
2555 struct net_device *dev,
2556 struct bss_parameters *params)
2557{
2558 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2559
2560 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302561
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
2563 __func__,pAdapter->device_mode);
2564
2565 if((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002566 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302567 )
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 {
2569 /* ap_isolate == -1 means that in change bss, upper layer doesn't
2570 * want to update this parameter */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302571 if (-1 != params->ap_isolate)
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 {
2573 pAdapter->sessionCtx.ap.apDisableIntraBssFwd = !!params->ap_isolate;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 }
2576
2577 EXIT();
2578 return 0;
2579}
2580
Kiet Lam10841362013-11-01 11:36:50 +05302581/* FUNCTION: wlan_hdd_change_country_code_cd
2582* to wait for contry code completion
2583*/
2584void* wlan_hdd_change_country_code_cb(void *pAdapter)
2585{
2586 hdd_adapter_t *call_back_pAdapter = pAdapter;
2587 complete(&call_back_pAdapter->change_country_code);
2588 return NULL;
2589}
2590
Jeff Johnson295189b2012-06-20 16:38:30 -07002591/*
2592 * FUNCTION: wlan_hdd_cfg80211_change_iface
2593 * This function is used to set the interface type (INFRASTRUCTURE/ADHOC)
2594 */
2595int wlan_hdd_cfg80211_change_iface( struct wiphy *wiphy,
2596 struct net_device *ndev,
2597 enum nl80211_iftype type,
2598 u32 *flags,
2599 struct vif_params *params
2600 )
2601{
2602 struct wireless_dev *wdev;
2603 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
2604 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
Mohit Khanna0f232092012-09-11 14:46:08 -07002605 hdd_adapter_t *pP2pAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 tCsrRoamProfile *pRoamProfile = NULL;
2607 eCsrRoamBssType LastBSSType;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302608 hdd_config_t *pConfig = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 eMib_dot11DesiredBssType connectedBssType;
2610 VOS_STATUS status;
2611
2612 ENTER();
2613
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302614 status = wlan_hdd_validate_context(pHddCtx);
2615
2616 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302618 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2619 "%s: HDD context is not valid", __func__);
2620 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 }
2622
2623 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
2624 __func__, pAdapter->device_mode);
2625
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05302626 pConfig = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 wdev = ndev->ieee80211_ptr;
2628
2629#ifdef WLAN_BTAMP_FEATURE
2630 if((NL80211_IFTYPE_P2P_CLIENT == type)||
2631 (NL80211_IFTYPE_ADHOC == type)||
2632 (NL80211_IFTYPE_AP == type)||
2633 (NL80211_IFTYPE_P2P_GO == type))
2634 {
2635 pHddCtx->isAmpAllowed = VOS_FALSE;
2636 // stop AMP traffic
2637 status = WLANBAP_StopAmp();
2638 if(VOS_STATUS_SUCCESS != status )
2639 {
2640 pHddCtx->isAmpAllowed = VOS_TRUE;
2641 hddLog(VOS_TRACE_LEVEL_FATAL,
2642 "%s: Failed to stop AMP", __func__);
2643 return -EINVAL;
2644 }
2645 }
2646#endif //WLAN_BTAMP_FEATURE
2647 /* Reset the current device mode bit mask*/
2648 wlan_hdd_clear_concurrency_mode(pHddCtx, pAdapter->device_mode);
2649
2650 if( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnsone7245742012-09-05 17:12:55 -07002652 || (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE)
Jeff Johnson295189b2012-06-20 16:38:30 -07002653 )
2654 {
2655 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2656 pRoamProfile = &pWextState->roamProfile;
2657 LastBSSType = pRoamProfile->BSSType;
2658
2659 switch (type)
2660 {
2661 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002662 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 hddLog(VOS_TRACE_LEVEL_INFO,
2664 "%s: setting interface Type to INFRASTRUCTURE", __func__);
2665 pRoamProfile->BSSType = eCSR_BSS_TYPE_INFRASTRUCTURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002666#ifdef WLAN_FEATURE_11AC
2667 if(pConfig->dot11Mode == eHDD_DOT11_MODE_AUTO)
2668 {
2669 pConfig->dot11Mode = eHDD_DOT11_MODE_11ac;
2670 }
2671#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302672 pRoamProfile->phyMode =
Jeff Johnsone7245742012-09-05 17:12:55 -07002673 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002675 //Check for sub-string p2p to confirm its a p2p interface
2676 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302677 {
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002678 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2679 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2680 }
2681 else
2682 {
2683 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002685 }
Madan Mohan Koyyalamudi81746922013-07-17 14:38:51 +05302686#ifdef FEATURE_WLAN_TDLS
2687 /* The open adapter for the p2p shall skip initializations in
2688 * tdls_init if the device mode is WLAN_HDD_P2P_DEVICE, for
2689 * TDLS is supported only on WLAN_HDD_P2P_CLIENT. Hence invoke
2690 * tdls_init when the change_iface sets the device mode to
2691 * WLAN_HDD_P2P_CLIENT.
2692 */
2693
2694 if ( pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2695 {
2696 if (0 != wlan_hdd_tdls_init (pAdapter))
2697 {
2698 return -EINVAL;
2699 }
2700 }
2701#endif
2702
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 break;
2704 case NL80211_IFTYPE_ADHOC:
2705 hddLog(VOS_TRACE_LEVEL_INFO,
2706 "%s: setting interface Type to ADHOC", __func__);
2707 pRoamProfile->BSSType = eCSR_BSS_TYPE_START_IBSS;
2708 pRoamProfile->phyMode =
2709 hdd_cfg_xlate_to_csr_phy_mode(pConfig->dot11Mode);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002710 pAdapter->device_mode = WLAN_HDD_IBSS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 wdev->iftype = type;
2712 break;
2713
2714 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 {
2717 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
2718 "%s: setting interface Type to %s", __func__,
2719 (type == NL80211_IFTYPE_AP) ? "SoftAP" : "P2pGo");
2720
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002721 //Cancel any remain on channel for GO mode
2722 if (NL80211_IFTYPE_P2P_GO == type)
2723 {
2724 wlan_hdd_cancel_existing_remain_on_channel(pAdapter);
2725 }
Mohit Khanna0f232092012-09-11 14:46:08 -07002726 if (NL80211_IFTYPE_AP == type)
2727 {
2728 /* As Loading WLAN Driver one interface being created for p2p device
2729 * address. This will take one HW STA and the max number of clients
2730 * that can connect to softAP will be reduced by one. so while changing
2731 * the interface type to NL80211_IFTYPE_AP (SoftAP) remove p2p0
2732 * interface as it is not required in SoftAP mode.
2733 */
2734
2735 // Get P2P Adapter
2736 pP2pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_P2P_DEVICE);
2737
2738 if (pP2pAdapter)
2739 {
2740 hdd_stop_adapter(pHddCtx, pP2pAdapter);
2741 hdd_deinit_adapter(pHddCtx, pP2pAdapter);
2742 hdd_close_adapter(pHddCtx, pP2pAdapter, VOS_TRUE);
2743 }
2744 }
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302745#ifdef FEATURE_WLAN_TDLS
Mohit Khanna0f232092012-09-11 14:46:08 -07002746
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302747 /* A Mutex Lock is introduced while changing the mode to
2748 * protect the concurrent access for the Adapters by TDLS
2749 * module.
2750 */
2751 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2752 {
2753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2754 "%s: unable to lock list", __func__);
2755 return -EINVAL;
2756 }
2757#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 //De-init the adapter.
2759 hdd_stop_adapter( pHddCtx, pAdapter );
2760 hdd_deinit_adapter( pHddCtx, pAdapter );
2761 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2763 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302764#ifdef FEATURE_WLAN_TDLS
2765 mutex_unlock(&pHddCtx->tdls_lock);
2766#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002767
2768 //Disable BMPS and IMPS if enabled
2769 //before starting Go
2770 if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
2771 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302772 if(VOS_STATUS_E_FAILURE ==
Jeff Johnson32d95a32012-09-10 13:15:23 -07002773 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_P2P_GO))
2774 {
2775 //Fail to Exit BMPS
2776 VOS_ASSERT(0);
2777 }
2778 }
2779
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002780 if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) &&
2781 (pConfig->apRandomBssidEnabled))
2782 {
2783 /* To meet Android requirements create a randomized
2784 MAC address of the form 02:1A:11:Fx:xx:xx */
2785 get_random_bytes(&ndev->dev_addr[3], 3);
2786 ndev->dev_addr[0] = 0x02;
2787 ndev->dev_addr[1] = 0x1A;
2788 ndev->dev_addr[2] = 0x11;
2789 ndev->dev_addr[3] |= 0xF0;
2790 memcpy(pAdapter->macAddressCurrent.bytes, ndev->dev_addr,
2791 VOS_MAC_ADDR_SIZE);
Arif Hussain24bafea2013-11-15 15:10:03 -08002792 pr_info("wlan: Generated HotSpot BSSID " MAC_ADDRESS_STR"\n",
2793 MAC_ADDR_ARRAY(ndev->dev_addr));
Madan Mohan Koyyalamudi3ff2a0b2012-10-15 14:33:46 -07002794 }
2795
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 hdd_set_ap_ops( pAdapter->dev );
2797
Kiet Lam10841362013-11-01 11:36:50 +05302798 /* This is for only SAP mode where users can
2799 * control country through ini.
2800 * P2P GO follows station country code
2801 * acquired during the STA scanning. */
2802 if((NL80211_IFTYPE_AP == type) &&
2803 (memcmp(pConfig->apCntryCode, CFG_AP_COUNTRY_CODE_DEFAULT, 3) != 0))
2804 {
2805 int status = 0;
2806 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_INFO,
2807 "%s: setting country code from INI ", __func__);
2808 init_completion(&pAdapter->change_country_code);
2809 status = (int)sme_ChangeCountryCode(pHddCtx->hHal,
2810 (void *)(tSmeChangeCountryCallback)
2811 wlan_hdd_change_country_code_cb,
2812 pConfig->apCntryCode, pAdapter,
2813 pHddCtx->pvosContext,
Abhishek Singha306a442013-11-07 18:39:01 +05302814 eSIR_FALSE,
2815 eSIR_TRUE);
Kiet Lam10841362013-11-01 11:36:50 +05302816 if (eHAL_STATUS_SUCCESS == status)
2817 {
2818 /* Wait for completion */
2819 status = wait_for_completion_interruptible_timeout(
2820 &pAdapter->change_country_code,
2821 msecs_to_jiffies(WLAN_WAIT_TIME_COUNTRY));
2822 if (status <= 0)
2823 {
2824 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2825 "%s: SME Timed out while setting country code ",
2826 __func__);
2827 }
2828 }
2829 else
2830 {
2831 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2832 "%s: SME Change Country code failed \n",__func__);
2833 return -EINVAL;
2834 }
2835 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 status = hdd_init_ap_mode(pAdapter);
2837 if(status != VOS_STATUS_SUCCESS)
2838 {
2839 hddLog(VOS_TRACE_LEVEL_FATAL,
2840 "%s: Error initializing the ap mode", __func__);
2841 return -EINVAL;
2842 }
2843 hdd_set_conparam(1);
2844
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 /*interface type changed update in wiphy structure*/
2846 if(wdev)
2847 {
2848 wdev->iftype = type;
2849 pHddCtx->change_iface = type;
2850 }
2851 else
2852 {
2853 hddLog(VOS_TRACE_LEVEL_ERROR,
2854 "%s: ERROR !!!! Wireless dev is NULL", __func__);
2855 return -EINVAL;
2856 }
2857 goto done;
2858 }
2859
2860 default:
2861 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2862 __func__);
2863 return -EOPNOTSUPP;
2864 }
2865 }
2866 else if ( (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 )
2869 {
2870 switch(type)
2871 {
2872 case NL80211_IFTYPE_STATION:
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 case NL80211_IFTYPE_P2P_CLIENT:
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 case NL80211_IFTYPE_ADHOC:
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302875#ifdef FEATURE_WLAN_TDLS
2876
2877 /* A Mutex Lock is introduced while changing the mode to
2878 * protect the concurrent access for the Adapters by TDLS
2879 * module.
2880 */
2881 if (mutex_lock_interruptible(&pHddCtx->tdls_lock))
2882 {
2883 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2884 "%s: unable to lock list", __func__);
2885 return -EINVAL;
2886 }
2887#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07002888 hdd_stop_adapter( pHddCtx, pAdapter );
2889 hdd_deinit_adapter( pHddCtx, pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 wdev->iftype = type;
Gopichand Nakkalaf527dc62012-12-31 16:35:10 -08002891 //Check for sub-string p2p to confirm its a p2p interface
2892 if (NULL != strstr(ndev->name,"p2p"))
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002893 {
2894 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
2895 WLAN_HDD_P2P_DEVICE : WLAN_HDD_P2P_CLIENT;
2896 }
2897 else
2898 {
2899 pAdapter->device_mode = (type == NL80211_IFTYPE_STATION) ?
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 WLAN_HDD_INFRA_STATION: WLAN_HDD_P2P_CLIENT;
Gopichand Nakkala864d3552012-12-31 16:08:51 -08002901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 hdd_set_conparam(0);
2903 pHddCtx->change_iface = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 memset(&pAdapter->sessionCtx, 0, sizeof(pAdapter->sessionCtx));
2905 hdd_set_station_ops( pAdapter->dev );
2906 status = hdd_init_station_mode( pAdapter );
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302907#ifdef FEATURE_WLAN_TDLS
2908 mutex_unlock(&pHddCtx->tdls_lock);
2909#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 if( VOS_STATUS_SUCCESS != status )
2911 return -EOPNOTSUPP;
Jeff Johnsone7245742012-09-05 17:12:55 -07002912 /* In case of JB, for P2P-GO, only change interface will be called,
2913 * This is the right place to enable back bmps_imps()
2914 */
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302915 if (pHddCtx->hdd_wlan_suspended)
2916 {
2917 hdd_set_pwrparams(pHddCtx);
2918 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002919 hdd_enable_bmps_imps(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 goto done;
2921 case NL80211_IFTYPE_AP:
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 case NL80211_IFTYPE_P2P_GO:
Jeff Johnson295189b2012-06-20 16:38:30 -07002923 wdev->iftype = type;
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 pAdapter->device_mode = (type == NL80211_IFTYPE_AP) ?
2925 WLAN_HDD_SOFTAP : WLAN_HDD_P2P_GO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002926 goto done;
2927 default:
2928 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported interface Type",
2929 __func__);
2930 return -EOPNOTSUPP;
2931
2932 }
2933
2934 }
2935 else
2936 {
2937 return -EOPNOTSUPP;
2938 }
2939
2940
2941 if(pRoamProfile)
2942 {
2943 if ( LastBSSType != pRoamProfile->BSSType )
2944 {
2945 /*interface type changed update in wiphy structure*/
2946 wdev->iftype = type;
2947
2948 /*the BSS mode changed, We need to issue disconnect
2949 if connected or in IBSS disconnect state*/
2950 if ( hdd_connGetConnectedBssType(
2951 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connectedBssType ) ||
2952 ( eCSR_BSS_TYPE_START_IBSS == LastBSSType ) )
2953 {
2954 /*need to issue a disconnect to CSR.*/
2955 INIT_COMPLETION(pAdapter->disconnect_comp_var);
2956 if( eHAL_STATUS_SUCCESS ==
2957 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2958 pAdapter->sessionId,
2959 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
2960 {
2961 wait_for_completion_interruptible_timeout(
2962 &pAdapter->disconnect_comp_var,
2963 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
2964 }
2965 }
2966 }
2967 }
2968
2969done:
2970 /*set bitmask based on updated value*/
2971 wlan_hdd_set_concurrency_mode(pHddCtx, pAdapter->device_mode);
Leo Chang6fe1f922013-06-07 19:21:24 -07002972
2973 /* Only STA mode support TM now
2974 * all other mode, TM feature should be disabled */
2975 if ( (pHddCtx->cfg_ini->thermalMitigationEnable) &&
2976 (~VOS_STA & pHddCtx->concurrency_mode) )
2977 {
2978 hddDevTmLevelChangedHandler(pHddCtx->parent_dev, 0);
2979 }
2980
Jeff Johnson295189b2012-06-20 16:38:30 -07002981#ifdef WLAN_BTAMP_FEATURE
Gopichand Nakkala747461f2013-04-24 19:24:45 +05302982 if((NL80211_IFTYPE_STATION == type) && (pHddCtx->concurrency_mode <= 1) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
2984 {
2985 //we are ok to do AMP
2986 pHddCtx->isAmpAllowed = VOS_TRUE;
2987 }
2988#endif //WLAN_BTAMP_FEATURE
2989 EXIT();
2990 return 0;
2991}
2992
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002993#ifdef FEATURE_WLAN_TDLS
2994static int wlan_hdd_tdls_add_station(struct wiphy *wiphy,
2995 struct net_device *dev, u8 *mac, bool update, tCsrStaParams *StaParams)
2996{
2997 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
2998 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
2999 VOS_STATUS status;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003000 hddTdlsPeer_t *pTdlsPeer;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003001
3002 ENTER();
3003
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303004 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003005 {
3006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3007 "Invalid arguments");
3008 return -EINVAL;
3009 }
Hoonki Lee27511902013-03-14 18:19:06 -07003010
3011 if ((eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode) ||
3012 (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode))
3013 {
3014 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3015 "%s: TDLS mode is disabled OR not enabled in FW."
3016 MAC_ADDRESS_STR " Request declined.",
3017 __func__, MAC_ADDR_ARRAY(mac));
3018 return -ENOTSUPP;
3019 }
3020
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003021 if (pHddCtx->isLogpInProgress)
3022 {
3023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3024 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07003025 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003026 return -EBUSY;
3027 }
3028
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303029 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003030
3031 if ( NULL == pTdlsPeer ) {
3032 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3033 "%s: " MAC_ADDRESS_STR " (update %d) not exist. return invalid",
3034 __func__, MAC_ADDR_ARRAY(mac), update);
3035 return -EINVAL;
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003036 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003037
3038 /* in add station, we accept existing valid staId if there is */
3039 if ((0 == update) &&
3040 ((pTdlsPeer->link_status >= eTDLS_LINK_CONNECTING) ||
3041 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003042 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003043 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003044 "%s: " MAC_ADDRESS_STR
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003045 " link_status %d. staId %d. add station ignored.",
3046 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId);
3047 return 0;
3048 }
3049 /* in change station, we accept only when staId is valid */
3050 if ((1 == update) &&
3051 ((pTdlsPeer->link_status > eTDLS_LINK_CONNECTING) ||
3052 (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))))
3053 {
3054 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3055 "%s: " MAC_ADDRESS_STR
3056 " link status %d. staId %d. change station %s.",
3057 __func__, MAC_ADDR_ARRAY(mac), pTdlsPeer->link_status, pTdlsPeer->staId,
3058 (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? "ignored" : "declined");
3059 return (TDLS_STA_INDEX_VALID(pTdlsPeer->staId)) ? 0 : -EPERM;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003060 }
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003061
3062 /* when others are on-going, we want to change link_status to idle */
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303063 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, mac, TRUE))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003064 {
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 setup is ongoing. 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
3072 /* first to check if we reached to maximum supported TDLS peer.
3073 TODO: for now, return -EPERM looks working fine,
3074 but need to check if any other errno fit into this category.*/
3075 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
3076 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3078 "%s: " MAC_ADDRESS_STR
3079 " TDLS Max peer already connected. Request declined.",
3080 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala05922802013-03-14 12:23:19 -07003081 goto error;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003082 }
3083 else
3084 {
3085 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303086 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, mac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003087 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003088 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003089 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3090 "%s: " MAC_ADDRESS_STR " already connected. Request declined.",
3091 __func__, MAC_ADDR_ARRAY(mac));
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003092 return -EPERM;
3093 }
3094 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003095 if (0 == update)
3096 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_CONNECTING);
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003097
Jeff Johnsond75fe012013-04-06 10:53:06 -07003098 /* debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303099 if (NULL != StaParams)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003100 {
3101 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3102 "%s: TDLS Peer Parameters.", __func__);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003103 if(StaParams->htcap_present)
3104 {
3105 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3106 "ht_capa->cap_info: %0x", StaParams->HTCap.capInfo);
3107 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3108 "ht_capa->extended_capabilities: %0x",
3109 StaParams->HTCap.extendedHtCapInfo);
3110 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003111 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3112 "params->capability: %0x",StaParams->capability);
3113 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003114 "params->ext_capab_len: %0x",StaParams->extn_capability[0]);
Hoonki Lee66b75f32013-04-16 18:30:07 -07003115 if(StaParams->vhtcap_present)
3116 {
3117 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3118 "rxMcsMap %x rxHighest %x txMcsMap %x txHighest %x",
3119 StaParams->VHTCap.suppMcs.rxMcsMap, StaParams->VHTCap.suppMcs.rxHighest,
3120 StaParams->VHTCap.suppMcs.txMcsMap, StaParams->VHTCap.suppMcs.txHighest);
3121 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003122 {
3123 int i = 0;
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003124 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "Supported rates:");
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003125 for (i = 0; i < sizeof(StaParams->supported_rates); i++)
3126 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
3127 "[%d]: %x ", i, StaParams->supported_rates[i]);
3128 }
Jeff Johnsond75fe012013-04-06 10:53:06 -07003129 } /* end debug code */
Gopichand Nakkala838be5d2013-04-10 22:41:51 +05303130 else if ((1 == update) && (NULL == StaParams))
3131 {
3132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3133 "%s : update is true, but staParams is NULL. Error!", __func__);
3134 return -EPERM;
3135 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003136
3137 INIT_COMPLETION(pAdapter->tdls_add_station_comp);
3138
3139 if (!update)
3140 {
3141 status = sme_AddTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3142 pAdapter->sessionId, mac);
3143 }
3144 else
3145 {
3146 status = sme_ChangeTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
3147 pAdapter->sessionId, mac, StaParams);
3148 }
3149
3150 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_add_station_comp,
3151 msecs_to_jiffies(WAIT_TIME_TDLS_ADD_STA));
3152
3153 if (!status)
3154 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003155 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003156 "%s: timeout waiting for tdls add station indication",
3157 __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003158 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003159 }
3160 if ( eHAL_STATUS_SUCCESS != pAdapter->tdlsAddStaStatus)
3161 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07003162 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003163 "%s: Add Station is unsucessful", __func__);
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07003164 return -EPERM;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003165 }
3166
3167 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07003168
3169error:
3170 wlan_hdd_tdls_set_link_status(pAdapter, mac, eTDLS_LINK_IDLE);
3171 return -EPERM;
3172
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003173}
3174#endif
3175
Jeff Johnson295189b2012-06-20 16:38:30 -07003176static int wlan_hdd_change_station(struct wiphy *wiphy,
3177 struct net_device *dev,
3178 u8 *mac,
3179 struct station_parameters *params)
3180{
3181 VOS_STATUS status = VOS_STATUS_SUCCESS;
3182 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Gopichand Nakkala29149562013-05-10 21:43:41 +05303183 hdd_context_t *pHddCtx;
3184 hdd_station_ctx_t *pHddStaCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 v_MACADDR_t STAMacAddress;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003186#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003187 tCsrStaParams StaParams = {0};
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003188 tANI_U8 isBufSta = 0;
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003189#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003190 ENTER();
3191
Gopichand Nakkala29149562013-05-10 21:43:41 +05303192 if ((NULL == pAdapter))
3193 {
3194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3195 "invalid adapter ");
3196 return -EINVAL;
3197 }
3198
3199 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3200 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3201
3202 if ((NULL == pHddCtx) || (NULL == pHddStaCtx))
3203 {
3204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3205 "invalid HDD state or HDD station context");
3206 return -EINVAL;
3207 }
3208
3209 if (pHddCtx->isLogpInProgress)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003210 {
3211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3212 "%s:LOGP in Progress. Ignore!!!", __func__);
3213 return -EAGAIN;
3214 }
3215
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 vos_mem_copy(STAMacAddress.bytes, mac, sizeof(v_MACADDR_t));
3217
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003218 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
3219 || (pAdapter->device_mode == WLAN_HDD_P2P_GO))
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003221 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_AUTHORIZED))
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303223 status = hdd_softap_change_STA_state( pAdapter, &STAMacAddress,
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 WLANTL_STA_AUTHENTICATED);
3225
Gopichand Nakkala29149562013-05-10 21:43:41 +05303226 if (status != VOS_STATUS_SUCCESS)
3227 {
3228 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3229 "%s: Not able to change TL state to AUTHENTICATED", __func__);
3230 return -EINVAL;
3231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 }
3233 }
Hoonki Leea6d49be2013-04-05 09:43:25 -07003234 else if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
3235 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)) {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303236#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003237 if (params->sta_flags_set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
3238 StaParams.capability = params->capability;
3239 StaParams.uapsd_queues = params->uapsd_queues;
3240 StaParams.max_sp = params->max_sp;
3241
3242 if (0 != params->ext_capab_len)
3243 vos_mem_copy(StaParams.extn_capability, params->ext_capab,
3244 sizeof(StaParams.extn_capability));
3245
3246 if (NULL != params->ht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003247 {
3248 StaParams.htcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003249 vos_mem_copy(&StaParams.HTCap, params->ht_capa, sizeof(tSirHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003250 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003251
3252 StaParams.supported_rates_len = params->supported_rates_len;
3253
3254 /* Note : The Maximum sizeof supported_rates sent by the Supplicant is 32.
3255 * The supported_rates array , for all the structures propogating till Add Sta
3256 * to the firmware has to be modified , if the supplicant (ieee80211) is
3257 * modified to send more rates.
3258 */
3259
3260 /* To avoid Data Currption , set to max length to SIR_MAC_MAX_SUPP_RATES
3261 */
3262 if (StaParams.supported_rates_len > SIR_MAC_MAX_SUPP_RATES)
3263 StaParams.supported_rates_len = SIR_MAC_MAX_SUPP_RATES;
3264
3265 if (0 != StaParams.supported_rates_len) {
3266 int i = 0;
3267 vos_mem_copy(StaParams.supported_rates, params->supported_rates,
3268 StaParams.supported_rates_len);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003270 "Supported Rates with Length %d", StaParams.supported_rates_len);
3271 for (i=0; i < StaParams.supported_rates_len; i++)
Hoonki Lee5305c3a2013-04-29 23:28:59 -07003272 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003273 "[%d]: %0x", i, StaParams.supported_rates[i]);
3274 }
3275
3276 if (NULL != params->vht_capa)
Hoonki Lee66b75f32013-04-16 18:30:07 -07003277 {
3278 StaParams.vhtcap_present = 1;
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003279 vos_mem_copy(&StaParams.VHTCap, params->vht_capa, sizeof(tSirVHTCap));
Hoonki Lee66b75f32013-04-16 18:30:07 -07003280 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003281
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003282 if (0 != params->ext_capab_len ) {
3283 /*Define A Macro : TODO Sunil*/
3284 if ((1<<4) & StaParams.extn_capability[3]) {
3285 isBufSta = 1;
3286 }
3287 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303288 status = wlan_hdd_tdls_set_peer_caps( pAdapter, mac, params->uapsd_queues,
3289 params->max_sp, isBufSta);
3290 if (VOS_STATUS_SUCCESS != status) {
3291 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3292 "%s: wlan_hdd_tdls_set_peer_caps failed!", __func__);
3293 return -EINVAL;
3294 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003295 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 1, &StaParams);
3296
3297 if (VOS_STATUS_SUCCESS != status) {
3298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3299 "%s: sme_ChangeTdlsPeerSta failed!", __func__);
3300 return -EINVAL;
3301 }
3302 }
Gopichand Nakkalab0856222013-03-12 22:39:05 -07003303#endif
Gopichand Nakkala6239acd2013-06-14 14:48:00 +05303304 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003305 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 return status;
3307}
3308
3309/*
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 * FUNCTION: wlan_hdd_cfg80211_add_key
3311 * This function is used to initialize the key information
3312 */
3313#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003314static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 struct net_device *ndev,
3316 u8 key_index, bool pairwise,
3317 const u8 *mac_addr,
3318 struct key_params *params
3319 )
3320#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003321static int wlan_hdd_cfg80211_add_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 struct net_device *ndev,
3323 u8 key_index, const u8 *mac_addr,
3324 struct key_params *params
3325 )
3326#endif
3327{
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 tCsrRoamSetKey setKey;
3330 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303331 int status;
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003332 v_U32_t roamId= 0xFF;
3333 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003334 hdd_hostapd_state_t *pHostapdState;
3335 VOS_STATUS vos_status;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003336 eHalStatus halStatus;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303337 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003338
3339 ENTER();
3340
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303341 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3342 status = wlan_hdd_validate_context(pHddCtx);
3343
3344 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003345 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303346 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3347 "%s: HDD context is not valid", __func__);
3348 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003349 }
3350
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003351 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d",
3352 __func__, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003353
3354 if (CSR_MAX_NUM_KEY <= key_index)
3355 {
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003356 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 key_index);
3358
3359 return -EINVAL;
3360 }
3361
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003362 if (CSR_MAX_KEY_LEN < params->key_len)
3363 {
3364 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key length %d", __func__,
3365 params->key_len);
3366
3367 return -EINVAL;
3368 }
3369
3370 hddLog(VOS_TRACE_LEVEL_INFO,
3371 "%s: called with key index = %d & key length %d",
3372 __func__, key_index, params->key_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003373
3374 /*extract key idx, key len and key*/
3375 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3376 setKey.keyId = key_index;
3377 setKey.keyLength = params->key_len;
3378 vos_mem_copy(&setKey.Key[0],params->key, params->key_len);
3379
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003380 switch (params->cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07003381 {
3382 case WLAN_CIPHER_SUITE_WEP40:
3383 setKey.encType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3384 break;
3385
3386 case WLAN_CIPHER_SUITE_WEP104:
3387 setKey.encType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3388 break;
3389
3390 case WLAN_CIPHER_SUITE_TKIP:
3391 {
3392 u8 *pKey = &setKey.Key[0];
3393 setKey.encType = eCSR_ENCRYPT_TYPE_TKIP;
3394
3395 vos_mem_zero(pKey, CSR_MAX_KEY_LEN);
3396
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003397 /*Supplicant sends the 32bytes key in this order
Jeff Johnson295189b2012-06-20 16:38:30 -07003398
3399 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003400 | Tk1 |TX-MIC | RX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 |--------------|----------|----------|
3402 <---16bytes---><--8bytes--><--8bytes-->
3403
3404 */
3405 /*Sme expects the 32 bytes key to be in the below order
3406
3407 |--------------|----------|----------|
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003408 | Tk1 |RX-MIC | TX Mic |
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 |--------------|----------|----------|
3410 <---16bytes---><--8bytes--><--8bytes-->
3411 */
3412 /* Copy the Temporal Key 1 (TK1) */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003413 vos_mem_copy(pKey, params->key, 16);
Jeff Johnson295189b2012-06-20 16:38:30 -07003414
3415 /*Copy the rx mic first*/
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003416 vos_mem_copy(&pKey[16], &params->key[24], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003417
3418 /*Copy the tx mic */
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003419 vos_mem_copy(&pKey[24], &params->key[16], 8);
Jeff Johnson295189b2012-06-20 16:38:30 -07003420
3421
3422 break;
3423 }
3424
3425 case WLAN_CIPHER_SUITE_CCMP:
3426 setKey.encType = eCSR_ENCRYPT_TYPE_AES;
3427 break;
3428
3429#ifdef FEATURE_WLAN_WAPI
3430 case WLAN_CIPHER_SUITE_SMS4:
3431 {
3432 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3433 wlan_hdd_cfg80211_set_key_wapi(pAdapter, key_index, mac_addr,
3434 params->key, params->key_len);
3435 return 0;
3436 }
3437#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003438
Jeff Johnson295189b2012-06-20 16:38:30 -07003439#ifdef FEATURE_WLAN_CCX
3440 case WLAN_CIPHER_SUITE_KRK:
3441 setKey.encType = eCSR_ENCRYPT_TYPE_KRK;
3442 break;
3443#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003444
3445#ifdef WLAN_FEATURE_11W
3446 case WLAN_CIPHER_SUITE_AES_CMAC:
3447 setKey.encType = eCSR_ENCRYPT_TYPE_AES_CMAC;
Chet Lanctot3b5158a2013-03-31 16:45:21 -07003448 break;
Chet Lanctot186b5732013-03-18 10:26:30 -07003449#endif
3450
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 default:
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003452 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: unsupported cipher type %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 __func__, params->cipher);
3454 return -EOPNOTSUPP;
3455 }
3456
3457 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: encryption type %d",
3458 __func__, setKey.encType);
3459
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003460 if (
Jeff Johnson295189b2012-06-20 16:38:30 -07003461#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3462 (!pairwise)
3463#else
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003464 (!mac_addr || is_broadcast_ether_addr(mac_addr))
Jeff Johnson295189b2012-06-20 16:38:30 -07003465#endif
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003466 )
3467 {
3468 /* set group key*/
3469 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3470 "%s- %d: setting Broadcast key",
3471 __func__, __LINE__);
3472 setKey.keyDirection = eSIR_RX_ONLY;
3473 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3474 }
3475 else
3476 {
3477 /* set pairwise key*/
3478 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3479 "%s- %d: setting pairwise key",
3480 __func__, __LINE__);
3481 setKey.keyDirection = eSIR_TX_RX;
3482 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3483 }
3484 if ((WLAN_HDD_IBSS == pAdapter->device_mode) && !pairwise)
3485 {
3486 setKey.keyDirection = eSIR_TX_RX;
3487 /*Set the group key*/
3488 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3489 pAdapter->sessionId, &setKey, &roamId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003490
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003491 if ( 0 != status )
3492 {
3493 hddLog(VOS_TRACE_LEVEL_ERROR,
3494 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3495 return -EINVAL;
3496 }
3497 /*Save the keys here and call sme_RoamSetKey for setting
3498 the PTK after peer joins the IBSS network*/
3499 vos_mem_copy(&pAdapter->sessionCtx.station.ibss_enc_key,
3500 &setKey, sizeof(tCsrRoamSetKey));
3501 return status;
3502 }
Gopichand Nakkala29149562013-05-10 21:43:41 +05303503 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP) ||
3504 (pAdapter->device_mode == WLAN_HDD_P2P_GO))
3505 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003507 if( pHostapdState->bssState == BSS_START )
3508 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 status = WLANSAP_SetKeySta( pVosContext, &setKey);
3510
3511 if ( status != eHAL_STATUS_SUCCESS )
3512 {
3513 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3514 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3515 __LINE__, status );
3516 }
3517 }
3518
3519 /* Saving WEP keys */
3520 else if( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == setKey.encType ||
3521 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == setKey.encType )
3522 {
3523 //Save the wep key in ap context. Issue setkey after the BSS is started.
3524 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3525 vos_mem_copy(&pAPCtx->wepKey[key_index], &setKey, sizeof(tCsrRoamSetKey));
3526 }
3527 else
3528 {
3529 //Save the key in ap context. Issue setkey after the BSS is started.
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003530 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 vos_mem_copy(&pAPCtx->groupKey, &setKey, sizeof(tCsrRoamSetKey));
3532 }
3533 }
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003534 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
3535 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 {
3537 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3538 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3539
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303540#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3541 if (!pairwise)
3542#else
3543 if (!mac_addr || is_broadcast_ether_addr(mac_addr))
3544#endif
3545 {
3546 /* set group key*/
3547 if (pHddStaCtx->roam_info.deferKeyComplete)
3548 {
3549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3550 "%s- %d: Perform Set key Complete",
3551 __func__, __LINE__);
3552 hdd_PerformRoamSetKeyComplete(pAdapter);
3553 }
3554 }
3555
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 pWextState->roamProfile.Keys.KeyLength[key_index] = (u8)params->key_len;
3557
Venkata Prathyusha Kuntupalliee2ce712013-01-17 14:09:24 -08003558 pWextState->roamProfile.Keys.defaultIndex = key_index;
3559
3560
Jeff Johnsonf77ef0a2013-03-27 09:29:14 -07003561 vos_mem_copy(&pWextState->roamProfile.Keys.KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 params->key, params->key_len);
3563
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303564
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3566
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303567 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 "%s: set key for peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303569 __func__, setKey.peerMac[0], setKey.peerMac[1],
3570 setKey.peerMac[2], setKey.peerMac[3],
3571 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 setKey.keyDirection);
3573
3574 vos_status = wlan_hdd_check_ula_done(pAdapter);
3575
3576 if ( vos_status != VOS_STATUS_SUCCESS )
3577 {
3578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3579 "[%4d] wlan_hdd_check_ula_done returned ERROR status= %d",
3580 __LINE__, vos_status );
3581
3582 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3583
3584 return -EINVAL;
3585
3586 }
3587
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003588#ifdef WLAN_FEATURE_VOWIFI_11R
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303589 /* The supplicant may attempt to set the PTK once pre-authentication
3590 is done. Save the key in the UMAC and include it in the ADD BSS
3591 request */
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003592 halStatus = sme_FTUpdateKey( WLAN_HDD_GET_HAL_CTX(pAdapter), &setKey);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303593 if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_SUCCESS )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003594 {
Gopichand Nakkala3d295922013-05-07 16:19:14 +05303595 hddLog(VOS_TRACE_LEVEL_INFO_MED,
3596 "%s: Update PreAuth Key success", __func__);
3597 return 0;
3598 }
3599 else if ( halStatus == eHAL_STATUS_FT_PREAUTH_KEY_FAILED )
3600 {
3601 hddLog(VOS_TRACE_LEVEL_ERROR,
3602 "%s: Update PreAuth Key failed", __func__);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05303603 return -EINVAL;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07003604 }
3605#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -07003606
3607 /* issue set key request to SME*/
3608 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3609 pAdapter->sessionId, &setKey, &roamId );
3610
3611 if ( 0 != status )
3612 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303613 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 "%s: sme_RoamSetKey failed, returned %d", __func__, status);
3615 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3616 return -EINVAL;
3617 }
3618
3619
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303620 /* in case of IBSS as there was no information available about WEP keys during
3621 * IBSS join, group key intialized with NULL key, so re-initialize group key
Jeff Johnson295189b2012-06-20 16:38:30 -07003622 * with correct value*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303623 if ( (eCSR_BSS_TYPE_START_IBSS == pWextState->roamProfile.BSSType) &&
3624 !( ( IW_AUTH_KEY_MGMT_802_1X
3625 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType)
3627 )
3628 &&
3629 ( (WLAN_CIPHER_SUITE_WEP40 == params->cipher)
3630 || (WLAN_CIPHER_SUITE_WEP104 == params->cipher)
3631 )
3632 )
3633 {
3634 setKey.keyDirection = eSIR_RX_ONLY;
3635 vos_mem_copy(setKey.peerMac,groupmacaddr,WNI_CFG_BSSID_LEN);
3636
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303637 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 "%s: set key peerMac %2x:%2x:%2x:%2x:%2x:%2x, direction %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303639 __func__, setKey.peerMac[0], setKey.peerMac[1],
3640 setKey.peerMac[2], setKey.peerMac[3],
3641 setKey.peerMac[4], setKey.peerMac[5],
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 setKey.keyDirection);
3643
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303644 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 pAdapter->sessionId, &setKey, &roamId );
3646
3647 if ( 0 != status )
3648 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303649 hddLog(VOS_TRACE_LEVEL_ERROR,
3650 "%s: sme_RoamSetKey failed for group key (IBSS), returned %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003651 __func__, status);
3652 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3653 return -EINVAL;
3654 }
3655 }
3656 }
3657
3658 return 0;
3659}
3660
3661/*
3662 * FUNCTION: wlan_hdd_cfg80211_get_key
3663 * This function is used to get the key information
3664 */
3665#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303666static int wlan_hdd_cfg80211_get_key(
3667 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003668 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303669 u8 key_index, bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 const u8 *mac_addr, void *cookie,
3671 void (*callback)(void *cookie, struct key_params*)
3672 )
3673#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303674static int wlan_hdd_cfg80211_get_key(
3675 struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 struct net_device *ndev,
3677 u8 key_index, const u8 *mac_addr, void *cookie,
3678 void (*callback)(void *cookie, struct key_params*)
3679 )
3680#endif
3681{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303682 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3684 tCsrRoamProfile *pRoamProfile = &(pWextState->roamProfile);
3685 struct key_params params;
3686
3687 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303688
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
3690 __func__,pAdapter->device_mode);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303691
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 memset(&params, 0, sizeof(params));
3693
3694 if (CSR_MAX_NUM_KEY <= key_index)
3695 {
3696 return -EINVAL;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003698
3699 switch(pRoamProfile->EncryptionType.encryptionType[0])
3700 {
3701 case eCSR_ENCRYPT_TYPE_NONE:
3702 params.cipher = IW_AUTH_CIPHER_NONE;
3703 break;
3704
3705 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3706 case eCSR_ENCRYPT_TYPE_WEP40:
3707 params.cipher = WLAN_CIPHER_SUITE_WEP40;
3708 break;
3709
3710 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3711 case eCSR_ENCRYPT_TYPE_WEP104:
3712 params.cipher = WLAN_CIPHER_SUITE_WEP104;
3713 break;
3714
3715 case eCSR_ENCRYPT_TYPE_TKIP:
3716 params.cipher = WLAN_CIPHER_SUITE_TKIP;
3717 break;
3718
3719 case eCSR_ENCRYPT_TYPE_AES:
3720 params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
3721 break;
3722
3723 default:
3724 params.cipher = IW_AUTH_CIPHER_NONE;
3725 break;
3726 }
3727
3728 params.key_len = pRoamProfile->Keys.KeyLength[key_index];
3729 params.seq_len = 0;
3730 params.seq = NULL;
3731 params.key = &pRoamProfile->Keys.KeyMaterial[key_index][0];
3732 callback(cookie, &params);
3733 return 0;
3734}
3735
3736/*
3737 * FUNCTION: wlan_hdd_cfg80211_del_key
3738 * This function is used to delete the key information
3739 */
3740#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303741static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 struct net_device *ndev,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303743 u8 key_index,
3744 bool pairwise,
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 const u8 *mac_addr
3746 )
3747#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303748static int wlan_hdd_cfg80211_del_key( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 struct net_device *ndev,
3750 u8 key_index,
3751 const u8 *mac_addr
3752 )
3753#endif
3754{
3755 int status = 0;
3756
3757 //This code needs to be revisited. There is sme_removeKey API, we should
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303758 //plan to use that. After the change to use correct index in setkey,
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 //it is observed that this is invalidating peer
3760 //key index whenever re-key is done. This is affecting data link.
3761 //It should be ok to ignore del_key.
3762#if 0
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303763 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
3764 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 u8 groupmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
3766 tCsrRoamSetKey setKey;
3767 v_U32_t roamId= 0xFF;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303768
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 ENTER();
3770
3771 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: device_mode = %d\n",
3772 __func__,pAdapter->device_mode);
3773
3774 if (CSR_MAX_NUM_KEY <= key_index)
3775 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303776 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 key_index);
3778
3779 return -EINVAL;
3780 }
3781
3782 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3783 setKey.keyId = key_index;
3784
3785 if (mac_addr)
3786 vos_mem_copy(setKey.peerMac, mac_addr,WNI_CFG_BSSID_LEN);
3787 else
3788 vos_mem_copy(setKey.peerMac, groupmacaddr, WNI_CFG_BSSID_LEN);
3789
3790 setKey.encType = eCSR_ENCRYPT_TYPE_NONE;
3791
3792 if ((pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07003793 || (pAdapter->device_mode == WLAN_HDD_P2P_GO)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303794 )
3795 {
3796
3797 hdd_hostapd_state_t *pHostapdState =
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
3799 if( pHostapdState->bssState == BSS_START)
3800 {
3801 status = WLANSAP_SetKeySta( pVosContext, &setKey);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303802
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 if ( status != eHAL_STATUS_SUCCESS )
3804 {
3805 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3806 "[%4d] WLANSAP_SetKeySta returned ERROR status= %d",
3807 __LINE__, status );
3808 }
3809 }
3810 }
3811 else if ( (pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303812 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 )
3814 {
3815 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3816
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303817 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_SETTING_KEY;
3818
3819 hddLog(VOS_TRACE_LEVEL_INFO_MED,
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 "%s: delete key for peerMac %2x:%2x:%2x:%2x:%2x:%2x",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303821 __func__, setKey.peerMac[0], setKey.peerMac[1],
3822 setKey.peerMac[2], setKey.peerMac[3],
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 setKey.peerMac[4], setKey.peerMac[5]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303824 if(pAdapter->sessionCtx.station.conn_info.connState ==
3825 eConnectionState_Associated)
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303827 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303829
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 if ( 0 != status )
3831 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303832 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003833 "%s: sme_RoamSetKey failure, returned %d",
3834 __func__, status);
3835 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3836 return -EINVAL;
3837 }
3838 }
3839 }
3840#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07003841 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 return status;
3843}
3844
3845/*
3846 * FUNCTION: wlan_hdd_cfg80211_set_default_key
3847 * This function is used to set the default tx key index
3848 */
3849#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
3850static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3851 struct net_device *ndev,
3852 u8 key_index,
3853 bool unicast, bool multicast)
3854#else
3855static int wlan_hdd_cfg80211_set_default_key( struct wiphy *wiphy,
3856 struct net_device *ndev,
3857 u8 key_index)
3858#endif
3859{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303860 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303861 int status;
Gopichand Nakkala29149562013-05-10 21:43:41 +05303862 hdd_wext_state_t *pWextState;
3863 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303864 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003865
3866 ENTER();
3867
Gopichand Nakkala29149562013-05-10 21:43:41 +05303868 if ((NULL == pAdapter))
3869 {
3870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3871 "invalid adapter");
3872 return -EINVAL;
3873 }
3874
3875 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3876 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3877
3878 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3879 {
3880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3881 "invalid Wext state or HDD context");
3882 return -EINVAL;
3883 }
3884
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d key_index = %d \n",
3886 __func__,pAdapter->device_mode, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303887
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 if (CSR_MAX_NUM_KEY <= key_index)
3889 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303890 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid key index %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 key_index);
3892
3893 return -EINVAL;
3894 }
3895
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303896 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3897 status = wlan_hdd_validate_context(pHddCtx);
3898
3899 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003900 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05303901 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3902 "%s: HDD context is not valid", __func__);
3903 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003904 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303905
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 || (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303908 )
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 {
Gopichand Nakkala29149562013-05-10 21:43:41 +05303910 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
Arif Hussain6943f522013-11-04 20:10:10 -08003911 pHddStaCtx->conn_info.ucEncryptionType) &&
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303912 (eCSR_ENCRYPT_TYPE_AES !=
Arif Hussain6943f522013-11-04 20:10:10 -08003913 pHddStaCtx->conn_info.ucEncryptionType)
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303915 {
3916 /* if default key index is not same as previous one,
Jeff Johnson295189b2012-06-20 16:38:30 -07003917 * then update the default key index */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303918
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 tCsrRoamSetKey setKey;
3920 v_U32_t roamId= 0xFF;
3921 tCsrKeys *Keys = &pWextState->roamProfile.Keys;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303922
3923 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: default tx key index %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 __func__, key_index);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303925
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 Keys->defaultIndex = (u8)key_index;
3927 vos_mem_zero(&setKey,sizeof(tCsrRoamSetKey));
3928 setKey.keyId = key_index;
3929 setKey.keyLength = Keys->KeyLength[key_index];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303930
3931 vos_mem_copy(&setKey.Key[0],
3932 &Keys->KeyMaterial[key_index][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 Keys->KeyLength[key_index]);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303934
Gopichand Nakkala29149562013-05-10 21:43:41 +05303935 setKey.keyDirection = eSIR_TX_RX;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303936
3937 vos_mem_copy(setKey.peerMac,
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 &pHddStaCtx->conn_info.bssId[0],
3939 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303940
Gopichand Nakkala29149562013-05-10 21:43:41 +05303941 if (Keys->KeyLength[key_index] == CSR_WEP40_KEY_LEN &&
3942 pWextState->roamProfile.EncryptionType.encryptionType[0] ==
3943 eCSR_ENCRYPT_TYPE_WEP104)
3944 {
3945 /*In the case of dynamic wep supplicant hardcodes DWEP type to eCSR_ENCRYPT_TYPE_WEP104
3946 even though ap is configured for WEP-40 encryption. In this canse the key length
3947 is 5 but the encryption type is 104 hence checking the key langht(5) and encryption
3948 type(104) and switching encryption type to 40*/
3949 pWextState->roamProfile.EncryptionType.encryptionType[0] =
3950 eCSR_ENCRYPT_TYPE_WEP40;
3951 pWextState->roamProfile.mcEncryptionType.encryptionType[0] =
3952 eCSR_ENCRYPT_TYPE_WEP40;
3953 }
3954
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303955 setKey.encType =
Jeff Johnson295189b2012-06-20 16:38:30 -07003956 pWextState->roamProfile.EncryptionType.encryptionType[0];
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303957
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 /* issue set key request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303959 status = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 pAdapter->sessionId, &setKey, &roamId );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303961
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 if ( 0 != status )
3963 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303964 hddLog(VOS_TRACE_LEVEL_ERROR,
3965 "%s: sme_RoamSetKey failed, returned %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 status);
3967 return -EINVAL;
3968 }
3969 }
3970 }
3971
3972 /* In SoftAp mode setting key direction for default mode */
3973 else if ( WLAN_HDD_SOFTAP == pAdapter->device_mode )
3974 {
3975 if ( (eCSR_ENCRYPT_TYPE_TKIP !=
3976 pWextState->roamProfile.EncryptionType.encryptionType[0]) &&
3977 (eCSR_ENCRYPT_TYPE_AES !=
3978 pWextState->roamProfile.EncryptionType.encryptionType[0])
3979 )
3980 {
3981 /* Saving key direction for default key index to TX default */
3982 hdd_ap_ctx_t *pAPCtx = WLAN_HDD_GET_AP_CTX_PTR(pAdapter);
3983 pAPCtx->wepKey[key_index].keyDirection = eSIR_TX_DEFAULT;
3984 }
3985 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05303986
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 return status;
3988}
3989
Jeff Johnson295189b2012-06-20 16:38:30 -07003990/*
3991 * FUNCTION: wlan_hdd_cfg80211_inform_bss
3992 * This function is used to inform the BSS details to nl80211 interface.
3993 */
3994static struct cfg80211_bss* wlan_hdd_cfg80211_inform_bss(
3995 hdd_adapter_t *pAdapter, tCsrRoamConnectedProfile *roamProfile)
3996{
3997 struct net_device *dev = pAdapter->dev;
3998 struct wireless_dev *wdev = dev->ieee80211_ptr;
3999 struct wiphy *wiphy = wdev->wiphy;
4000 tSirBssDescription *pBssDesc = roamProfile->pBssDesc;
4001 int chan_no;
4002 int ie_length;
4003 const char *ie;
4004 unsigned int freq;
4005 struct ieee80211_channel *chan;
4006 int rssi = 0;
4007 struct cfg80211_bss *bss = NULL;
4008
4009 ENTER();
4010
4011 if( NULL == pBssDesc )
4012 {
4013 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pBssDesc is NULL\n", __func__);
4014 return bss;
4015 }
4016
4017 chan_no = pBssDesc->channelId;
4018 ie_length = GET_IE_LEN_IN_BSS_DESC( pBssDesc->length );
4019 ie = ((ie_length != 0) ? (const char *)&pBssDesc->ieFields: NULL);
4020
4021 if( NULL == ie )
4022 {
4023 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: IE of BSS descriptor is NULL\n", __func__);
4024 return bss;
4025 }
4026
4027#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
4028 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ))
4029 {
4030 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4031 }
4032 else
4033 {
4034 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4035 }
4036#else
4037 freq = ieee80211_channel_to_frequency(chan_no);
4038#endif
4039
4040 chan = __ieee80211_get_channel(wiphy, freq);
4041
4042 bss = cfg80211_get_bss(wiphy, chan, pBssDesc->bssId,
4043 &roamProfile->SSID.ssId[0], roamProfile->SSID.length,
4044 WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
4045 if (bss == NULL)
4046 {
4047 rssi = (VOS_MIN ((pBssDesc->rssi + pBssDesc->sinr), 0))*100;
4048
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304049 return (cfg80211_inform_bss(wiphy, chan, pBssDesc->bssId,
4050 le64_to_cpu(*(__le64 *)pBssDesc->timeStamp),
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 pBssDesc->capabilityInfo,
4052 pBssDesc->beaconInterval, ie, ie_length,
4053 rssi, GFP_KERNEL ));
4054}
4055 else
4056 {
4057 return bss;
4058 }
4059}
4060
4061
4062
4063/*
4064 * FUNCTION: wlan_hdd_cfg80211_inform_bss_frame
4065 * This function is used to inform the BSS details to nl80211 interface.
4066 */
4067struct cfg80211_bss*
4068wlan_hdd_cfg80211_inform_bss_frame( hdd_adapter_t *pAdapter,
4069 tSirBssDescription *bss_desc
4070 )
4071{
4072 /*
4073 cfg80211_inform_bss() is not updating ie field of bss entry, if entry
4074 already exists in bss data base of cfg80211 for that particular BSS ID.
4075 Using cfg80211_inform_bss_frame to update the bss entry instead of
4076 cfg80211_inform_bss, But this call expects mgmt packet as input. As of
4077 now there is no possibility to get the mgmt(probe response) frame from PE,
4078 converting bss_desc to ieee80211_mgmt(probe response) and passing to
4079 cfg80211_inform_bss_frame.
4080 */
4081 struct net_device *dev = pAdapter->dev;
4082 struct wireless_dev *wdev = dev->ieee80211_ptr;
4083 struct wiphy *wiphy = wdev->wiphy;
4084 int chan_no = bss_desc->channelId;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004085#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4086 qcom_ie_age *qie_age = NULL;
4087 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length ) + sizeof(qcom_ie_age);
4088#else
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 int ie_length = GET_IE_LEN_IN_BSS_DESC( bss_desc->length );
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004090#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 const char *ie =
4092 ((ie_length != 0) ? (const char *)&bss_desc->ieFields: NULL);
4093 unsigned int freq;
4094 struct ieee80211_channel *chan;
4095 struct ieee80211_mgmt *mgmt =
4096 kzalloc((sizeof (struct ieee80211_mgmt) + ie_length), GFP_KERNEL);
4097 struct cfg80211_bss *bss_status = NULL;
4098 size_t frame_len = sizeof (struct ieee80211_mgmt) + ie_length;
4099 int rssi = 0;
Wilson Yangf80a0542013-10-07 13:02:37 -07004100 hdd_context_t *pHddCtx;
4101 int status;
Jeff Johnsone7245742012-09-05 17:12:55 -07004102#ifdef WLAN_OPEN_SOURCE
4103 struct timespec ts;
4104#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004105
4106 ENTER();
4107
Wilson Yangf80a0542013-10-07 13:02:37 -07004108 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4109 status = wlan_hdd_validate_context(pHddCtx);
4110
4111 /*bss_update is not allowed during wlan driver loading or unloading*/
4112 if (pHddCtx->isLoadUnloadInProgress)
4113 {
4114 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4115 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4116 return NULL;
4117 }
4118
4119
4120 if (0 != status)
4121 {
4122 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4123 "%s: HDD context is not valid", __func__);
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004124 return NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004125 }
4126
4127
4128 if (!mgmt)
4129 {
4130 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4131 "%s: memory allocation failed ", __func__);
4132 return NULL;
4133 }
Madan Mohan Koyyalamudi2e5c9142012-11-02 13:17:48 -07004134
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 memcpy(mgmt->bssid, bss_desc->bssId, ETH_ALEN);
Jeff Johnsone7245742012-09-05 17:12:55 -07004136
4137#ifdef WLAN_OPEN_SOURCE
4138 /* Android does not want the timestamp from the frame.
4139 Instead it wants a monotonic increasing value */
4140 get_monotonic_boottime(&ts);
4141 mgmt->u.probe_resp.timestamp =
4142 ((u64)ts.tv_sec * 1000000) + (ts.tv_nsec / 1000);
4143#else
4144 /* keep old behavior for non-open source (for now) */
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 memcpy(&mgmt->u.probe_resp.timestamp, bss_desc->timeStamp,
4146 sizeof (bss_desc->timeStamp));
Jeff Johnsone7245742012-09-05 17:12:55 -07004147
4148#endif
4149
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 mgmt->u.probe_resp.beacon_int = bss_desc->beaconInterval;
4151 mgmt->u.probe_resp.capab_info = bss_desc->capabilityInfo;
Madan Mohan Koyyalamudi86f629e2012-11-09 16:27:29 -08004152
4153#ifdef WLAN_ENABLE_AGEIE_ON_SCAN_RESULTS
4154 /* GPS Requirement: need age ie per entry. Using vendor specific. */
4155 /* Assuming this is the last IE, copy at the end */
4156 ie_length -=sizeof(qcom_ie_age);
4157 qie_age = (qcom_ie_age *)(mgmt->u.probe_resp.variable + ie_length);
4158 qie_age->element_id = QCOM_VENDOR_IE_ID;
4159 qie_age->len = QCOM_VENDOR_IE_AGE_LEN;
4160 qie_age->oui_1 = QCOM_OUI1;
4161 qie_age->oui_2 = QCOM_OUI2;
4162 qie_age->oui_3 = QCOM_OUI3;
4163 qie_age->type = QCOM_VENDOR_IE_AGE_TYPE;
4164 qie_age->age = vos_timer_get_system_ticks() - bss_desc->nReceivedTime;
4165#endif
4166
Jeff Johnson295189b2012-06-20 16:38:30 -07004167 memcpy(mgmt->u.probe_resp.variable, ie, ie_length);
Gopichand Nakkalad908ec82013-05-16 19:32:19 +05304168 if (bss_desc->fProbeRsp)
4169 {
4170 mgmt->frame_control |=
4171 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP);
4172 }
4173 else
4174 {
4175 mgmt->frame_control |=
4176 (u16)(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_BEACON);
4177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004178
4179#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304180 if (chan_no <= ARRAY_SIZE(hdd_channels_2_4_GHZ) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 (wiphy->bands[IEEE80211_BAND_2GHZ] != NULL))
4182 {
4183 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_2GHZ);
4184 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304185 else if ((chan_no > ARRAY_SIZE(hdd_channels_2_4_GHZ)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 (wiphy->bands[IEEE80211_BAND_5GHZ] != NULL))
4187
4188 {
4189 freq = ieee80211_channel_to_frequency(chan_no, IEEE80211_BAND_5GHZ);
4190 }
4191 else
4192 {
4193 kfree(mgmt);
4194 return NULL;
4195 }
4196#else
4197 freq = ieee80211_channel_to_frequency(chan_no);
4198#endif
4199 chan = __ieee80211_get_channel(wiphy, freq);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004200 /*when the band is changed on the fly using the GUI, three things are done
4201 * 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)
4202 * as part of the scan abort, message willbe queued to PE and we proceed with flushing and changinh the band.
4203 * pe will stop the scanning further and report back the results what ever it had till now by calling the call back function.
4204 * if the time between update band and scandone call back is sufficent enough the band change reflects in SME, SME validates the channels
4205 * and discards the channels correponding to previous band and calls back with zero bss results.
4206 * 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
4207 * all the channels correponding to previous band.this is due to race condition.but those channels are invalid to the new band and so
4208 * this function __ieee80211_get_channel will return NULL.Each time we report scan result with this pointer null warning kernel trace is printed.
4209 * if the scan results contain large number of APs continuosly kernel warning trace is printed and it will lead to apps watch dog bark.
4210 * So drop the bss and continue to next bss.
4211 */
4212 if(chan == NULL)
4213 {
4214 hddLog(VOS_TRACE_LEVEL_INFO, "%s chan pointer is NULL", __func__);
Chilam Ngc4244af2013-04-01 15:37:32 -07004215 kfree(mgmt);
Leela V Kiran Kumar Reddy90032de2013-01-24 18:33:30 -08004216 return NULL;
4217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004218 /*To keep the rssi icon of the connected AP in the scan window
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304219 *and the rssi icon of the wireless networks in sync
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 * */
4221 if (( eConnectionState_Associated ==
4222 pAdapter->sessionCtx.station.conn_info.connState ) &&
4223 ( VOS_TRUE == vos_mem_compare(bss_desc->bssId,
4224 pAdapter->sessionCtx.station.conn_info.bssId,
4225 WNI_CFG_BSSID_LEN)))
4226 {
4227 /* supplicant takes the signal strength in terms of mBm(100*dBm) */
4228 rssi = (pAdapter->rssi * 100);
4229 }
4230 else
4231 {
4232 rssi = (VOS_MIN ((bss_desc->rssi + bss_desc->sinr), 0))*100;
4233 }
4234
4235 bss_status = cfg80211_inform_bss_frame(wiphy, chan, mgmt,
4236 frame_len, rssi, GFP_KERNEL);
4237 kfree(mgmt);
4238 return bss_status;
4239}
4240
4241/*
4242 * FUNCTION: wlan_hdd_cfg80211_update_bss_db
4243 * This function is used to update the BSS data base of CFG8011
4244 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304245struct cfg80211_bss* wlan_hdd_cfg80211_update_bss_db( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 tCsrRoamInfo *pRoamInfo
4247 )
4248{
4249 tCsrRoamConnectedProfile roamProfile;
4250 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4251 struct cfg80211_bss *bss = NULL;
4252
4253 ENTER();
4254
4255 memset(&roamProfile, 0, sizeof(tCsrRoamConnectedProfile));
4256 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roamProfile);
4257
4258 if (NULL != roamProfile.pBssDesc)
4259 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304260 bss = wlan_hdd_cfg80211_inform_bss(pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004261 &roamProfile);
4262
4263 if (NULL == bss)
4264 {
4265 hddLog(VOS_TRACE_LEVEL_INFO, "%s: cfg80211_inform_bss return NULL",
4266 __func__);
4267 }
4268
4269 sme_RoamFreeConnectProfile(hHal, &roamProfile);
4270 }
4271 else
4272 {
4273 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: roamProfile.pBssDesc is NULL",
4274 __func__);
4275 }
4276 return bss;
4277}
4278
4279/*
4280 * FUNCTION: wlan_hdd_cfg80211_update_bss
4281 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304282static int wlan_hdd_cfg80211_update_bss( struct wiphy *wiphy,
4283 hdd_adapter_t *pAdapter
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 )
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304285{
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4287 tCsrScanResultInfo *pScanResult;
4288 eHalStatus status = 0;
4289 tScanResultHandle pResult;
4290 struct cfg80211_bss *bss_status = NULL;
Wilson Yangf80a0542013-10-07 13:02:37 -07004291 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004292
4293 ENTER();
4294
Wilson Yangf80a0542013-10-07 13:02:37 -07004295 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4296
4297 if (pHddCtx->isLogpInProgress)
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 {
Wilson Yangf80a0542013-10-07 13:02:37 -07004299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4300 "%s:LOGP in Progress. Ignore!!!",__func__);
4301 return -EAGAIN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 }
4303
Wilson Yangf80a0542013-10-07 13:02:37 -07004304
4305 /*bss_update is not allowed during wlan driver loading or unloading*/
4306 if (pHddCtx->isLoadUnloadInProgress)
4307 {
4308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4309 "%s:Loading_unloading in Progress. Ignore!!!",__func__);
4310 return VOS_STATUS_E_PERM;
4311 }
4312
4313
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 /*
4315 * start getting scan results and populate cgf80211 BSS database
4316 */
4317 status = sme_ScanGetResult(hHal, pAdapter->sessionId, NULL, &pResult);
4318
4319 /* no scan results */
4320 if (NULL == pResult)
4321 {
4322 hddLog(VOS_TRACE_LEVEL_INFO, "%s: No scan result\n", __func__);
4323 return status;
4324 }
4325
4326 pScanResult = sme_ScanResultGetFirst(hHal, pResult);
4327
4328 while (pScanResult)
4329 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304330 /*
4331 * cfg80211_inform_bss() is not updating ie field of bss entry, if
4332 * entry already exists in bss data base of cfg80211 for that
4333 * particular BSS ID. Using cfg80211_inform_bss_frame to update the
4334 * bss entry instead of cfg80211_inform_bss, But this call expects
4335 * mgmt packet as input. As of now there is no possibility to get
4336 * the mgmt(probe response) frame from PE, converting bss_desc to
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 * ieee80211_mgmt(probe response) and passing to c
4338 * fg80211_inform_bss_frame.
4339 * */
4340
4341 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4342 &pScanResult->BssDescriptor);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304343
Jeff Johnson295189b2012-06-20 16:38:30 -07004344
4345 if (NULL == bss_status)
4346 {
4347 hddLog(VOS_TRACE_LEVEL_INFO,
4348 "%s: NULL returned by cfg80211_inform_bss\n", __func__);
4349 }
4350 else
4351 {
Yue Maf49ba872013-08-19 12:04:25 -07004352 cfg80211_put_bss(
4353#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
4354 wiphy,
4355#endif
4356 bss_status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 }
4358
4359 pScanResult = sme_ScanResultGetNext(hHal, pResult);
4360 }
4361
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304362 sme_ScanResultPurge(hHal, pResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07004363
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304364 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004365}
4366
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004367void
4368hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel)
4369{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304370 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Arif Hussaina7c8e412013-11-20 11:06:42 -08004371 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(macAddr));
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004372} /****** end hddPrintMacAddr() ******/
4373
4374void
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004375hddPrintPmkId(tANI_U8 *pmkId, tANI_U8 logLevel)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004376{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304377 VOS_TRACE(VOS_MODULE_ID_HDD, logLevel,
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004378 "%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
4379 pmkId[0], pmkId[1], pmkId[2], pmkId[3], pmkId[4],
4380 pmkId[5], pmkId[6], pmkId[7], pmkId[8], pmkId[9], pmkId[10],
4381 pmkId[11], pmkId[12], pmkId[13], pmkId[14], pmkId[15]);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004382} /****** end hddPrintPmkId() ******/
4383
4384//hddPrintMacAddr(tCsrBssid macAddr, tANI_U8 logLevel);
4385//hddPrintMacAddr(macAddr, VOS_TRACE_LEVEL_FATAL);
4386
4387//void sirDumpBuf(tpAniSirGlobal pMac, tANI_U8 modId, tANI_U32 level, tANI_U8 *buf, tANI_U32 size);
4388//sirDumpBuf(pMac, VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL, pmkid, 16);
4389
4390#define dump_bssid(bssid) \
4391 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004392 hddLog(VOS_TRACE_LEVEL_INFO, "BSSID (MAC) address:\t"); \
4393 hddPrintMacAddr(bssid, VOS_TRACE_LEVEL_INFO);\
4394 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004395 }
4396
4397#define dump_pmkid(pMac, pmkid) \
4398 { \
Jeff Johnsone7245742012-09-05 17:12:55 -07004399 hddLog(VOS_TRACE_LEVEL_INFO, "PMKSA-ID:\t"); \
4400 hddPrintPmkId(pmkid, VOS_TRACE_LEVEL_INFO);\
4401 hddLog(VOS_TRACE_LEVEL_INFO, "\n"); \
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004402 }
4403
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004404#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004405/*
4406 * FUNCTION: wlan_hdd_cfg80211_pmksa_candidate_notify
4407 * This function is used to notify the supplicant of a new PMKSA candidate.
4408 */
4409int wlan_hdd_cfg80211_pmksa_candidate_notify(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304410 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004411 int index, bool preauth )
4412{
Jeff Johnsone7245742012-09-05 17:12:55 -07004413#ifdef FEATURE_WLAN_OKC
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004414 struct net_device *dev = pAdapter->dev;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004415 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004416
4417 ENTER();
Jeff Johnsone7245742012-09-05 17:12:55 -07004418 hddLog(VOS_TRACE_LEVEL_INFO, "%s is going to notify supplicant of:", __func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004419
4420 if( NULL == pRoamInfo )
4421 {
4422 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: pRoamInfo is NULL\n", __func__);
4423 return -EINVAL;
4424 }
4425
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004426 if (eANI_BOOLEAN_TRUE == hdd_is_okc_mode_enabled(pHddCtx))
4427 {
4428 dump_bssid(pRoamInfo->bssid);
4429 cfg80211_pmksa_candidate_notify(dev, index,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004430 pRoamInfo->bssid, preauth, GFP_KERNEL);
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07004431 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004432#endif /* FEATURE_WLAN_OKC */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304433 return 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004434}
4435#endif //FEATURE_WLAN_LFR
4436
Yue Maef608272013-04-08 23:09:17 -07004437#ifdef FEATURE_WLAN_LFR_METRICS
4438/*
4439 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth
4440 * 802.11r/LFR metrics reporting function to report preauth initiation
4441 *
4442 */
4443#define MAX_LFR_METRICS_EVENT_LENGTH 100
4444VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth(hdd_adapter_t *pAdapter,
4445 tCsrRoamInfo *pRoamInfo)
4446{
4447 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4448 union iwreq_data wrqu;
4449
4450 ENTER();
4451
4452 if (NULL == pAdapter)
4453 {
4454 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4455 return VOS_STATUS_E_FAILURE;
4456 }
4457
4458 /* create the event */
4459 memset(&wrqu, 0, sizeof(wrqu));
4460 memset(metrics_notification, 0, sizeof(metrics_notification));
4461
4462 wrqu.data.pointer = metrics_notification;
4463 wrqu.data.length = scnprintf(metrics_notification,
4464 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_INIT "
4465 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4466
4467 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4468
4469 EXIT();
4470
4471 return VOS_STATUS_SUCCESS;
4472}
4473
4474/*
4475 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_preauth_status
4476 * 802.11r/LFR metrics reporting function to report preauth completion
4477 * or failure
4478 */
4479VOS_STATUS wlan_hdd_cfg80211_roam_metrics_preauth_status(
4480 hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, bool preauth_status)
4481{
4482 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4483 union iwreq_data wrqu;
4484
4485 ENTER();
4486
4487 if (NULL == pAdapter)
4488 {
4489 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4490 return VOS_STATUS_E_FAILURE;
4491 }
4492
4493 /* create the event */
4494 memset(&wrqu, 0, sizeof(wrqu));
4495 memset(metrics_notification, 0, sizeof(metrics_notification));
4496
4497 scnprintf(metrics_notification, sizeof(metrics_notification),
4498 "QCOM: LFR_PREAUTH_STATUS "MAC_ADDRESS_STR,
4499 MAC_ADDR_ARRAY(pRoamInfo->bssid));
4500
4501 if (1 == preauth_status)
4502 strncat(metrics_notification, " TRUE", 5);
4503 else
4504 strncat(metrics_notification, " FALSE", 6);
4505
4506 wrqu.data.pointer = metrics_notification;
4507 wrqu.data.length = strlen(metrics_notification);
4508
4509 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4510
4511 EXIT();
4512
4513 return VOS_STATUS_SUCCESS;
4514}
4515
4516/*
4517 * FUNCTION: wlan_hdd_cfg80211_roam_metrics_handover
4518 * 802.11r/LFR metrics reporting function to report handover initiation
4519 *
4520 */
4521VOS_STATUS wlan_hdd_cfg80211_roam_metrics_handover(hdd_adapter_t * pAdapter,
4522 tCsrRoamInfo *pRoamInfo)
4523{
4524 unsigned char metrics_notification[MAX_LFR_METRICS_EVENT_LENGTH + 1];
4525 union iwreq_data wrqu;
4526
4527 ENTER();
4528
4529 if (NULL == pAdapter)
4530 {
4531 hddLog(LOGE, "%s: pAdapter is NULL!", __func__);
4532 return VOS_STATUS_E_FAILURE;
4533 }
4534
4535 /* create the event */
4536 memset(&wrqu, 0, sizeof(wrqu));
4537 memset(metrics_notification, 0, sizeof(metrics_notification));
4538
4539 wrqu.data.pointer = metrics_notification;
4540 wrqu.data.length = scnprintf(metrics_notification,
4541 sizeof(metrics_notification), "QCOM: LFR_PREAUTH_HANDOVER "
4542 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pRoamInfo->bssid));
4543
4544 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, metrics_notification);
4545
4546 EXIT();
4547
4548 return VOS_STATUS_SUCCESS;
4549}
4550#endif
4551
Jeff Johnson295189b2012-06-20 16:38:30 -07004552/*
4553 * FUNCTION: hdd_cfg80211_scan_done_callback
4554 * scanning callback function, called after finishing scan
4555 *
4556 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304557static eHalStatus hdd_cfg80211_scan_done_callback(tHalHandle halHandle,
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 void *pContext, tANI_U32 scanId, eCsrScanStatus status)
4559{
4560 struct net_device *dev = (struct net_device *) pContext;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304561 //struct wireless_dev *wdev = dev->ieee80211_ptr;
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004563 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4564 hdd_scaninfo_t *pScanInfo = &pHddCtx->scan_info;
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 struct cfg80211_scan_request *req = NULL;
4566 int ret = 0;
4567
4568 ENTER();
4569
4570 hddLog(VOS_TRACE_LEVEL_INFO,
4571 "%s called with halHandle = %p, pContext = %p,"
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304572 "scanID = %d, returned status = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 __func__, halHandle, pContext, (int) scanId, (int) status);
4574
Kiet Lamac06e2c2013-10-23 16:25:07 +05304575 pScanInfo->mScanPendingCounter = 0;
4576
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 //Block on scan req completion variable. Can't wait forever though.
4578 ret = wait_for_completion_interruptible_timeout(
4579 &pScanInfo->scan_req_completion_event,
4580 msecs_to_jiffies(WLAN_WAIT_TIME_SCAN_REQ));
4581 if (!ret)
4582 {
4583 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004584 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 }
4586
Yue Maef608272013-04-08 23:09:17 -07004587 if (pScanInfo->mScanPending != VOS_TRUE)
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 {
4589 VOS_ASSERT(pScanInfo->mScanPending);
Jeff Johnsone7245742012-09-05 17:12:55 -07004590 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 }
4592
4593 /* Check the scanId */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304594 if (pScanInfo->scanId != scanId)
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 {
4596 hddLog(VOS_TRACE_LEVEL_INFO,
4597 "%s called with mismatched scanId pScanInfo->scanId = %d "
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304598 "scanId = %d \n", __func__, (int) pScanInfo->scanId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 (int) scanId);
4600 }
4601
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304602 ret = wlan_hdd_cfg80211_update_bss((WLAN_HDD_GET_CTX(pAdapter))->wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 pAdapter);
4604
4605 if (0 > ret)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304606 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004607
4608
4609 /* If any client wait scan result through WEXT
4610 * send scan done event to client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004611 if (pHddCtx->scan_info.waitScanResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 {
4613 /* The other scan request waiting for current scan finish
4614 * Send event to notify current scan finished */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004615 if(WEXT_SCAN_PENDING_DELAY == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 {
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004617 vos_event_set(&pHddCtx->scan_info.scan_finished_event);
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 }
4619 /* Send notify to WEXT client */
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004620 else if(WEXT_SCAN_PENDING_PIGGYBACK == pHddCtx->scan_info.scan_pending_option)
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 {
4622 struct net_device *dev = pAdapter->dev;
4623 union iwreq_data wrqu;
4624 int we_event;
4625 char *msg;
4626
4627 memset(&wrqu, '\0', sizeof(wrqu));
4628 we_event = SIOCGIWSCAN;
4629 msg = NULL;
4630 wireless_send_event(dev, we_event, &wrqu, msg);
4631 }
4632 }
Madan Mohan Koyyalamudi2a1ba772012-10-11 14:59:06 -07004633 pHddCtx->scan_info.waitScanResult = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004634
4635 /* Get the Scan Req */
4636 req = pAdapter->request;
4637
4638 if (!req)
4639 {
4640 hddLog(VOS_TRACE_LEVEL_ERROR, "request is became NULL\n");
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004641 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnsone7245742012-09-05 17:12:55 -07004642 goto allow_suspend;
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 }
4644
4645 /*
4646 * setting up 0, just in case.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304647 */
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 req->n_ssids = 0;
4649 req->n_channels = 0;
4650 req->ie = 0;
4651
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 pAdapter->request = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07004653 /* Scan is no longer pending */
4654 pScanInfo->mScanPending = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004655
Madan Mohan Koyyalamudib764bf82012-10-11 16:38:51 -07004656 /*
4657 * cfg80211_scan_done informing NL80211 about completion
4658 * of scanning
4659 */
4660 cfg80211_scan_done(req, false);
Madan Mohan Koyyalamudif4e81002012-11-13 10:46:38 -08004661 complete(&pScanInfo->abortscan_event_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07004662
Jeff Johnsone7245742012-09-05 17:12:55 -07004663allow_suspend:
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07004664 /* release the wake lock at the end of the scan*/
4665 hdd_allow_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07004666
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004667 /* Acquire wakelock to handle the case where APP's tries to suspend
4668 * immediatly after the driver gets connect request(i.e after scan)
4669 * from supplicant, this result in app's is suspending and not able
4670 * to process the connect request to AP */
Amar Singhal6144c002013-05-03 16:11:42 -07004671 hdd_allow_suspend_timeout(1000);
Madan Mohan Koyyalamudi10d83a92012-09-28 15:47:05 -07004672
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004673#ifdef FEATURE_WLAN_TDLS
4674 wlan_hdd_tdls_scan_done_callback(pAdapter);
4675#endif
4676
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 EXIT();
4678 return 0;
4679}
4680
4681/*
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004682 * FUNCTION: hdd_isScanAllowed
4683 * Go through each adapter and check if scan allowed
4684 *
4685 */
4686v_BOOL_t hdd_isScanAllowed( hdd_context_t *pHddCtx )
4687{
4688 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
4689 hdd_station_ctx_t *pHddStaCtx = NULL;
4690 hdd_adapter_t *pAdapter = NULL;
4691 VOS_STATUS status = 0;
4692 v_U8_t staId = 0;
4693 v_U8_t *staMac = NULL;
4694
4695 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
4696
4697 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
4698 {
4699 pAdapter = pAdapterNode->pAdapter;
4700
4701 if( pAdapter )
4702 {
4703 hddLog(VOS_TRACE_LEVEL_INFO,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304704 "%s: Adapter with device mode %d exists",
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004705 __func__, pAdapter->device_mode);
4706 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
4707 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
4708 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode))
4709 {
4710 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4711 if ((eConnectionState_Associated == pHddStaCtx->conn_info.connState) &&
4712 (VOS_FALSE == pHddStaCtx->conn_info.uIsAuthenticated))
4713 {
4714 staMac = (v_U8_t *) &(pAdapter->macAddressCurrent.bytes[0]);
4715 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004716 "%s: client " MAC_ADDRESS_STR
4717 " is in the middle of WPS/EAPOL exchange.", __func__,
4718 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004719 return VOS_FALSE;
4720 }
4721 }
4722 else if ((WLAN_HDD_SOFTAP == pAdapter->device_mode) ||
4723 (WLAN_HDD_P2P_GO == pAdapter->device_mode))
4724 {
4725 for (staId = 0; staId < WLAN_MAX_STA_COUNT; staId++)
4726 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304727 if ((pAdapter->aStaInfo[staId].isUsed) &&
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004728 (WLANTL_STA_CONNECTED == pAdapter->aStaInfo[staId].tlSTAState))
4729 {
4730 staMac = (v_U8_t *) &(pAdapter->aStaInfo[staId].macAddrSTA.bytes[0]);
4731
4732 hddLog(VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08004733 "%s: client " MAC_ADDRESS_STR " of SoftAP/P2P-GO is in the "
4734 "middle of WPS/EAPOL exchange.", __func__,
4735 MAC_ADDR_ARRAY(staMac));
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004736 return VOS_FALSE;
4737 }
4738 }
4739 }
4740 }
4741 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
4742 pAdapterNode = pNext;
4743 }
4744 hddLog(VOS_TRACE_LEVEL_INFO,
4745 "%s: Scan allowed", __func__);
4746 return VOS_TRUE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304747}
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004748
4749/*
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 * FUNCTION: wlan_hdd_cfg80211_scan
4751 * this scan respond to scan trigger and update cfg80211 scan database
4752 * later, scan dump command can be used to recieve scan results
4753 */
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08004754int wlan_hdd_cfg80211_scan( struct wiphy *wiphy,
4755#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4756 struct net_device *dev,
4757#endif
4758 struct cfg80211_scan_request *request)
4759{
4760#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
4761 struct net_device *dev = request->wdev->netdev;
4762#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304763 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX( pAdapter );
4765 hdd_wext_state_t *pwextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304766 hdd_config_t *cfg_param = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 tCsrScanRequest scanRequest;
4768 tANI_U8 *channelList = NULL, i;
4769 v_U32_t scanId = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304770 int status;
4771 hdd_scaninfo_t *pScanInfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004772 v_U8_t* pP2pIe = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004773
4774 ENTER();
4775
4776 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
4777 __func__,pAdapter->device_mode);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004778
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05304779 status = wlan_hdd_validate_context(pHddCtx);
4780
4781 if (0 != status)
4782 {
4783 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4784 "%s: HDD context is not valid", __func__);
4785 return status;
4786 }
4787
4788 cfg_param = pHddCtx->cfg_ini;
4789 pScanInfo = &pHddCtx->scan_info;
4790
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004791 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004792 (eConnectionState_Connecting ==
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004793 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004794 {
4795 hddLog(VOS_TRACE_LEVEL_ERROR,
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08004796 "%s: %p(%d) Connection in progress: Scan request denied (EBUSY)", __func__, \
4797 WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pAdapter->sessionId);
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004798 return -EBUSY;
4799 }
4800
Jeff Johnson295189b2012-06-20 16:38:30 -07004801#ifdef WLAN_BTAMP_FEATURE
4802 //Scan not supported when AMP traffic is on.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004803 if (VOS_TRUE == WLANBAP_AmpSessionOn())
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 {
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08004805 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 "%s: No scanning when AMP is on", __func__);
4807 return -EOPNOTSUPP;
4808 }
4809#endif
4810 //Scan on any other interface is not supported.
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004811 if (pAdapter->device_mode == WLAN_HDD_SOFTAP)
Jeff Johnson295189b2012-06-20 16:38:30 -07004812 {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004813 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 "%s: Not scanning on device_mode = %d",
4815 __func__, pAdapter->device_mode);
4816 return -EOPNOTSUPP;
4817 }
4818
4819 if (TRUE == pScanInfo->mScanPending)
4820 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304821 if ( MAX_PENDING_LOG > pScanInfo->mScanPendingCounter++ )
4822 {
4823 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: mScanPending is TRUE", __func__);
4824 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004825 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004826 }
4827
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304828 //Don't Allow Scan and return busy if Remain On
Jeff Johnson32d95a32012-09-10 13:15:23 -07004829 //Channel and action frame is pending
4830 //Otherwise Cancel Remain On Channel and allow Scan
4831 //If no action frame pending
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004832 if (0 != wlan_hdd_check_remain_on_channel(pAdapter))
Jeff Johnson32d95a32012-09-10 13:15:23 -07004833 {
Kiet Lamac06e2c2013-10-23 16:25:07 +05304834 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Remain On Channel Pending", __func__);
Jeff Johnson32d95a32012-09-10 13:15:23 -07004835 return -EBUSY;
4836 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004837#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004838 /* if tdls disagree scan right now, return immediately.
4839 tdls will schedule the scan when scan is allowed. (return SUCCESS)
4840 or will reject the scan if any TDLS is in progress. (return -EBUSY)
4841 */
4842 status = wlan_hdd_tdls_scan_callback (pAdapter,
4843 wiphy,
4844#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
4845 dev,
Gopichand Nakkalac3c42b92013-03-20 19:42:34 -07004846#endif
Gopichand Nakkala638ebc72013-03-21 18:04:02 -07004847 request);
4848 if(status <= 0)
4849 {
4850 hddLog(VOS_TRACE_LEVEL_INFO, "%s: TDLS Pending %d", __func__, status);
4851 return status;
Gopichand Nakkala681989c2013-03-06 22:27:48 -08004852 }
4853#endif
Jeff Johnson32d95a32012-09-10 13:15:23 -07004854
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 if (mutex_lock_interruptible(&pHddCtx->tmInfo.tmOperationLock))
4856 {
4857 VOS_TRACE(VOS_MODULE_ID_HDD,VOS_TRACE_LEVEL_ERROR,
Jeff Johnson1250df42012-12-10 14:31:52 -08004858 "%s: Acquire lock fail", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 return -EAGAIN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 if (TRUE == pHddCtx->tmInfo.tmAction.enterImps)
4862 {
4863 hddLog(VOS_TRACE_LEVEL_WARN,
4864 "%s: MAX TM Level Scan not allowed", __func__);
4865 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304866 return -EBUSY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 }
4868 mutex_unlock(&pHddCtx->tmInfo.tmOperationLock);
4869
Madan Mohan Koyyalamudicfd53742013-01-11 15:29:03 -08004870 /* Check if scan is allowed at this point of time.
4871 */
4872 if (!hdd_isScanAllowed(pHddCtx))
4873 {
4874 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Scan not allowed", __func__);
4875 return -EBUSY;
4876 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304877
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 vos_mem_zero( &scanRequest, sizeof(scanRequest));
4879
4880 if (NULL != request)
4881 {
4882 hddLog(VOS_TRACE_LEVEL_INFO, "scan request for ssid = %d",
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304883 (int)request->n_ssids);
Jeff Johnson295189b2012-06-20 16:38:30 -07004884
4885 /* Even though supplicant doesn't provide any SSIDs, n_ssids is set to 1.
4886 * Becasue of this, driver is assuming that this is not wildcard scan and so
4887 * is not aging out the scan results.
4888 */
Jeff Johnson32d95a32012-09-10 13:15:23 -07004889 if (request->ssids && '\0' == request->ssids->ssid[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 {
4891 request->n_ssids = 0;
4892 }
4893
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07004894 if ((request->ssids) && (0 < request->n_ssids))
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 {
4896 tCsrSSIDInfo *SsidInfo;
4897 int j;
4898 scanRequest.SSIDs.numOfSSIDs = request->n_ssids;
4899 /* Allocate num_ssid tCsrSSIDInfo structure */
4900 SsidInfo = scanRequest.SSIDs.SSIDList =
4901 ( tCsrSSIDInfo *)vos_mem_malloc(
4902 request->n_ssids*sizeof(tCsrSSIDInfo));
4903
4904 if(NULL == scanRequest.SSIDs.SSIDList)
4905 {
4906 hddLog(VOS_TRACE_LEVEL_ERROR,
4907 "memory alloc failed SSIDInfo buffer");
4908 return -ENOMEM;
4909 }
4910
4911 /* copy all the ssid's and their length */
4912 for(j = 0; j < request->n_ssids; j++, SsidInfo++)
4913 {
4914 /* get the ssid length */
4915 SsidInfo->SSID.length = request->ssids[j].ssid_len;
4916 vos_mem_copy(SsidInfo->SSID.ssId, &request->ssids[j].ssid[0],
4917 SsidInfo->SSID.length);
4918 SsidInfo->SSID.ssId[SsidInfo->SSID.length] = '\0';
4919 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "SSID number %d: %s",
4920 j, SsidInfo->SSID.ssId);
4921 }
4922 /* set the scan type to active */
4923 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4924 }
4925 else if(WLAN_HDD_P2P_GO == pAdapter->device_mode)
4926 {
4927 /* set the scan type to active */
4928 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4929 }
4930 else
4931 {
4932 /*Set the scan type to default type, in this case it is ACTIVE*/
4933 scanRequest.scanType = pScanInfo->scan_mode;
4934 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304935 scanRequest.minChnTime = cfg_param->nActiveMinChnTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 scanRequest.maxChnTime = cfg_param->nActiveMaxChnTime;
4937 }
4938 else
4939 {
4940 /* set the scan type to active */
4941 scanRequest.scanType = eSIR_ACTIVE_SCAN;
4942 vos_mem_set( scanRequest.bssid, sizeof( tCsrBssid ), 0xff );
4943
4944 /* set min and max channel time to zero */
4945 scanRequest.minChnTime = 0;
4946 scanRequest.maxChnTime = 0;
4947 }
4948
4949 /* set BSSType to default type */
4950 scanRequest.BSSType = eCSR_BSS_TYPE_ANY;
4951
4952 /*TODO: scan the requested channels only*/
4953
4954 /*Right now scanning all the channels */
4955 if( request )
4956 {
4957 if( request->n_channels )
4958 {
4959 channelList = vos_mem_malloc( request->n_channels );
4960 if( NULL == channelList )
4961 {
4962 status = -ENOMEM;
4963 goto free_mem;
4964 }
4965
4966 for( i = 0 ; i < request->n_channels ; i++ )
4967 channelList[i] = request->channels[i]->hw_value;
4968 }
4969
4970 scanRequest.ChannelInfo.numOfChannels = request->n_channels;
4971 scanRequest.ChannelInfo.ChannelList = channelList;
4972
4973 /* set requestType to full scan */
4974 scanRequest.requestType = eCSR_SCAN_REQUEST_FULL_SCAN;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304975
4976 /* Flush the scan results(only p2p beacons) for STA scan and P2P
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004977 * search (Flush on both full scan and social scan but not on single
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304978 * channel scan).P2P search happens on 3 social channels (1, 6, 11)
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004979 */
4980
4981 /* Supplicant does single channel scan after 8-way handshake
Gopichand Nakkala747461f2013-04-24 19:24:45 +05304982 * and in that case driver shoudnt flush scan results. If
4983 * driver flushes the scan results here and unfortunately if
4984 * the AP doesnt respond to our probe req then association
Madan Mohan Koyyalamudi8d50f312012-11-27 15:48:57 -08004985 * fails which is not desired
4986 */
4987
4988 if( request->n_channels != WLAN_HDD_P2P_SINGLE_CHANNEL_SCAN )
4989 {
4990 sme_ScanFlushP2PResult( WLAN_HDD_GET_HAL_CTX(pAdapter),
4991 pAdapter->sessionId );
4992 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004993
4994 if( request->ie_len )
4995 {
4996 /* save this for future association (join requires this) */
4997 memset( &pScanInfo->scanAddIE, 0, sizeof(pScanInfo->scanAddIE) );
4998 memcpy( pScanInfo->scanAddIE.addIEdata, request->ie, request->ie_len);
4999 pScanInfo->scanAddIE.length = request->ie_len;
5000
5001 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
Jeff Johnsone7245742012-09-05 17:12:55 -07005002 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) ||
5003 (WLAN_HDD_P2P_DEVICE == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 )
5005 {
5006 pwextBuf->roamProfile.pAddIEScan = pScanInfo->scanAddIE.addIEdata;
5007 pwextBuf->roamProfile.nAddIEScanLength = pScanInfo->scanAddIE.length;
5008 }
5009
5010 scanRequest.uIEFieldLen = pScanInfo->scanAddIE.length;
5011 scanRequest.pIEField = pScanInfo->scanAddIE.addIEdata;
5012
Jeff Johnson295189b2012-06-20 16:38:30 -07005013 pP2pIe = wlan_hdd_get_p2p_ie_ptr((v_U8_t*)request->ie,
5014 request->ie_len);
5015 if (pP2pIe != NULL)
5016 {
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07005017#ifdef WLAN_FEATURE_P2P_DEBUG
5018 if (((globalP2PConnectionStatus == P2P_GO_NEG_COMPLETED) ||
5019 (globalP2PConnectionStatus == P2P_GO_NEG_PROCESS)) &&
5020 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5021 {
5022 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_1;
5023 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5024 "Go nego completed to Connection is started");
5025 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5026 "for 8way Handshake");
5027 }
5028 else if((globalP2PConnectionStatus == P2P_CLIENT_DISCONNECTED_STATE) &&
5029 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5030 {
5031 globalP2PConnectionStatus = P2P_CLIENT_CONNECTING_STATE_2;
5032 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
5033 "Disconnected state to Connection is started");
5034 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P]P2P Scanning is started "
5035 "for 4way Handshake");
5036 }
5037#endif
5038
Jeff Johnsone7245742012-09-05 17:12:55 -07005039 /* no_cck will be set during p2p find to disable 11b rates */
5040 if(TRUE == request->no_cck)
Jeff Johnson295189b2012-06-20 16:38:30 -07005041 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 hddLog(VOS_TRACE_LEVEL_INFO,
5043 "%s: This is a P2P Search", __func__);
5044 scanRequest.p2pSearch = 1;
Jeff Johnsone7245742012-09-05 17:12:55 -07005045
Jeff Johnsone7245742012-09-05 17:12:55 -07005046 if( request->n_channels == WLAN_HDD_P2P_SOCIAL_CHANNELS )
5047 {
Madan Mohan Koyyalamudi1b1d9e82012-10-21 11:38:33 -07005048 /* set requestType to P2P Discovery */
5049 scanRequest.requestType = eCSR_SCAN_P2P_DISCOVERY;
Jeff Johnsone7245742012-09-05 17:12:55 -07005050 }
5051
5052 /*
5053 Skip Dfs Channel in case of P2P Search
5054 if it is set in ini file
5055 */
5056 if(cfg_param->skipDfsChnlInP2pSearch)
5057 {
5058 scanRequest.skipDfsChnlInP2pSearch = 1;
5059 }
5060 else
5061 {
5062 scanRequest.skipDfsChnlInP2pSearch = 0;
5063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005064
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 }
5066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 }
5068 }
5069
5070 INIT_COMPLETION(pScanInfo->scan_req_completion_event);
5071
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005072 /* acquire the wakelock to avoid the apps suspend during the scan. To
5073 * address the following issues.
5074 * 1) Disconnected scenario: we are not allowing the suspend as WLAN is not in
5075 * BMPS/IMPS this result in android trying to suspend aggressively and backing off
5076 * for long time, this result in apps running at full power for long time.
5077 * 2) Connected scenario: If we allow the suspend during the scan, RIVA will
5078 * be stuck in full power because of resume BMPS
5079 */
5080 hdd_prevent_suspend();
Jeff Johnsone7245742012-09-05 17:12:55 -07005081
5082 status = sme_ScanRequest( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005083 pAdapter->sessionId, &scanRequest, &scanId,
5084 &hdd_cfg80211_scan_done_callback, dev );
Jeff Johnsone7245742012-09-05 17:12:55 -07005085
Jeff Johnson295189b2012-06-20 16:38:30 -07005086 if (eHAL_STATUS_SUCCESS != status)
5087 {
5088 hddLog(VOS_TRACE_LEVEL_ERROR,
5089 "%s: sme_ScanRequest returned error %d", __func__, status);
5090 complete(&pScanInfo->scan_req_completion_event);
Madan Mohan Koyyalamudi3b230fe2012-10-18 14:46:32 -07005091 if(eHAL_STATUS_RESOURCES == status)
5092 {
Madan Mohan Koyyalamudia3fcf142012-10-18 15:01:20 -07005093 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 -07005094 status = -EBUSY;
5095 } else {
5096 status = -EIO;
5097 }
Madan Mohan Koyyalamudi9f5a10c2012-09-28 14:46:16 -07005098 hdd_allow_suspend();
Jeff Johnson295189b2012-06-20 16:38:30 -07005099 goto free_mem;
5100 }
5101
5102 pScanInfo->mScanPending = TRUE;
5103 pAdapter->request = request;
5104 pScanInfo->scanId = scanId;
5105
5106 complete(&pScanInfo->scan_req_completion_event);
5107
5108free_mem:
5109 if( scanRequest.SSIDs.SSIDList )
5110 {
5111 vos_mem_free(scanRequest.SSIDs.SSIDList);
5112 }
5113
5114 if( channelList )
5115 vos_mem_free( channelList );
5116
5117 EXIT();
5118
5119 return status;
5120}
5121
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005122
5123void hdd_select_cbmode( hdd_adapter_t *pAdapter,v_U8_t operationChannel)
5124{
5125 v_U8_t iniDot11Mode =
5126 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->dot11Mode;
5127 eHddDot11Mode hddDot11Mode = iniDot11Mode;
5128
5129 switch ( iniDot11Mode )
5130 {
5131 case eHDD_DOT11_MODE_AUTO:
5132 case eHDD_DOT11_MODE_11ac:
5133 case eHDD_DOT11_MODE_11ac_ONLY:
5134#ifdef WLAN_FEATURE_11AC
5135 hddDot11Mode = eHDD_DOT11_MODE_11ac;
5136#else
5137 hddDot11Mode = eHDD_DOT11_MODE_11n;
5138#endif
5139 break;
5140 case eHDD_DOT11_MODE_11n:
5141 case eHDD_DOT11_MODE_11n_ONLY:
5142 hddDot11Mode = eHDD_DOT11_MODE_11n;
5143 break;
5144 default:
5145 hddDot11Mode = iniDot11Mode;
5146 break;
5147 }
5148 /* This call decides required channel bonding mode */
5149 sme_SelectCBMode((WLAN_HDD_GET_CTX(pAdapter)->hHal),
5150 hdd_cfg_xlate_to_csr_phy_mode(hddDot11Mode),
5151 operationChannel);
5152}
5153
Jeff Johnson295189b2012-06-20 16:38:30 -07005154/*
5155 * FUNCTION: wlan_hdd_cfg80211_connect_start
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305156 * This function is used to start the association process
Jeff Johnson295189b2012-06-20 16:38:30 -07005157 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305158int wlan_hdd_cfg80211_connect_start( hdd_adapter_t *pAdapter,
Jeff Johnson32d95a32012-09-10 13:15:23 -07005159 const u8 *ssid, size_t ssid_len, const u8 *bssid, u8 operatingChannel)
Jeff Johnson295189b2012-06-20 16:38:30 -07005160{
5161 int status = 0;
5162 hdd_wext_state_t *pWextState;
5163 v_U32_t roamId;
5164 tCsrRoamProfile *pRoamProfile;
5165 eMib_dot11DesiredBssType connectedBssType;
5166 eCsrAuthType RSNAuthType;
5167
5168 ENTER();
5169
5170 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305171
Jeff Johnson295189b2012-06-20 16:38:30 -07005172 if (SIR_MAC_MAX_SSID_LENGTH < ssid_len)
5173 {
5174 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: wrong SSID len", __func__);
5175 return -EINVAL;
5176 }
5177
5178 pRoamProfile = &pWextState->roamProfile;
5179
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305180 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07005181 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005182 int ret = 0;
5183 hdd_station_ctx_t *pHddStaCtx;
5184 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5185 hdd_connGetConnectedBssType(pHddStaCtx,&connectedBssType );
5186
5187 if((eMib_dot11DesiredBssType_independent == connectedBssType) ||
5188 (eConnectionState_Associated == pHddStaCtx->conn_info.connState) ||
5189 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 {
5191 /* Issue disconnect to CSR */
5192 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305193 if( eHAL_STATUS_SUCCESS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
5195 pAdapter->sessionId,
5196 eCSR_DISCONNECT_REASON_UNSPECIFIED ) )
5197 {
Jeff Johnsone7245742012-09-05 17:12:55 -07005198 ret = wait_for_completion_interruptible_timeout(
5199 &pAdapter->disconnect_comp_var,
5200 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5201 if (0 == ret)
5202 {
5203 VOS_ASSERT(0);
5204 }
5205 }
5206 }
5207 else if(eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState)
5208 {
5209 ret = wait_for_completion_interruptible_timeout(
5210 &pAdapter->disconnect_comp_var,
5211 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
5212 if (0 == ret)
5213 {
5214 VOS_ASSERT(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005215 }
5216 }
5217
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305218 if (HDD_WMM_USER_MODE_NO_QOS ==
Jeff Johnson295189b2012-06-20 16:38:30 -07005219 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->WmmMode)
5220 {
5221 /*QoS not enabled in cfg file*/
5222 pRoamProfile->uapsd_mask = 0;
5223 }
5224 else
5225 {
5226 /*QoS enabled, update uapsd mask from cfg file*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305227 pRoamProfile->uapsd_mask =
Jeff Johnson295189b2012-06-20 16:38:30 -07005228 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->UapsdMask;
5229 }
5230
5231 pRoamProfile->SSIDs.numOfSSIDs = 1;
5232 pRoamProfile->SSIDs.SSIDList->SSID.length = ssid_len;
5233 vos_mem_zero(pRoamProfile->SSIDs.SSIDList->SSID.ssId,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305234 sizeof(pRoamProfile->SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 vos_mem_copy((void *)(pRoamProfile->SSIDs.SSIDList->SSID.ssId),
5236 ssid, ssid_len);
5237
5238 if (bssid)
5239 {
5240 pRoamProfile->BSSIDs.numOfBSSIDs = 1;
5241 vos_mem_copy((void *)(pRoamProfile->BSSIDs.bssid), bssid,
5242 WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305243 /* Save BSSID in seperate variable as well, as RoamProfile
5244 BSSID is getting zeroed out in the association process. And in
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 case of join failure we should send valid BSSID to supplicant
5246 */
5247 vos_mem_copy((void *)(pWextState->req_bssId), bssid,
5248 WNI_CFG_BSSID_LEN);
5249 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07005250 else
5251 {
5252 vos_mem_zero((void *)(pRoamProfile->BSSIDs.bssid),WNI_CFG_BSSID_LEN);
5253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005254
5255 if ((IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion) ||
5256 (IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion))
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305257 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005258 /*set gen ie*/
5259 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5260 /*set auth*/
5261 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005263#ifdef FEATURE_WLAN_WAPI
5264 if (pAdapter->wapi_info.nWapiMode)
5265 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005266 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005267 switch (pAdapter->wapi_info.wapiAuthMode)
5268 {
5269 case WAPI_AUTH_MODE_PSK:
5270 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005271 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 pAdapter->wapi_info.wapiAuthMode);
5273 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5274 break;
5275 }
5276 case WAPI_AUTH_MODE_CERT:
5277 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005278 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 pAdapter->wapi_info.wapiAuthMode);
5280 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5281 break;
5282 }
5283 } // End of switch
5284 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5285 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5286 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005287 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005288 pRoamProfile->AuthType.numEntries = 1;
5289 pRoamProfile->EncryptionType.numEntries = 1;
5290 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5291 pRoamProfile->mcEncryptionType.numEntries = 1;
5292 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5293 }
5294 }
5295#endif /* FEATURE_WLAN_WAPI */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305296#ifdef WLAN_FEATURE_GTK_OFFLOAD
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305297 /* Initializing gtkOffloadReqParams */
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305298 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
5299 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5300 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05305301 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
5302 sizeof (tSirGtkOffloadParams));
5303 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05305304 }
5305#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005306 pRoamProfile->csrPersona = pAdapter->device_mode;
5307
Jeff Johnson32d95a32012-09-10 13:15:23 -07005308 if( operatingChannel )
5309 {
5310 pRoamProfile->ChannelInfo.ChannelList = &operatingChannel;
5311 pRoamProfile->ChannelInfo.numOfChannels = 1;
5312 }
Chet Lanctot186b5732013-03-18 10:26:30 -07005313 else
5314 {
5315 pRoamProfile->ChannelInfo.ChannelList = NULL;
5316 pRoamProfile->ChannelInfo.numOfChannels = 0;
5317 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005318 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) && operatingChannel)
5319 {
5320 hdd_select_cbmode(pAdapter,operatingChannel);
5321 }
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005322 /* change conn_state to connecting before sme_RoamConnect(), because sme_RoamConnect()
5323 * has a direct path to call hdd_smeRoamCallback(), which will change the conn_state
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305324 * If direct path, conn_state will be accordingly changed to NotConnected or Associated
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005325 * by either hdd_AssociationCompletionHandler() or hdd_DisConnectHandler() in sme_RoamCallback()
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005326 * if sme_RomConnect is to be queued, Connecting state will remain until it is completed.
5327 */
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305328 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5329 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005330 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5331 eConnectionState_Connecting);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305332
5333 status = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 pAdapter->sessionId, pRoamProfile, &roamId);
5335
Gopichand Nakkalaa3c8fb62013-06-21 15:36:42 +05305336 if ((eHAL_STATUS_SUCCESS != status) &&
5337 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5338 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305339
5340 {
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005341 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: sme_RoamConnect (session %d) failed with "
5342 "status %d. -> NotConnected", __func__, pAdapter->sessionId, status);
5343 /* change back to NotAssociated */
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305344 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
Madan Mohan Koyyalamudi42dcd162012-12-03 16:34:04 -08005345 eConnectionState_NotConnected);
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +05305346 }
Madan Mohan Koyyalamudidf86c422012-12-04 17:03:44 -08005347
5348 pRoamProfile->ChannelInfo.ChannelList = NULL;
5349 pRoamProfile->ChannelInfo.numOfChannels = 0;
5350
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 }
5352 else
5353 {
5354 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid Roam profile", __func__);
5355 return -EINVAL;
5356 }
Madan Mohan Koyyalamudifd4e1da2012-11-09 17:50:19 -08005357 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 return status;
5359}
5360
5361/*
5362 * FUNCTION: wlan_hdd_set_cfg80211_auth_type
5363 * This function is used to set the authentication type (OPEN/SHARED).
5364 *
5365 */
5366static int wlan_hdd_cfg80211_set_auth_type(hdd_adapter_t *pAdapter,
5367 enum nl80211_auth_type auth_type)
5368{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305369 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5371
5372 ENTER();
5373
5374 /*set authentication type*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305375 switch (auth_type)
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 case NL80211_AUTHTYPE_AUTOMATIC:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305378 hddLog(VOS_TRACE_LEVEL_INFO,
5379 "%s: set authentication type to AUTOSWITCH", __func__);
5380 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_AUTOSWITCH;
5381 break;
5382
5383 case NL80211_AUTHTYPE_OPEN_SYSTEM:
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07005384#ifdef WLAN_FEATURE_VOWIFI_11R
5385 case NL80211_AUTHTYPE_FT:
5386#endif /* WLAN_FEATURE_VOWIFI_11R */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305387 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 "%s: set authentication type to OPEN", __func__);
5389 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5390 break;
5391
5392 case NL80211_AUTHTYPE_SHARED_KEY:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305393 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 "%s: set authentication type to SHARED", __func__);
5395 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5396 break;
5397#ifdef FEATURE_WLAN_CCX
5398 case NL80211_AUTHTYPE_NETWORK_EAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305399 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07005400 "%s: set authentication type to CCKM WPA", __func__);
5401 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_CCKM_WPA;//eCSR_AUTH_TYPE_CCKM_RSN needs to be handled as well if required.
5402 break;
5403#endif
5404
5405
5406 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305407 hddLog(VOS_TRACE_LEVEL_ERROR,
5408 "%s: Unsupported authentication type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 auth_type);
5410 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_UNKNOWN;
5411 return -EINVAL;
5412 }
5413
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305414 pWextState->roamProfile.AuthType.authType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005415 pHddStaCtx->conn_info.authType;
5416 return 0;
5417}
5418
5419/*
5420 * FUNCTION: wlan_hdd_set_akm_suite
5421 * This function is used to set the key mgmt type(PSK/8021x).
5422 *
5423 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305424static int wlan_hdd_set_akm_suite( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 u32 key_mgmt
5426 )
5427{
5428 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5429 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305430
Jeff Johnson295189b2012-06-20 16:38:30 -07005431 /*set key mgmt type*/
5432 switch(key_mgmt)
5433 {
5434 case WLAN_AKM_SUITE_PSK:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305435#ifdef WLAN_FEATURE_VOWIFI_11R
5436 case WLAN_AKM_SUITE_FT_PSK:
5437#endif
5438 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to PSK",
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 __func__);
5440 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5441 break;
5442
5443 case WLAN_AKM_SUITE_8021X:
Gopichand Nakkala356fb102013-03-06 12:34:04 +05305444#ifdef WLAN_FEATURE_VOWIFI_11R
5445 case WLAN_AKM_SUITE_FT_8021X:
5446#endif
5447 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to 8021x",
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 __func__);
5449 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5450 break;
5451#ifdef FEATURE_WLAN_CCX
5452#define WLAN_AKM_SUITE_CCKM 0x00409600 /* Should be in ieee802_11_defs.h */
5453#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5454 case WLAN_AKM_SUITE_CCKM:
5455 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting key mgmt type to CCKM",
5456 __func__);
5457 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5458 break;
5459#endif
5460
5461 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305462 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported key mgmt type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 __func__, key_mgmt);
5464 return -EINVAL;
5465
5466 }
5467 return 0;
5468}
5469
5470/*
5471 * FUNCTION: wlan_hdd_cfg80211_set_cipher
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305472 * This function is used to set the encryption type
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 * (NONE/WEP40/WEP104/TKIP/CCMP).
5474 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305475static int wlan_hdd_cfg80211_set_cipher( hdd_adapter_t *pAdapter,
5476 u32 cipher,
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 bool ucast
5478 )
5479{
5480 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305481 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5483
5484 ENTER();
5485
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305486 if (!cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305488 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: received cipher %d - considering none",
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 __func__, cipher);
5490 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5491 }
5492 else
5493 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305494
Jeff Johnson295189b2012-06-20 16:38:30 -07005495 /*set encryption method*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305496 switch (cipher)
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 {
5498 case IW_AUTH_CIPHER_NONE:
5499 encryptionType = eCSR_ENCRYPT_TYPE_NONE;
5500 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305501
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 case WLAN_CIPHER_SUITE_WEP40:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305503 encryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305505
Jeff Johnson295189b2012-06-20 16:38:30 -07005506 case WLAN_CIPHER_SUITE_WEP104:
Gopichand Nakkala29149562013-05-10 21:43:41 +05305507 encryptionType = eCSR_ENCRYPT_TYPE_WEP104;
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305509
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 case WLAN_CIPHER_SUITE_TKIP:
5511 encryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5512 break;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305513
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 case WLAN_CIPHER_SUITE_CCMP:
5515 encryptionType = eCSR_ENCRYPT_TYPE_AES;
5516 break;
5517#ifdef FEATURE_WLAN_WAPI
5518 case WLAN_CIPHER_SUITE_SMS4:
5519 encryptionType = eCSR_ENCRYPT_TYPE_WPI;
5520 break;
5521#endif
5522
5523#ifdef FEATURE_WLAN_CCX
5524 case WLAN_CIPHER_SUITE_KRK:
5525 encryptionType = eCSR_ENCRYPT_TYPE_KRK;
5526 break;
5527#endif
5528 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305529 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Unsupported cipher type %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 __func__, cipher);
5531 return -EOPNOTSUPP;
5532 }
5533 }
5534
5535 if (ucast)
5536 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305537 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting unicast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005538 __func__, encryptionType);
5539 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
5540 pWextState->roamProfile.EncryptionType.numEntries = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305541 pWextState->roamProfile.EncryptionType.encryptionType[0] =
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 encryptionType;
5543 }
5544 else
5545 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305546 hddLog(VOS_TRACE_LEVEL_INFO, "%s: setting mcast cipher type to %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07005547 __func__, encryptionType);
5548 pHddStaCtx->conn_info.mcEncryptionType = encryptionType;
5549 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
5550 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = encryptionType;
5551 }
5552
5553 return 0;
5554}
5555
5556
5557/*
5558 * FUNCTION: wlan_hdd_cfg80211_set_ie
5559 * This function is used to parse WPA/RSN IE's.
5560 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305561int wlan_hdd_cfg80211_set_ie( hdd_adapter_t *pAdapter,
5562 u8 *ie,
Jeff Johnson295189b2012-06-20 16:38:30 -07005563 size_t ie_len
5564 )
5565{
5566 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5567 u8 *genie = ie;
5568 v_U16_t remLen = ie_len;
5569#ifdef FEATURE_WLAN_WAPI
5570 v_U32_t akmsuite[MAX_NUM_AKM_SUITES];
5571 u16 *tmp;
5572 v_U16_t akmsuiteCount;
5573 int *akmlist;
5574#endif
5575 ENTER();
5576
5577 /* clear previous assocAddIE */
5578 pWextState->assocAddIE.length = 0;
5579 pWextState->roamProfile.bWPSAssociation = VOS_FALSE;
5580
5581 while (remLen >= 2)
5582 {
5583 v_U16_t eLen = 0;
5584 v_U8_t elementId;
5585 elementId = *genie++;
5586 eLen = *genie++;
5587 remLen -= 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305588
5589 hddLog(VOS_TRACE_LEVEL_INFO, "%s: IE[0x%X], LEN[%d]\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 __func__, elementId, eLen);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305591
5592 switch ( elementId )
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305594 case DOT11F_EID_WPA:
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005595 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 -07005596 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305597 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005598 "%s: Invalid WPA IE", __func__);
5599 return -EINVAL;
5600 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305601 else if (0 == memcmp(&genie[0], "\x00\x50\xf2\x04", 4))
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 {
5603 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305604 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPS IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005605 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305606
Jeff Johnson295189b2012-06-20 16:38:30 -07005607 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5608 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005609 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE. "
5610 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005611 VOS_ASSERT(0);
5612 return -ENOMEM;
5613 }
5614 // WSC IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5615 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5616 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305617
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 pWextState->roamProfile.bWPSAssociation = VOS_TRUE;
5619 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5620 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5621 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305622 else if (0 == memcmp(&genie[0], "\x00\x50\xf2", 3))
5623 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WPA IE (len %d)",__func__, eLen + 2);
5625 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5626 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2) /*ie_len*/);
5627 pWextState->roamProfile.pWPAReqIE = pWextState->WPARSNIE;
5628 pWextState->roamProfile.nWPAReqIELength = eLen + 2;//ie_len;
5629 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305630 else if ( (0 == memcmp(&genie[0], P2P_OUI_TYPE,
Kiet Lam8da98992013-11-21 15:59:07 +05305631 P2P_OUI_TYPE_SIZE)))
Jeff Johnson295189b2012-06-20 16:38:30 -07005632 {
5633 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305634 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set P2P IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005635 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305636
Jeff Johnson295189b2012-06-20 16:38:30 -07005637 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5638 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005639 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5640 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005641 VOS_ASSERT(0);
5642 return -ENOMEM;
5643 }
5644 // P2P IE is saved to Additional IE ; it should be accumulated to handle WPS IE + P2P IE
5645 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5646 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305647
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5649 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5650 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005651#ifdef WLAN_FEATURE_WFD
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305652 else if ( (0 == memcmp(&genie[0], WFD_OUI_TYPE,
5653 WFD_OUI_TYPE_SIZE))
Jeff Johnson295189b2012-06-20 16:38:30 -07005654 /*Consider WFD IE, only for P2P Client */
5655 && (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode) )
5656 {
5657 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305658 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set WFD IE(len %d)",
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305660
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5662 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005663 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5664 "Need bigger buffer space");
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 VOS_ASSERT(0);
5666 return -ENOMEM;
5667 }
5668 // WFD IE is saved to Additional IE ; it should be accumulated to handle
5669 // WPS IE + P2P IE + WFD IE
5670 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5671 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305672
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5674 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5675 }
5676#endif
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005677 /* Appending HS 2.0 Indication Element in Assiciation Request */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305678 else if ( (0 == memcmp(&genie[0], HS20_OUI_TYPE,
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005679 HS20_OUI_TYPE_SIZE)) )
5680 {
5681 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305682 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set HS20 IE(len %d)",
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005683 __func__, eLen + 2);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005684
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005685 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5686 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005687 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5688 "Need bigger buffer space");
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005689 VOS_ASSERT(0);
5690 return -ENOMEM;
5691 }
5692 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5693 pWextState->assocAddIE.length += eLen + 2;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005694
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07005695 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5696 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5697 }
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005698
Praveen Kumar Sirisilla7d68b7b2013-09-22 14:01:42 -07005699 if (WLAN_HDD_IBSS == pAdapter->device_mode) {
5700
5701 /* populating as ADDIE in beacon frames */
5702 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5703 WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, genie - 2, eLen + 2,
5704 NULL, eANI_BOOLEAN_FALSE)== eHAL_STATUS_SUCCESS)
5705 {
5706 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5707 WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG, 1,NULL,
5708 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5709 {
5710 hddLog(LOGE,
5711 "Coldn't pass "
5712 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_FLAG to CCM");
5713 }
5714 }/* ccmCfgSetStr(,WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA, , )*/
5715 else
5716 hddLog(LOGE,
5717 "Could not pass on "
5718 "WNI_CFG_PROBE_RSP_BCN_ADDNIE_DATA to CCM");
5719
5720 /* IBSS mode doesn't contain params->proberesp_ies still
5721 beaconIE's need to be populated in probe response frames */
5722 if ( (NULL != (genie - 2)) && (0 != eLen + 2) )
5723 {
5724 u16 rem_probe_resp_ie_len = eLen + 2;
5725 u8 probe_rsp_ie_len[3] = {0};
5726 u8 counter = 0;
5727
5728 /* Check Probe Resp Length if it is greater then 255 then
5729 Store Probe Rsp IEs into WNI_CFG_PROBE_RSP_ADDNIE_DATA1
5730 & WNI_CFG_PROBE_RSP_ADDNIE_DATA2 CFG Variable As We are
5731 not able Store More then 255 bytes into One Variable */
5732
5733 while ((rem_probe_resp_ie_len > 0) && (counter < 3))
5734 {
5735 if (rem_probe_resp_ie_len > MAX_CFG_STRING_LEN)
5736 {
5737 probe_rsp_ie_len[counter++] = MAX_CFG_STRING_LEN;
5738 rem_probe_resp_ie_len -= MAX_CFG_STRING_LEN;
5739 }
5740 else
5741 {
5742 probe_rsp_ie_len[counter++] = rem_probe_resp_ie_len;
5743 rem_probe_resp_ie_len = 0;
5744 }
5745 }
5746
5747 rem_probe_resp_ie_len = 0;
5748
5749 if (probe_rsp_ie_len[0] > 0)
5750 {
5751 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5752 WNI_CFG_PROBE_RSP_ADDNIE_DATA1,
5753 (tANI_U8*)(genie - 2),
5754 probe_rsp_ie_len[0], NULL,
5755 eANI_BOOLEAN_FALSE)
5756 == eHAL_STATUS_FAILURE)
5757 {
5758 hddLog(LOGE,
5759 "Could not pass"
5760 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA1 to CCM");
5761 }
5762 rem_probe_resp_ie_len += probe_rsp_ie_len[0];
5763 }
5764
5765 if (probe_rsp_ie_len[1] > 0)
5766 {
5767 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5768 WNI_CFG_PROBE_RSP_ADDNIE_DATA2,
5769 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5770 probe_rsp_ie_len[1], NULL,
5771 eANI_BOOLEAN_FALSE)
5772 == eHAL_STATUS_FAILURE)
5773 {
5774 hddLog(LOGE,
5775 "Could not pass"
5776 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA2 to CCM");
5777 }
5778 rem_probe_resp_ie_len += probe_rsp_ie_len[1];
5779 }
5780
5781 if (probe_rsp_ie_len[2] > 0)
5782 {
5783 if (ccmCfgSetStr(WLAN_HDD_GET_HAL_CTX(pAdapter),
5784 WNI_CFG_PROBE_RSP_ADDNIE_DATA3,
5785 (tANI_U8*)(genie - (2 + rem_probe_resp_ie_len)),
5786 probe_rsp_ie_len[2], NULL,
5787 eANI_BOOLEAN_FALSE)
5788 == eHAL_STATUS_FAILURE)
5789 {
5790 hddLog(LOGE,
5791 "Could not pass"
5792 "on WNI_CFG_PROBE_RSP_ADDNIE_DATA3 to CCM");
5793 }
5794 rem_probe_resp_ie_len += probe_rsp_ie_len[2];
5795 }
5796
5797 if (ccmCfgSetInt(WLAN_HDD_GET_HAL_CTX(pAdapter),
5798 WNI_CFG_PROBE_RSP_ADDNIE_FLAG, 1,NULL,
5799 eANI_BOOLEAN_FALSE) == eHAL_STATUS_FAILURE)
5800 {
5801 hddLog(LOGE,
5802 "Could not pass"
5803 "on WNI_CFG_PROBE_RSP_ADDNIE_FLAG to CCM");
5804 }
5805 }
5806 else
5807 {
5808 // Reset WNI_CFG_PROBE_RSP Flags
5809 wlan_hdd_reset_prob_rspies(pAdapter);
5810
5811 hddLog(VOS_TRACE_LEVEL_INFO,
5812 "%s: No Probe Response IE received in set beacon",
5813 __func__);
5814 }
5815 } /* end of if (WLAN_HDD_IBSS == pAdapter->device_mode) */
Jeff Johnson295189b2012-06-20 16:38:30 -07005816 break;
5817 case DOT11F_EID_RSN:
5818 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set RSN IE(len %d)",__func__, eLen + 2);
5819 memset( pWextState->WPARSNIE, 0, MAX_WPA_RSN_IE_LEN );
5820 memcpy( pWextState->WPARSNIE, genie - 2, (eLen + 2)/*ie_len*/);
5821 pWextState->roamProfile.pRSNReqIE = pWextState->WPARSNIE;
5822 pWextState->roamProfile.nRSNReqIELength = eLen + 2; //ie_len;
5823 break;
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005824 /* Appending Extended Capabilities with Interworking bit set in Assoc Req */
5825 case DOT11F_EID_EXTCAP:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305826 {
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005827 v_U16_t curAddIELen = pWextState->assocAddIE.length;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305828 hddLog (VOS_TRACE_LEVEL_INFO, "%s Set Extended CAPS IE(len %d)",
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005829 __func__, eLen + 2);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305830
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005831 if( SIR_MAC_MAX_IE_LENGTH < (pWextState->assocAddIE.length + eLen) )
5832 {
Jeff Johnson902c9832012-12-10 14:28:09 -08005833 hddLog(VOS_TRACE_LEVEL_FATAL, "Cannot accommodate assocAddIE "
5834 "Need bigger buffer space");
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005835 VOS_ASSERT(0);
5836 return -ENOMEM;
5837 }
5838 memcpy( pWextState->assocAddIE.addIEdata + curAddIELen, genie - 2, eLen + 2);
5839 pWextState->assocAddIE.length += eLen + 2;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305840
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005841 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5842 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5843 break;
5844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005845#ifdef FEATURE_WLAN_WAPI
5846 case WLAN_EID_WAPI:
5847 pAdapter->wapi_info.nWapiMode = 1; //Setting WAPI Mode to ON=1
Jeff Johnson0299d0a2013-10-30 12:37:43 -07005848 hddLog(VOS_TRACE_LEVEL_INFO, "WAPI MODE IS %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 pAdapter->wapi_info.nWapiMode);
5850 tmp = (u16 *)ie;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305851 tmp = tmp + 2; // Skip element Id and Len, Version
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 akmsuiteCount = WPA_GET_LE16(tmp);
5853 tmp = tmp + 1;
5854 akmlist = (int *)(tmp);
5855 if(akmsuiteCount <= MAX_NUM_AKM_SUITES)
5856 {
5857 memcpy(akmsuite, akmlist, (4*akmsuiteCount));
5858 }
5859 else
5860 {
5861 hddLog(VOS_TRACE_LEVEL_FATAL, "Invalid akmSuite count\n");
5862 VOS_ASSERT(0);
5863 return -EINVAL;
5864 }
5865
5866 if (WAPI_PSK_AKM_SUITE == akmsuite[0])
5867 {
5868 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO PSK",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005869 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_PSK;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 if (WAPI_CERT_AKM_SUITE == akmsuite[0])
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305873 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005874 hddLog(VOS_TRACE_LEVEL_INFO, "%s: WAPI AUTH MODE SET TO CERTIFICATE",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005875 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 pAdapter->wapi_info.wapiAuthMode = WAPI_AUTH_MODE_CERT;
5877 }
5878 break;
5879#endif
5880 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305881 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005882 "%s Set UNKNOWN IE %X", __func__, elementId);
Madan Mohan Koyyalamudief3b66e2012-10-11 14:29:42 -07005883 /* when Unknown IE is received we should break and continue
5884 * to the next IE in the buffer instead we were returning
5885 * so changing this to break */
5886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005887 }
5888 genie += eLen;
5889 remLen -= eLen;
5890 }
5891 EXIT();
5892 return 0;
5893}
5894
5895/*
Gopichand Nakkala18f0c262013-05-07 23:25:08 +05305896 * FUNCTION: hdd_isWPAIEPresent
5897 * Parse the received IE to find the WPA IE
5898 *
5899 */
5900static bool hdd_isWPAIEPresent(u8 *ie, u8 ie_len)
5901{
5902 v_U8_t eLen = 0;
5903 v_U16_t remLen = ie_len;
5904 v_U8_t elementId = 0;
5905
5906 while (remLen >= 2)
5907 {
5908 elementId = *ie++;
5909 eLen = *ie++;
5910 remLen -= 2;
5911 if (eLen > remLen)
5912 {
5913 hddLog(VOS_TRACE_LEVEL_ERROR,
5914 "%s: IE length is wrong %d", __func__, eLen);
5915 return FALSE;
5916 }
5917 if ((elementId == DOT11F_EID_WPA) && (remLen > 5))
5918 {
5919 /* OUI - 0x00 0X50 0XF2
5920 WPA Information Element - 0x01
5921 WPA version - 0x01*/
5922 if (0 == memcmp(&ie[0], "\x00\x50\xf2\x01\x01", 5))
5923 return TRUE;
5924 }
5925 ie += eLen;
5926 remLen -= eLen;
5927 }
5928 return FALSE;
5929}
5930
5931/*
Jeff Johnson295189b2012-06-20 16:38:30 -07005932 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305933 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 * parameters during connect operation.
5935 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305936int wlan_hdd_cfg80211_set_privacy( hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 struct cfg80211_connect_params *req
5938 )
5939{
5940 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305941 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 ENTER();
5943
5944 /*set wpa version*/
5945 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
5946
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305947 if (req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 {
Gopichand Nakkala781ded42013-06-28 12:10:45 +05305949 if (NL80211_WPA_VERSION_1 == req->crypto.wpa_versions)
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 {
5951 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
5952 }
5953 else if (NL80211_WPA_VERSION_2 == req->crypto.wpa_versions)
5954 {
5955 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
5956 }
5957 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305958
5959 hddLog(VOS_TRACE_LEVEL_INFO, "%s: set wpa version to %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005960 pWextState->wpaVersion);
5961
5962 /*set authentication type*/
5963 status = wlan_hdd_cfg80211_set_auth_type(pAdapter, req->auth_type);
5964
5965 if (0 > status)
5966 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305967 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 "%s: failed to set authentication type ", __func__);
5969 return status;
5970 }
5971
5972 /*set key mgmt type*/
5973 if (req->crypto.n_akm_suites)
5974 {
5975 status = wlan_hdd_set_akm_suite(pAdapter, req->crypto.akm_suites[0]);
5976 if (0 > status)
5977 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305978 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set akm suite",
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 __func__);
5980 return status;
5981 }
5982 }
5983
5984 /*set pairwise cipher type*/
5985 if (req->crypto.n_ciphers_pairwise)
5986 {
5987 status = wlan_hdd_cfg80211_set_cipher(pAdapter,
5988 req->crypto.ciphers_pairwise[0], true);
5989 if (0 > status)
5990 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05305991 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07005992 "%s: failed to set unicast cipher type", __func__);
5993 return status;
5994 }
5995 }
5996 else
5997 {
5998 /*Reset previous cipher suite to none*/
5999 status = wlan_hdd_cfg80211_set_cipher(pAdapter, 0, true);
6000 if (0 > status)
6001 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306002 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006003 "%s: failed to set unicast cipher type", __func__);
6004 return status;
6005 }
6006 }
6007
6008 /*set group cipher type*/
6009 status = wlan_hdd_cfg80211_set_cipher(pAdapter, req->crypto.cipher_group,
6010 false);
6011
6012 if (0 > status)
6013 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306014 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set mcast cipher type",
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 __func__);
6016 return status;
6017 }
6018
Chet Lanctot186b5732013-03-18 10:26:30 -07006019#ifdef WLAN_FEATURE_11W
6020 pWextState->roamProfile.MFPEnabled = (req->mfp == NL80211_MFP_REQUIRED);
6021#endif
6022
Jeff Johnson295189b2012-06-20 16:38:30 -07006023 /*parse WPA/RSN IE, and set the correspoing fileds in Roam profile*/
6024 if (req->ie_len)
6025 {
6026 status = wlan_hdd_cfg80211_set_ie(pAdapter, req->ie, req->ie_len);
6027 if ( 0 > status)
6028 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306029 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse the WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006030 __func__);
6031 return status;
6032 }
6033 }
6034
6035 /*incase of WEP set default key information*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306036 if (req->key && req->key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 {
6038 if ( (WLAN_CIPHER_SUITE_WEP40 == req->crypto.ciphers_pairwise[0])
6039 || (WLAN_CIPHER_SUITE_WEP104 == req->crypto.ciphers_pairwise[0])
6040 )
6041 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306042 if ( IW_AUTH_KEY_MGMT_802_1X
Jeff Johnson295189b2012-06-20 16:38:30 -07006043 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
6044 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306045 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Dynamic WEP not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006046 __func__);
6047 return -EOPNOTSUPP;
6048 }
6049 else
6050 {
6051 u8 key_len = req->key_len;
6052 u8 key_idx = req->key_idx;
6053
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306054 if ((eCSR_SECURITY_WEP_KEYSIZE_MAX_BYTES >= key_len)
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 && (CSR_MAX_NUM_KEY > key_idx)
6056 )
6057 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306058 hddLog(VOS_TRACE_LEVEL_INFO,
6059 "%s: setting default wep key, key_idx = %hu key_len %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 __func__, key_idx, key_len);
6061 vos_mem_copy(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306062 &pWextState->roamProfile.Keys.KeyMaterial[key_idx][0],
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 req->key, key_len);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306064 pWextState->roamProfile.Keys.KeyLength[key_idx] =
Jeff Johnson295189b2012-06-20 16:38:30 -07006065 (u8)key_len;
6066 pWextState->roamProfile.Keys.defaultIndex = (u8)key_idx;
6067 }
6068 }
6069 }
6070 }
6071
6072 return status;
6073}
6074
6075/*
6076 * FUNCTION: wlan_hdd_cfg80211_set_privacy
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306077 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 * parameters during connect operation.
6079 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306080static int wlan_hdd_cfg80211_connect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006081 struct net_device *ndev,
6082 struct cfg80211_connect_params *req
6083 )
6084{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306085 int status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306086 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( ndev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 VOS_STATUS exitbmpsStatus = VOS_STATUS_E_INVAL;
6088 hdd_context_t *pHddCtx = NULL;
6089
6090 ENTER();
6091
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306092 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6094
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306095 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6096 status = wlan_hdd_validate_context(pHddCtx);
6097
6098 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006099 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6101 "%s: HDD context is not valid", __func__);
6102 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 }
6104
6105#ifdef WLAN_BTAMP_FEATURE
6106 //Infra connect not supported when AMP traffic is on.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306107 if( VOS_TRUE == WLANBAP_AmpSessionOn() )
Jeff Johnson295189b2012-06-20 16:38:30 -07006108 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306109 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 "%s: No connection when AMP is on", __func__);
Madan Mohan Koyyalamudicae253a2012-11-06 19:10:35 -08006111 return -ECONNREFUSED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 }
6113#endif
6114 /*initialise security parameters*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306115 status = wlan_hdd_cfg80211_set_privacy(pAdapter, req);
Jeff Johnson295189b2012-06-20 16:38:30 -07006116
6117 if ( 0 > status)
6118 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306119 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security params",
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 __func__);
6121 return status;
6122 }
6123
6124 //If Device Mode is Station Concurrent Sessions Exit BMps
Jeff Johnsona8a1a482012-12-12 16:49:33 -08006125 //P2P Mode will be taken care in Open/close adapter
Jeff Johnson295189b2012-06-20 16:38:30 -07006126 if((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
6127 (vos_concurrent_sessions_running()))
6128 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306129 exitbmpsStatus = hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
Jeff Johnson295189b2012-06-20 16:38:30 -07006130 }
6131
Mohit Khanna765234a2012-09-11 15:08:35 -07006132 if ( req->channel )
6133 {
6134 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
6135 req->ssid_len, req->bssid,
6136 req->channel->hw_value);
6137 }
6138 else
6139 {
6140 status = wlan_hdd_cfg80211_connect_start(pAdapter, req->ssid,
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306141 req->ssid_len, req->bssid, 0);
Mohit Khanna765234a2012-09-11 15:08:35 -07006142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006143
6144 if (0 > status)
6145 {
6146 //ReEnable BMPS if disabled
6147 if((VOS_STATUS_SUCCESS == exitbmpsStatus) &&
6148 (NULL != pHddCtx))
6149 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05306150 if (pHddCtx->hdd_wlan_suspended)
6151 {
6152 hdd_set_pwrparams(pHddCtx);
6153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006154 //ReEnable Bmps and Imps back
6155 hdd_enable_bmps_imps(pHddCtx);
6156 }
6157
6158 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6159 return status;
6160 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306161 pHddCtx->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 EXIT();
6163 return status;
6164}
6165
6166
6167/*
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306168 * FUNCTION: wlan_hdd_disconnect
6169 * This function is used to issue a disconnect request to SME
6170 */
6171int wlan_hdd_disconnect( hdd_adapter_t *pAdapter, u16 reason )
6172{
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306173 int status;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306174 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306175 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6176
6177 status = wlan_hdd_validate_context(pHddCtx);
6178
6179 if (0 != status)
6180 {
6181 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6182 "%s: HDD context is not valid", __func__);
6183 return status;
6184 }
6185
6186 pHddCtx->isAmpAllowed = VOS_TRUE;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306187 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306188 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306189
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306190 /*issue disconnect*/
6191 status = sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
6192 pAdapter->sessionId, reason);
6193
6194 if ( 0 != status )
6195 {
6196 hddLog(VOS_TRACE_LEVEL_ERROR,
6197 "%s csrRoamDisconnect failure, returned %d \n",
6198 __func__, (int)status );
6199 return -EINVAL;
6200 }
6201 wait_for_completion_interruptible_timeout(
6202 &pAdapter->disconnect_comp_var,
6203 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
6204 /*stop tx queues*/
6205 netif_tx_disable(pAdapter->dev);
6206 netif_carrier_off(pAdapter->dev);
6207 return status;
6208}
6209
6210
6211/*
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 * FUNCTION: wlan_hdd_cfg80211_disconnect
6213 * This function is used to issue a disconnect request to SME
6214 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306215static int wlan_hdd_cfg80211_disconnect( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 struct net_device *dev,
6217 u16 reason
6218 )
6219{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306220 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6221 tCsrRoamProfile *pRoamProfile =
Jeff Johnson295189b2012-06-20 16:38:30 -07006222 &(WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter))->roamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306223 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006224 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006225 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306226#ifdef FEATURE_WLAN_TDLS
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006227 tANI_U8 staIdx;
6228#endif
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306229
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306231
6232 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006233 __func__,pAdapter->device_mode);
6234
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306235 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Disconnect called with reason code %d",
6236 __func__, reason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006237
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306238 status = wlan_hdd_validate_context(pHddCtx);
6239
6240 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006241 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6243 "%s: HDD context is not valid", __func__);
6244 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 }
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306246
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 if (NULL != pRoamProfile)
6248 {
6249 /*issue disconnect request to SME, if station is in connected state*/
6250 if (pHddStaCtx->conn_info.connState == eConnectionState_Associated)
6251 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306252 eCsrRoamDisconnectReason reasonCode =
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 eCSR_DISCONNECT_REASON_UNSPECIFIED;
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306254 hdd_scaninfo_t *pScanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 switch(reason)
6256 {
6257 case WLAN_REASON_MIC_FAILURE:
6258 reasonCode = eCSR_DISCONNECT_REASON_MIC_ERROR;
6259 break;
6260
6261 case WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY:
6262 case WLAN_REASON_DISASSOC_AP_BUSY:
6263 case WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA:
6264 reasonCode = eCSR_DISCONNECT_REASON_DISASSOC;
6265 break;
6266
6267 case WLAN_REASON_PREV_AUTH_NOT_VALID:
6268 case WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA:
6269 reasonCode = eCSR_DISCONNECT_REASON_DEAUTH;
6270 break;
6271
6272 case WLAN_REASON_DEAUTH_LEAVING:
6273 default:
6274 reasonCode = eCSR_DISCONNECT_REASON_UNSPECIFIED;
6275 break;
6276 }
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306277 pHddStaCtx->conn_info.connState = eConnectionState_NotConnected;
6278 pScanInfo = &pHddCtx->scan_info;
6279 if (pScanInfo->mScanPending)
6280 {
6281 hddLog(VOS_TRACE_LEVEL_INFO, "Disconnect is in progress, "
6282 "Aborting Scan");
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306283 hdd_abort_mac_scan(pHddCtx, pAdapter->sessionId);
Gopichand Nakkalaaa353782013-05-17 20:36:22 +05306284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006285
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006286#ifdef FEATURE_WLAN_TDLS
6287 /* First clean up the tdls peers if any */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006288 for (staIdx = 0 ; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006289 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006290 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pAdapter->sessionId) &&
6291 (pHddCtx->tdlsConnInfo[staIdx].staId))
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006292 {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006293 uint8 *mac;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006294 mac = pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08006295 VOS_TRACE(VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006296 "%s: call sme_DeleteTdlsPeerSta staId %d sessionId %d " MAC_ADDRESS_STR,
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006297 __func__, pHddCtx->tdlsConnInfo[staIdx].staId, pAdapter->sessionId,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07006298 MAC_ADDR_ARRAY(mac));
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006299 sme_DeleteTdlsPeerSta(WLAN_HDD_GET_HAL_CTX(pAdapter),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08006300 pAdapter->sessionId,
6301 mac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08006302 }
6303 }
6304#endif
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306305 status = wlan_hdd_disconnect(pAdapter, reasonCode);
6306 if ( 0 != status )
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 {
6308 hddLog(VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306309 "%s wlan_hdd_disconnect failure, returned %d \n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 __func__, (int)status );
6311 return -EINVAL;
6312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 }
6314 }
6315 else
6316 {
6317 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid roam profile", __func__);
6318 }
6319
6320 return status;
6321}
6322
Gopichand Nakkala78a6c812013-05-13 16:39:49 +05306323
Jeff Johnson295189b2012-06-20 16:38:30 -07006324/*
6325 * FUNCTION: wlan_hdd_cfg80211_set_privacy_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306326 * This function is used to initialize the security
Jeff Johnson295189b2012-06-20 16:38:30 -07006327 * settings in IBSS mode.
6328 */
6329static int wlan_hdd_cfg80211_set_privacy_ibss(
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306330 hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 struct cfg80211_ibss_params *params
6332 )
6333{
6334 int status = 0;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306335 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 eCsrEncryptionType encryptionType = eCSR_ENCRYPT_TYPE_NONE;
6337 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306338
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 ENTER();
6340
6341 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_DISABLED;
Ravi Joshib58ca0d2013-10-29 09:50:23 -07006342 vos_mem_zero(&pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey));
Jeff Johnson295189b2012-06-20 16:38:30 -07006343
6344 if (params->ie_len && ( NULL != params->ie) )
6345 {
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006346 if (wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6347 params->ie_len, WLAN_EID_RSN ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 {
6349 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA2;
6350 encryptionType = eCSR_ENCRYPT_TYPE_AES;
6351 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006352 else if ( hdd_isWPAIEPresent (params->ie, params->ie_len ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006353 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006354 tDot11fIEWPA dot11WPAIE;
6355 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006356 u8 *ie;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006357
Wilson Yang00256342013-10-10 23:13:38 -07006358 memset(&dot11WPAIE, 0, sizeof(dot11WPAIE));
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006359 ie = wlan_hdd_cfg80211_get_ie_ptr (params->ie,
6360 params->ie_len, DOT11F_EID_WPA);
6361 if ( NULL != ie )
6362 {
6363 pWextState->wpaVersion = IW_AUTH_WPA_VERSION_WPA;
6364 // Unpack the WPA IE
6365 //Skip past the EID byte and length byte - and four byte WiFi OUI
6366 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
6367 &ie[2+4],
6368 ie[1] - 4,
6369 &dot11WPAIE);
6370 /*Extract the multicast cipher, the encType for unicast
6371 cipher for wpa-none is none*/
6372 encryptionType =
6373 hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
6374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 }
Shailender Karmuchi67edd312013-06-18 16:30:48 -07006376
Jeff Johnson295189b2012-06-20 16:38:30 -07006377 status = wlan_hdd_cfg80211_set_ie(pAdapter, params->ie, params->ie_len);
6378
6379 if (0 > status)
6380 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306381 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to parse WPA/RSN IE",
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 __func__);
6383 return status;
6384 }
6385 }
6386
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306387 pWextState->roamProfile.AuthType.authType[0] =
6388 pHddStaCtx->conn_info.authType =
Jeff Johnson295189b2012-06-20 16:38:30 -07006389 eCSR_AUTH_TYPE_OPEN_SYSTEM;
6390
6391 if (params->privacy)
6392 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306393 /* Security enabled IBSS, At this time there is no information available
6394 * about the security paramters, so initialise the encryption type to
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 * eCSR_ENCRYPT_TYPE_WEP40_STATICKEY.
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306396 * The correct security parameters will be updated later in
Jeff Johnson295189b2012-06-20 16:38:30 -07006397 * wlan_hdd_cfg80211_add_key */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306398 /* Hal expects encryption type to be set inorder
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 *enable privacy bit in beacons */
6400
6401 encryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
6402 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07006403 VOS_TRACE (VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
6404 "encryptionType=%d", encryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 pHddStaCtx->conn_info.ucEncryptionType = encryptionType;
6406 pWextState->roamProfile.EncryptionType.numEntries = 1;
6407 pWextState->roamProfile.EncryptionType.encryptionType[0] = encryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07006408 return status;
6409}
6410
6411/*
6412 * FUNCTION: wlan_hdd_cfg80211_join_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306413 * This function is used to create/join an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006414 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306415static int wlan_hdd_cfg80211_join_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006416 struct net_device *dev,
6417 struct cfg80211_ibss_params *params
6418 )
6419{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306420 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6422 tCsrRoamProfile *pRoamProfile;
6423 int status;
krunal sonie9002db2013-11-25 14:24:17 -08006424 bool alloc_bssid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306426 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006427
6428 ENTER();
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306429
6430 hddLog(VOS_TRACE_LEVEL_INFO,
Jeff Johnson295189b2012-06-20 16:38:30 -07006431 "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6432
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306433 status = wlan_hdd_validate_context(pHddCtx);
6434
6435 if (0 != status)
Jeff Johnson295189b2012-06-20 16:38:30 -07006436 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306437 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6438 "%s: HDD context is not valid", __func__);
6439 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006440 }
6441
6442 if (NULL == pWextState)
6443 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306444 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 __func__);
6446 return -EIO;
6447 }
6448
6449 pRoamProfile = &pWextState->roamProfile;
6450
6451 if ( eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType )
6452 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306453 hddLog (VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 "%s Interface type is not set to IBSS \n", __func__);
6455 return -EINVAL;
6456 }
6457
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006458 /* BSSID is provided by upper layers hence no need to AUTO generate */
6459 if (NULL != params->bssid) {
6460 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6461 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE) {
6462 hddLog (VOS_TRACE_LEVEL_ERROR,
6463 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6464 return -EIO;
6465 }
6466 }
krunal sonie9002db2013-11-25 14:24:17 -08006467 else if(pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0)
6468 {
6469 if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_IBSS_AUTO_BSSID, 0,
6470 NULL, eANI_BOOLEAN_FALSE)==eHAL_STATUS_FAILURE)
6471 {
6472 hddLog (VOS_TRACE_LEVEL_ERROR,
6473 "%s:ccmCfgStInt faild for WNI_CFG_IBSS_AUTO_BSSID", __func__);
6474 return -EIO;
6475 }
6476 params->bssid = vos_mem_malloc(sizeof(VOS_MAC_ADDR_SIZE));
6477 if (!params->bssid)
6478 {
6479 hddLog (VOS_TRACE_LEVEL_ERROR,
6480 "%s:Failed memory allocation", __func__);
6481 return -EIO;
6482 }
6483 vos_mem_copy((v_U8_t *)params->bssid,
6484 (v_U8_t *)&pHddCtx->cfg_ini->IbssBssid.bytes[0],
6485 VOS_MAC_ADDR_SIZE);
6486 alloc_bssid = VOS_TRUE;
6487 }
Praveen Kumar Sirisillad123d142013-09-24 16:50:13 -07006488
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 /* Set Channel */
Yue Maf49ba872013-08-19 12:04:25 -07006490 if (NULL !=
6491#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6492 params->chandef.chan)
6493#else
6494 params->channel)
6495#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 {
6497 u8 channelNum;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006498 v_U32_t numChans = WNI_CFG_VALID_CHANNEL_LIST_LEN;
6499 v_U8_t validChan[WNI_CFG_VALID_CHANNEL_LIST_LEN];
6500 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
6501 int indx;
Jeff Johnson295189b2012-06-20 16:38:30 -07006502
6503 /* Get channel number */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306504 channelNum =
Yue Maf49ba872013-08-19 12:04:25 -07006505 ieee80211_frequency_to_channel(
6506#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
6507 params->chandef.chan->center_freq);
6508#else
6509 params->channel->center_freq);
6510#endif
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006511
6512 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
6513 validChan, &numChans))
Jeff Johnson295189b2012-06-20 16:38:30 -07006514 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006515 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: No valid channel list",
6516 __func__);
6517 return -EOPNOTSUPP;
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006519
6520 for (indx = 0; indx < numChans; indx++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006521 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006522 if (channelNum == validChan[indx])
6523 {
6524 break;
6525 }
6526 }
6527 if (indx >= numChans)
6528 {
6529 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Not valid Channel %d",
Jeff Johnson295189b2012-06-20 16:38:30 -07006530 __func__, channelNum);
6531 return -EINVAL;
6532 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006533 /* Set the Operational Channel */
6534 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s: set channel %d", __func__,
6535 channelNum);
6536 pRoamProfile->ChannelInfo.numOfChannels = 1;
6537 pHddStaCtx->conn_info.operationChannel = channelNum;
6538 pRoamProfile->ChannelInfo.ChannelList =
6539 &pHddStaCtx->conn_info.operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 }
6541
6542 /* Initialize security parameters */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306543 status = wlan_hdd_cfg80211_set_privacy_ibss(pAdapter, params);
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 if (status < 0)
6545 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306546 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: failed to set security parameters",
Jeff Johnson295189b2012-06-20 16:38:30 -07006547 __func__);
6548 return status;
6549 }
6550
6551 /* Issue connect start */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306552 status = wlan_hdd_cfg80211_connect_start(pAdapter, params->ssid,
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07006553 params->ssid_len, params->bssid,
6554 pHddStaCtx->conn_info.operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006555
6556 if (0 > status)
6557 {
6558 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: connect failed", __func__);
6559 return status;
6560 }
6561
krunal sonie9002db2013-11-25 14:24:17 -08006562 if (NULL != params->bssid &&
6563 pHddCtx->cfg_ini->isCoalesingInIBSSAllowed == 0 &&
6564 alloc_bssid == VOS_TRUE)
6565 {
6566 vos_mem_free(params->bssid);
6567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 return 0;
6569}
6570
6571/*
6572 * FUNCTION: wlan_hdd_cfg80211_leave_ibss
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306573 * This function is used to leave an IBSS
Jeff Johnson295189b2012-06-20 16:38:30 -07006574 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306575static int wlan_hdd_cfg80211_leave_ibss( struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 struct net_device *dev
6577 )
6578{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306579 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
6581 tCsrRoamProfile *pRoamProfile;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306582 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
6583 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006584
6585 ENTER();
6586
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306587 status = wlan_hdd_validate_context(pHddCtx);
6588
6589 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006590 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306591 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6592 "%s: HDD context is not valid", __func__);
6593 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006594 }
6595
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 hddLog(VOS_TRACE_LEVEL_INFO, "%s: device_mode = %d\n",__func__,pAdapter->device_mode);
6597 if (NULL == pWextState)
6598 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306599 hddLog (VOS_TRACE_LEVEL_ERROR, "%s ERROR: Data Storage Corruption\n",
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 __func__);
6601 return -EIO;
6602 }
6603
6604 pRoamProfile = &pWextState->roamProfile;
6605
6606 /* Issue disconnect only if interface type is set to IBSS */
6607 if (eCSR_BSS_TYPE_START_IBSS != pRoamProfile->BSSType)
6608 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306609 hddLog (VOS_TRACE_LEVEL_ERROR, "%s: BSS Type is not set to IBSS",
Jeff Johnson295189b2012-06-20 16:38:30 -07006610 __func__);
6611 return -EINVAL;
6612 }
6613
6614 /* Issue Disconnect request */
6615 INIT_COMPLETION(pAdapter->disconnect_comp_var);
6616 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
6617 eCSR_DISCONNECT_REASON_IBSS_LEAVE);
6618
6619 return 0;
6620}
6621
6622/*
6623 * FUNCTION: wlan_hdd_cfg80211_set_wiphy_params
6624 * This function is used to set the phy parameters
6625 * (RTS Threshold/FRAG Threshold/Retry Count etc ...)
6626 */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306627static int wlan_hdd_cfg80211_set_wiphy_params(struct wiphy *wiphy,
Jeff Johnson295189b2012-06-20 16:38:30 -07006628 u32 changed)
6629{
6630 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
6631 tHalHandle hHal = pHddCtx->hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306632 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006633
6634 ENTER();
6635
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306636 status = wlan_hdd_validate_context(pHddCtx);
6637
6638 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006639 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306640 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6641 "%s: HDD context is not valid", __func__);
6642 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006643 }
6644
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 if (changed & WIPHY_PARAM_RTS_THRESHOLD)
6646 {
6647 u16 rts_threshold = (wiphy->rts_threshold == -1) ?
6648 WNI_CFG_RTS_THRESHOLD_STAMAX :
6649 wiphy->rts_threshold;
6650
6651 if ((WNI_CFG_RTS_THRESHOLD_STAMIN > rts_threshold) ||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306652 (WNI_CFG_RTS_THRESHOLD_STAMAX < rts_threshold))
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306654 hddLog(VOS_TRACE_LEVEL_ERROR,
6655 "%s: Invalid RTS Threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 __func__, rts_threshold);
6657 return -EINVAL;
6658 }
6659
6660 if (0 != ccmCfgSetInt(hHal, WNI_CFG_RTS_THRESHOLD,
6661 rts_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306662 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306664 hddLog(VOS_TRACE_LEVEL_ERROR,
6665 "%s: ccmCfgSetInt failed for rts_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 __func__, rts_threshold);
6667 return -EIO;
6668 }
6669
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306670 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set rts threshold %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006671 rts_threshold);
6672 }
6673
6674 if (changed & WIPHY_PARAM_FRAG_THRESHOLD)
6675 {
6676 u16 frag_threshold = (wiphy->frag_threshold == -1) ?
6677 WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX :
6678 wiphy->frag_threshold;
6679
6680 if ((WNI_CFG_FRAGMENTATION_THRESHOLD_STAMIN > frag_threshold)||
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306681 (WNI_CFG_FRAGMENTATION_THRESHOLD_STAMAX < frag_threshold) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306683 hddLog(VOS_TRACE_LEVEL_ERROR,
6684 "%s: Invalid frag_threshold value %hu", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07006685 frag_threshold);
6686 return -EINVAL;
6687 }
6688
6689 if (0 != ccmCfgSetInt(hHal, WNI_CFG_FRAGMENTATION_THRESHOLD,
6690 frag_threshold, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306691 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306693 hddLog(VOS_TRACE_LEVEL_ERROR,
6694 "%s: ccmCfgSetInt failed for frag_threshold value %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 __func__, frag_threshold);
6696 return -EIO;
6697 }
6698
6699 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set frag threshold %hu", __func__,
6700 frag_threshold);
6701 }
6702
6703 if ((changed & WIPHY_PARAM_RETRY_SHORT)
6704 || (changed & WIPHY_PARAM_RETRY_LONG))
6705 {
6706 u8 retry_value = (changed & WIPHY_PARAM_RETRY_SHORT) ?
6707 wiphy->retry_short :
6708 wiphy->retry_long;
6709
6710 if ((WNI_CFG_LONG_RETRY_LIMIT_STAMIN > retry_value) ||
6711 (WNI_CFG_LONG_RETRY_LIMIT_STAMAX < retry_value))
6712 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306713 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 __func__, retry_value);
6715 return -EINVAL;
6716 }
6717
6718 if (changed & WIPHY_PARAM_RETRY_SHORT)
6719 {
6720 if (0 != ccmCfgSetInt(hHal, WNI_CFG_LONG_RETRY_LIMIT,
6721 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306722 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306724 hddLog(VOS_TRACE_LEVEL_ERROR,
6725 "%s: ccmCfgSetInt failed for long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006726 __func__, retry_value);
6727 return -EIO;
6728 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306729 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set long retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 __func__, retry_value);
6731 }
6732 else if (changed & WIPHY_PARAM_RETRY_SHORT)
6733 {
6734 if (0 != ccmCfgSetInt(hHal, WNI_CFG_SHORT_RETRY_LIMIT,
6735 retry_value, ccmCfgSetCallback,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306736 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006737 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306738 hddLog(VOS_TRACE_LEVEL_ERROR,
6739 "%s: ccmCfgSetInt failed for short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 __func__, retry_value);
6741 return -EIO;
6742 }
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306743 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set short retry count %hu",
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 __func__, retry_value);
6745 }
6746 }
6747
6748 return 0;
6749}
6750
6751/*
6752 * FUNCTION: wlan_hdd_cfg80211_set_txpower
6753 * This function is used to set the txpower
6754 */
6755static int wlan_hdd_cfg80211_set_txpower(struct wiphy *wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07006756#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6757 struct wireless_dev *wdev,
6758#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006759#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,35)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306760 enum tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006761#else
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306762 enum nl80211_tx_power_setting type,
Jeff Johnson295189b2012-06-20 16:38:30 -07006763#endif
6764 int dbm)
6765{
6766 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306767 tHalHandle hHal = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 tSirMacAddr bssid = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
6769 tSirMacAddr selfMac = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306770 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006771
6772 ENTER();
6773
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306774 status = wlan_hdd_validate_context(pHddCtx);
6775
6776 if (0 != status)
6777 {
6778 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6779 "%s: HDD context is not valid", __func__);
6780 return status;
6781 }
6782
6783 hHal = pHddCtx->hHal;
6784
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306785 if (0 != ccmCfgSetInt(hHal, WNI_CFG_CURRENT_TX_POWER_LEVEL,
6786 dbm, ccmCfgSetCallback,
6787 eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306789 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 "%s: ccmCfgSetInt failed for tx power %hu", __func__, dbm);
6791 return -EIO;
6792 }
6793
6794 hddLog(VOS_TRACE_LEVEL_INFO_MED, "%s: set tx power level %d dbm", __func__,
6795 dbm);
6796
6797 switch(type)
6798 {
6799 case NL80211_TX_POWER_AUTOMATIC: /*automatically determine transmit power*/
6800 /* Fall through */
6801 case NL80211_TX_POWER_LIMITED: /*limit TX power by the mBm parameter*/
6802 if( sme_SetMaxTxPower(hHal, bssid, selfMac, dbm) != eHAL_STATUS_SUCCESS )
6803 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Setting maximum tx power failed",
6805 __func__);
6806 return -EIO;
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 }
6808 break;
6809 case NL80211_TX_POWER_FIXED: /*fix TX power to the mBm parameter*/
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306810 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: NL80211_TX_POWER_FIXED not supported",
Jeff Johnson295189b2012-06-20 16:38:30 -07006811 __func__);
6812 return -EOPNOTSUPP;
6813 break;
6814 default:
Gopichand Nakkala747461f2013-04-24 19:24:45 +05306815 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid power setting type %d",
6816 __func__, type);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 return -EIO;
6818 }
6819
6820 return 0;
6821}
6822
6823/*
6824 * FUNCTION: wlan_hdd_cfg80211_get_txpower
6825 * This function is used to read the txpower
6826 */
Yue Maf49ba872013-08-19 12:04:25 -07006827static int wlan_hdd_cfg80211_get_txpower(struct wiphy *wiphy,
6828#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)
6829 struct wireless_dev *wdev,
6830#endif
6831 int *dbm)
Jeff Johnson295189b2012-06-20 16:38:30 -07006832{
6833
6834 hdd_adapter_t *pAdapter;
6835 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306836 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006837
Jeff Johnsone7245742012-09-05 17:12:55 -07006838 ENTER();
6839
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306840 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07006841
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306842 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006843 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6845 "%s: HDD context is not valid", __func__);
6846 *dbm = 0;
6847 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006848 }
6849
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 pAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_INFRA_STATION);
6851 if (NULL == pAdapter)
6852 {
6853 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Not in station context " ,__func__);
6854 return -ENOENT;
6855 }
6856
6857 wlan_hdd_get_classAstats(pAdapter);
6858 *dbm = pAdapter->hdd_stats.ClassA_stat.max_pwr;
6859
Jeff Johnsone7245742012-09-05 17:12:55 -07006860 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 return 0;
6862}
6863
6864static int wlan_hdd_cfg80211_get_station(struct wiphy *wiphy, struct net_device *dev,
6865 u8* mac, struct station_info *sinfo)
6866{
6867 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR( dev );
6868 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
6869 int ssidlen = pHddStaCtx->conn_info.SSID.SSID.length;
6870 tANI_U8 rate_flags;
6871
6872 hdd_context_t *pHddCtx = (hdd_context_t*) wiphy_priv(wiphy);
6873 hdd_config_t *pCfg = pHddCtx->cfg_ini;
Jeff Johnson295189b2012-06-20 16:38:30 -07006874
6875 tANI_U8 OperationalRates[CSR_DOT11_SUPPORTED_RATES_MAX];
6876 tANI_U32 ORLeng = CSR_DOT11_SUPPORTED_RATES_MAX;
6877 tANI_U8 ExtendedRates[CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX];
6878 tANI_U32 ERLeng = CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX;
6879 tANI_U8 MCSRates[SIZE_OF_BASIC_MCS_SET];
6880 tANI_U32 MCSLeng = SIZE_OF_BASIC_MCS_SET;
6881 tANI_U16 maxRate = 0;
6882 tANI_U16 myRate;
6883 tANI_U16 currentRate = 0;
6884 tANI_U8 maxSpeedMCS = 0;
6885 tANI_U8 maxMCSIdx = 0;
6886 tANI_U8 rateFlag = 1;
6887 tANI_U8 i, j, rssidx;
Madan Mohan Koyyalamudic75be962012-10-18 19:19:03 -07006888 tANI_U16 temp;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306889 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07006890
Leo Chang6f8870f2013-03-26 18:11:36 -07006891#ifdef WLAN_FEATURE_11AC
6892 tANI_U32 vht_mcs_map;
6893 eDataRate11ACMaxMcs vhtMaxMcs;
6894#endif /* WLAN_FEATURE_11AC */
6895
Jeff Johnsone7245742012-09-05 17:12:55 -07006896 ENTER();
6897
Jeff Johnson295189b2012-06-20 16:38:30 -07006898 if ((eConnectionState_Associated != pHddStaCtx->conn_info.connState) ||
6899 (0 == ssidlen))
6900 {
6901 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Not associated or"
6902 " Invalid ssidlen, %d", __func__, ssidlen);
6903 /*To keep GUI happy*/
6904 return 0;
6905 }
6906
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306907 status = wlan_hdd_validate_context(pHddCtx);
6908
6909 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006910 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05306911 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
6912 "%s: HDD context is not valid", __func__);
6913 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07006914 }
6915
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07006916 wlan_hdd_get_station_stats(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006917 rate_flags = pAdapter->hdd_stats.ClassA_stat.tx_rate_flags;
6918
Kiet Lam3b17fc82013-09-27 05:24:08 +05306919 wlan_hdd_get_rssi(pAdapter, &sinfo->signal);
6920 sinfo->filled |= STATION_INFO_SIGNAL;
6921
Jeff Johnson295189b2012-06-20 16:38:30 -07006922 //convert to the UI units of 100kbps
6923 myRate = pAdapter->hdd_stats.ClassA_stat.tx_rate * 5;
6924
6925#ifdef LINKSPEED_DEBUG_ENABLED
Leo Chang6f8870f2013-03-26 18:11:36 -07006926 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 -07006927 sinfo->signal,
6928 pCfg->reportMaxLinkSpeed,
6929 myRate,
6930 (int) pCfg->linkSpeedRssiHigh,
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006931 (int) pCfg->linkSpeedRssiMid,
6932 (int) pCfg->linkSpeedRssiLow,
Leo Chang6f8870f2013-03-26 18:11:36 -07006933 (int) rate_flags,
6934 (int) pAdapter->hdd_stats.ClassA_stat.mcs_index);
Jeff Johnson295189b2012-06-20 16:38:30 -07006935#endif //LINKSPEED_DEBUG_ENABLED
6936
6937 if (eHDD_LINK_SPEED_REPORT_ACTUAL != pCfg->reportMaxLinkSpeed)
6938 {
6939 // we do not want to necessarily report the current speed
6940 if (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed)
6941 {
6942 // report the max possible speed
6943 rssidx = 0;
6944 }
6945 else if (eHDD_LINK_SPEED_REPORT_MAX_SCALED == pCfg->reportMaxLinkSpeed)
6946 {
6947 // report the max possible speed with RSSI scaling
6948 if (sinfo->signal >= pCfg->linkSpeedRssiHigh)
6949 {
6950 // report the max possible speed
6951 rssidx = 0;
6952 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006953 else if (sinfo->signal >= pCfg->linkSpeedRssiMid)
Jeff Johnson295189b2012-06-20 16:38:30 -07006954 {
6955 // report middle speed
6956 rssidx = 1;
6957 }
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006958 else if (sinfo->signal >= pCfg->linkSpeedRssiLow)
6959 {
6960 // report middle speed
6961 rssidx = 2;
6962 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 else
6964 {
6965 // report actual speed
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07006966 rssidx = 3;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 }
6968 }
6969 else
6970 {
6971 // unknown, treat as eHDD_LINK_SPEED_REPORT_MAX
6972 hddLog(VOS_TRACE_LEVEL_ERROR,
6973 "%s: Invalid value for reportMaxLinkSpeed: %u",
6974 __func__, pCfg->reportMaxLinkSpeed);
6975 rssidx = 0;
6976 }
6977
6978 maxRate = 0;
6979
6980 /* Get Basic Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05306981 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_OPERATIONAL_RATE_SET,
6982 OperationalRates, &ORLeng))
6983 {
6984 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
6985 /*To keep GUI happy*/
6986 return 0;
6987 }
6988
Jeff Johnson295189b2012-06-20 16:38:30 -07006989 for (i = 0; i < ORLeng; i++)
6990 {
Jeff Johnsone7245742012-09-05 17:12:55 -07006991 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07006992 {
6993 /* Validate Rate Set */
6994 if (supported_data_rate[j].beacon_rate_index == (OperationalRates[i] & 0x7F))
6995 {
6996 currentRate = supported_data_rate[j].supported_rate[rssidx];
6997 break;
6998 }
6999 }
7000 /* Update MAX rate */
7001 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7002 }
7003
7004 /* Get Extended Rate Set */
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307005 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET,
7006 ExtendedRates, &ERLeng))
7007 {
7008 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7009 /*To keep GUI happy*/
7010 return 0;
7011 }
7012
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 for (i = 0; i < ERLeng; i++)
7014 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007015 for (j = 0; j < (sizeof(supported_data_rate) / sizeof(supported_data_rate[0])); j ++)
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 {
7017 if (supported_data_rate[j].beacon_rate_index == (ExtendedRates[i] & 0x7F))
7018 {
7019 currentRate = supported_data_rate[j].supported_rate[rssidx];
7020 break;
7021 }
7022 }
7023 /* Update MAX rate */
7024 maxRate = (currentRate > maxRate)?currentRate:maxRate;
7025 }
Kiet Lamb69f8dc2013-11-15 15:34:27 +05307026 /* Get MCS Rate Set --
7027 only if we are connected at MCS rates (or)
7028 if we are always reporting max speed (or)
7029 if we have good rssi */
7030 if (((0 == rssidx) && !(rate_flags & eHAL_TX_RATE_LEGACY)) ||
7031 (eHDD_LINK_SPEED_REPORT_MAX == pCfg->reportMaxLinkSpeed))
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 {
Gopichand Nakkala05ab1322013-02-15 11:28:38 +05307033 if (0 != ccmCfgGetStr(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_CURRENT_MCS_SET,
7034 MCSRates, &MCSLeng))
7035 {
7036 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: ccm api returned failure", __func__);
7037 /*To keep GUI happy*/
7038 return 0;
7039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 rateFlag = 0;
Leo Chang6f8870f2013-03-26 18:11:36 -07007041#ifdef WLAN_FEATURE_11AC
7042 /* VHT80 rate has seperate rate table */
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307043 if (rate_flags & (eHAL_TX_RATE_VHT20|eHAL_TX_RATE_VHT40|eHAL_TX_RATE_VHT80))
Jeff Johnson295189b2012-06-20 16:38:30 -07007044 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007045 ccmCfgGetInt(WLAN_HDD_GET_HAL_CTX(pAdapter), WNI_CFG_VHT_TX_MCS_MAP, &vht_mcs_map);
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307046 vhtMaxMcs = (eDataRate11ACMaxMcs)(vht_mcs_map & DATA_RATE_11AC_MCS_MASK );
Leo Chang6f8870f2013-03-26 18:11:36 -07007047 if (rate_flags & eHAL_TX_RATE_SGI)
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007049 rateFlag |= 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007051 if (DATA_RATE_11AC_MAX_MCS_7 == vhtMaxMcs)
Jeff Johnson295189b2012-06-20 16:38:30 -07007052 {
Leo Chang6f8870f2013-03-26 18:11:36 -07007053 maxMCSIdx = 7;
7054 }
7055 else if (DATA_RATE_11AC_MAX_MCS_8 == vhtMaxMcs)
7056 {
7057 maxMCSIdx = 8;
7058 }
7059 else if (DATA_RATE_11AC_MAX_MCS_9 == vhtMaxMcs)
7060 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307061 //VHT20 is supporting 0~8
7062 if (rate_flags & eHAL_TX_RATE_VHT20)
7063 maxMCSIdx = 8;
7064 else
7065 maxMCSIdx = 9;
Leo Chang6f8870f2013-03-26 18:11:36 -07007066 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307067
7068 if (rate_flags & eHAL_TX_RATE_VHT80)
7069 {
7070 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT80_rate[rateFlag];
7071 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT80_rate[rateFlag];
7072 }
7073 else if (rate_flags & eHAL_TX_RATE_VHT40)
7074 {
7075 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT40_rate[rateFlag];
7076 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT40_rate[rateFlag];
7077 }
7078 else if (rate_flags & eHAL_TX_RATE_VHT20)
7079 {
7080 currentRate = supported_vht_mcs_rate[pAdapter->hdd_stats.ClassA_stat.mcs_index].supported_VHT20_rate[rateFlag];
7081 maxRate = supported_vht_mcs_rate[maxMCSIdx].supported_VHT20_rate[rateFlag];
7082 }
7083
Leo Chang6f8870f2013-03-26 18:11:36 -07007084 maxSpeedMCS = 1;
7085 if (currentRate > maxRate)
7086 {
7087 maxRate = currentRate;
7088 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307089
Leo Chang6f8870f2013-03-26 18:11:36 -07007090 }
7091 else
7092#endif /* WLAN_FEATURE_11AC */
7093 {
7094 if (rate_flags & eHAL_TX_RATE_HT40)
7095 {
7096 rateFlag |= 1;
7097 }
7098 if (rate_flags & eHAL_TX_RATE_SGI)
7099 {
7100 rateFlag |= 2;
7101 }
7102
7103 for (i = 0; i < MCSLeng; i++)
7104 {
7105 temp = sizeof(supported_mcs_rate) / sizeof(supported_mcs_rate[0]);
7106 for (j = 0; j < temp; j++)
7107 {
7108 if (supported_mcs_rate[j].beacon_rate_index == MCSRates[i])
7109 {
7110 currentRate = supported_mcs_rate[j].supported_rate[rateFlag];
7111 break;
7112 }
7113 }
7114 if ((j < temp) && (currentRate > maxRate))
7115 {
7116 maxRate = currentRate;
7117 maxSpeedMCS = 1;
7118 maxMCSIdx = supported_mcs_rate[j].beacon_rate_index;
7119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 }
7121 }
7122 }
7123
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307124 else if (!(rate_flags & eHAL_TX_RATE_LEGACY))
7125 {
7126 maxRate = myRate;
7127 maxSpeedMCS = 1;
7128 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7129 }
7130
Jeff Johnson295189b2012-06-20 16:38:30 -07007131 // make sure we report a value at least as big as our current rate
Madan Mohan Koyyalamudi8df78d52012-11-02 12:30:06 -07007132 if (((maxRate < myRate) && (0 == rssidx)) ||
7133 (0 == maxRate))
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 {
7135 maxRate = myRate;
7136 if (rate_flags & eHAL_TX_RATE_LEGACY)
7137 {
7138 maxSpeedMCS = 0;
7139 }
7140 else
7141 {
7142 maxSpeedMCS = 1;
7143 maxMCSIdx = pAdapter->hdd_stats.ClassA_stat.mcs_index;
7144 }
7145 }
7146
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307147 if (rate_flags & eHAL_TX_RATE_LEGACY)
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 {
7149 sinfo->txrate.legacy = maxRate;
7150#ifdef LINKSPEED_DEBUG_ENABLED
7151 pr_info("Reporting legacy rate %d\n", sinfo->txrate.legacy);
7152#endif //LINKSPEED_DEBUG_ENABLED
7153 }
7154 else
7155 {
7156 sinfo->txrate.mcs = maxMCSIdx;
Leo Chang6f8870f2013-03-26 18:11:36 -07007157#ifdef WLAN_FEATURE_11AC
7158 sinfo->txrate.nss = 1;
7159 if (rate_flags & eHAL_TX_RATE_VHT80)
7160 {
7161 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307162 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
Leo Chang6f8870f2013-03-26 18:11:36 -07007163 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307164 else if (rate_flags & eHAL_TX_RATE_VHT40)
Leo Chang6f8870f2013-03-26 18:11:36 -07007165 {
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307166 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7167 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7168 }
7169 else if (rate_flags & eHAL_TX_RATE_VHT20)
7170 {
7171 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7172 }
7173#endif /* WLAN_FEATURE_11AC */
7174 if (rate_flags & (eHAL_TX_RATE_HT20 | eHAL_TX_RATE_HT40))
7175 {
7176 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7177 if (rate_flags & eHAL_TX_RATE_HT40)
7178 {
7179 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7180 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 if (rate_flags & eHAL_TX_RATE_SGI)
7183 {
7184 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7185 }
Gopichand Nakkala4c705372013-04-24 13:20:33 +05307186
Jeff Johnson295189b2012-06-20 16:38:30 -07007187#ifdef LINKSPEED_DEBUG_ENABLED
7188 pr_info("Reporting MCS rate %d flags %x\n",
7189 sinfo->txrate.mcs,
7190 sinfo->txrate.flags );
7191#endif //LINKSPEED_DEBUG_ENABLED
7192 }
7193 }
7194 else
7195 {
7196 // report current rate instead of max rate
7197
7198 if (rate_flags & eHAL_TX_RATE_LEGACY)
7199 {
7200 //provide to the UI in units of 100kbps
7201 sinfo->txrate.legacy = myRate;
7202#ifdef LINKSPEED_DEBUG_ENABLED
7203 pr_info("Reporting actual legacy rate %d\n", sinfo->txrate.legacy);
7204#endif //LINKSPEED_DEBUG_ENABLED
7205 }
7206 else
7207 {
7208 //must be MCS
7209 sinfo->txrate.mcs = pAdapter->hdd_stats.ClassA_stat.mcs_index;
Leo Chang6f8870f2013-03-26 18:11:36 -07007210#ifdef WLAN_FEATURE_11AC
7211 sinfo->txrate.nss = 1;
7212 if (rate_flags & eHAL_TX_RATE_VHT80)
7213 {
7214 sinfo->txrate.flags |= RATE_INFO_FLAGS_VHT_MCS;
7215 }
7216 else
7217#endif /* WLAN_FEATURE_11AC */
7218 {
7219 sinfo->txrate.flags |= RATE_INFO_FLAGS_MCS;
7220 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 if (rate_flags & eHAL_TX_RATE_SGI)
7222 {
7223 sinfo->txrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
7224 }
7225 if (rate_flags & eHAL_TX_RATE_HT40)
7226 {
7227 sinfo->txrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
7228 }
Leo Chang6f8870f2013-03-26 18:11:36 -07007229#ifdef WLAN_FEATURE_11AC
7230 else if (rate_flags & eHAL_TX_RATE_VHT80)
7231 {
7232 sinfo->txrate.flags |= RATE_INFO_FLAGS_80_MHZ_WIDTH;
7233 }
7234#endif /* WLAN_FEATURE_11AC */
Jeff Johnson295189b2012-06-20 16:38:30 -07007235#ifdef LINKSPEED_DEBUG_ENABLED
7236 pr_info("Reporting actual MCS rate %d flags %x\n",
7237 sinfo->txrate.mcs,
7238 sinfo->txrate.flags );
7239#endif //LINKSPEED_DEBUG_ENABLED
7240 }
7241 }
7242 sinfo->filled |= STATION_INFO_TX_BITRATE;
7243
Madan Mohan Koyyalamudi4d4d2812012-09-24 14:08:29 -07007244 sinfo->tx_packets =
7245 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[0] +
7246 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[1] +
7247 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[2] +
7248 pAdapter->hdd_stats.summary_stat.tx_frm_cnt[3];
7249
7250 sinfo->tx_retries =
7251 pAdapter->hdd_stats.summary_stat.retry_cnt[0] +
7252 pAdapter->hdd_stats.summary_stat.retry_cnt[1] +
7253 pAdapter->hdd_stats.summary_stat.retry_cnt[2] +
7254 pAdapter->hdd_stats.summary_stat.retry_cnt[3];
7255
7256 sinfo->tx_failed =
7257 pAdapter->hdd_stats.summary_stat.fail_cnt[0] +
7258 pAdapter->hdd_stats.summary_stat.fail_cnt[1] +
7259 pAdapter->hdd_stats.summary_stat.fail_cnt[2] +
7260 pAdapter->hdd_stats.summary_stat.fail_cnt[3];
7261
7262 sinfo->filled |=
7263 STATION_INFO_TX_PACKETS |
7264 STATION_INFO_TX_RETRIES |
7265 STATION_INFO_TX_FAILED;
7266
7267 EXIT();
7268 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007269}
7270
7271static int wlan_hdd_cfg80211_set_power_mgmt(struct wiphy *wiphy,
Sameer Thalappilc9f26e92013-06-07 10:11:06 -07007272 struct net_device *dev, bool mode, int timeout)
Jeff Johnson295189b2012-06-20 16:38:30 -07007273{
7274 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307275 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307277 int status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007278
Jeff Johnsone7245742012-09-05 17:12:55 -07007279 ENTER();
7280
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 if (NULL == pAdapter)
7282 {
7283 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7284 return -ENODEV;
7285 }
7286
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307287 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307288 status = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307289
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307290 if (0 != status)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307291 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307292 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7293 "%s: HDD context is not valid", __func__);
7294 return status;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307295 }
7296
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307297 if ((DRIVER_POWER_MODE_AUTO == !mode) &&
7298 (TRUE == pHddCtx->hdd_wlan_suspended) &&
7299 (pHddCtx->cfg_ini->fhostArpOffload) &&
7300 (eConnectionState_Associated ==
7301 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.connState))
7302 {
Amar Singhald53568e2013-09-26 11:03:45 -07007303
7304 hddLog(VOS_TRACE_LEVEL_INFO,
7305 "offload: in cfg80211_set_power_mgmt, calling arp offload");
Gopichand Nakkalab03e8082013-05-30 18:09:25 +05307306 vos_status = hdd_conf_arp_offload(pAdapter, TRUE);
Gopichand Nakkala20c4c042013-04-19 22:08:55 +05307307 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7308 {
7309 hddLog(VOS_TRACE_LEVEL_INFO,
7310 "%s:Failed to enable ARPOFFLOAD Feature %d\n",
7311 __func__, vos_status);
7312 }
7313 }
7314
Jeff Johnson295189b2012-06-20 16:38:30 -07007315 /**The get power cmd from the supplicant gets updated by the nl only
7316 *on successful execution of the function call
7317 *we are oppositely mapped w.r.t mode in the driver
7318 **/
7319 vos_status = wlan_hdd_enter_bmps(pAdapter, !mode);
7320
Jeff Johnsone7245742012-09-05 17:12:55 -07007321 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07007322 if (VOS_STATUS_E_FAILURE == vos_status)
7323 {
7324 return -EINVAL;
7325 }
7326 return 0;
7327}
7328
7329
7330#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7331static int wlan_hdd_set_default_mgmt_key(struct wiphy *wiphy,
7332 struct net_device *netdev,
7333 u8 key_index)
7334{
Jeff Johnsone7245742012-09-05 17:12:55 -07007335 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007336 return 0;
7337}
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307338#endif //LINUX_VERSION_CODE
Jeff Johnson295189b2012-06-20 16:38:30 -07007339
7340#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
7341static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7342 struct net_device *dev,
7343 struct ieee80211_txq_params *params)
7344{
Jeff Johnsone7245742012-09-05 17:12:55 -07007345 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007346 return 0;
7347}
7348#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
7349static int wlan_hdd_set_txq_params(struct wiphy *wiphy,
7350 struct ieee80211_txq_params *params)
7351{
Jeff Johnsone7245742012-09-05 17:12:55 -07007352 ENTER();
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 return 0;
7354}
7355#endif //LINUX_VERSION_CODE
7356
7357static int wlan_hdd_cfg80211_del_station(struct wiphy *wiphy,
7358 struct net_device *dev, u8 *mac)
7359{
7360 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307361 hdd_context_t *pHddCtx;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007362 VOS_STATUS vos_status;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307363 int status;
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007364 v_U8_t staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007365
Jeff Johnsone7245742012-09-05 17:12:55 -07007366 ENTER();
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307367 if ( NULL == pAdapter )
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307369 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07007370 return -EINVAL;
7371 }
7372
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307373 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7374 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07007375
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307376 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007377 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307378 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7379 "%s: HDD context is not valid", __func__);
7380 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007381 }
7382
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 if ( (WLAN_HDD_SOFTAP == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 || (WLAN_HDD_P2P_GO == pAdapter->device_mode)
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 )
7386 {
7387 if( NULL == mac )
7388 {
7389 v_U16_t i;
7390 for(i = 0; i < WLAN_MAX_STA_COUNT; i++)
7391 {
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007392 if ((pAdapter->aStaInfo[i].isUsed) &&
7393 (!pAdapter->aStaInfo[i].isDeauthInProgress))
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 {
7395 u8 *macAddr = pAdapter->aStaInfo[i].macAddrSTA.bytes;
7396 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007397 "%s: Delete STA with MAC::"
7398 MAC_ADDRESS_STR,
7399 __func__, MAC_ADDR_ARRAY(macAddr));
Rajesh Chauhan18488fc2013-08-22 10:15:03 -07007400 vos_status = hdd_softap_sta_deauth(pAdapter, macAddr);
7401 if (VOS_IS_STATUS_SUCCESS(vos_status))
7402 pAdapter->aStaInfo[i].isDeauthInProgress = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007403 }
7404 }
7405 }
7406 else
7407 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007408
7409 vos_status = hdd_softap_GetStaId(pAdapter,(v_MACADDR_t *)mac, &staId);
7410 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7411 {
7412 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007413 "%s: Skip this DEL STA as this is not used::"
7414 MAC_ADDRESS_STR,
7415 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007416 return -ENOENT;
7417 }
7418
7419 if( pAdapter->aStaInfo[staId].isDeauthInProgress == TRUE)
7420 {
7421 hddLog(VOS_TRACE_LEVEL_INFO,
Arif Hussain24bafea2013-11-15 15:10:03 -08007422 "%s: Skip this DEL STA as deauth is in progress::"
7423 MAC_ADDRESS_STR,
7424 __func__, MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007425 return -ENOENT;
7426 }
7427
7428 pAdapter->aStaInfo[staId].isDeauthInProgress = TRUE;
7429
Jeff Johnson295189b2012-06-20 16:38:30 -07007430 hddLog(VOS_TRACE_LEVEL_INFO,
7431 "%s: Delete STA with MAC::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007432 MAC_ADDRESS_STR,
Jeff Johnson295189b2012-06-20 16:38:30 -07007433 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007434 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007435
7436 vos_status = hdd_softap_sta_deauth(pAdapter, mac);
7437 if (!VOS_IS_STATUS_SUCCESS(vos_status))
7438 {
7439 pAdapter->aStaInfo[staId].isDeauthInProgress = FALSE;
7440 hddLog(VOS_TRACE_LEVEL_INFO,
7441 "%s: STA removal failed for ::"
Arif Hussain24bafea2013-11-15 15:10:03 -08007442 MAC_ADDRESS_STR,
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007443 __func__,
Arif Hussain24bafea2013-11-15 15:10:03 -08007444 MAC_ADDR_ARRAY(mac));
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08007445 return -ENOENT;
7446 }
7447
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 }
7449 }
7450
7451 EXIT();
7452
7453 return 0;
7454}
7455
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007456static int wlan_hdd_cfg80211_add_station(struct wiphy *wiphy,
7457 struct net_device *dev, u8 *mac, struct station_parameters *params)
7458{
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007459 int status = -EPERM;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007460#ifdef FEATURE_WLAN_TDLS
7461 u32 mask, set;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08007462 ENTER();
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007463 mask = params->sta_flags_mask;
7464
7465 set = params->sta_flags_set;
7466
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07007467#ifdef WLAN_FEATURE_TDLS_DEBUG
7468 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7469 "%s: mask 0x%x set 0x%x " MAC_ADDRESS_STR,
7470 __func__, mask, set, MAC_ADDR_ARRAY(mac));
7471#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007472
7473 if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
7474 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
Gopichand Nakkala681989c2013-03-06 22:27:48 -08007475 status = wlan_hdd_tdls_add_station(wiphy, dev, mac, 0, NULL);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08007476 }
7477 }
7478#endif
Gopichand Nakkalab977a972013-02-18 19:15:09 -08007479 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07007480}
7481
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007482
7483#ifdef FEATURE_WLAN_LFR
Wilson Yang6507c4e2013-10-01 20:11:19 -07007484#define MAX_PMKSAIDS_IN_CACHE 8
7485
7486static tPmkidCacheInfo PMKIDCache[MAX_PMKSAIDS_IN_CACHE]; // HDD local cache
7487static tANI_U32 PMKIDCacheIndex; // HDD local Cache index
7488
7489
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007490static int wlan_hdd_cfg80211_set_pmksa(struct wiphy *wiphy, struct net_device *dev,
Jeff Johnsond13512a2012-07-17 11:42:19 -07007491 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007492{
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307493 tANI_U32 j=0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007494 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7495 tHalHandle halHandle;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307496 eHalStatus result;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307497 int status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007498 tANI_U8 BSSIDMatched = 0;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307499 hdd_context_t *pHddCtx;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307500
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007501 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: set PMKSA for " MAC_ADDRESS_STR,
7502 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07007503
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307504 // Validate pAdapter
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307505 if ( NULL == pAdapter )
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007506 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307507 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007508 return -EINVAL;
7509 }
7510
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307511 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7512 status = wlan_hdd_validate_context(pHddCtx);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007513
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307514 if (0 != status)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007515 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05307516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7517 "%s: HDD context is not valid", __func__);
7518 return status;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007519 }
7520
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307521 // Retrieve halHandle
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007522 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7523
Wilson Yang6507c4e2013-10-01 20:11:19 -07007524 for (j = 0; j < PMKIDCacheIndex; j++)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007525 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307526 if(vos_mem_compare(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007527 pmksa->bssid, WNI_CFG_BSSID_LEN))
7528 {
7529 /* BSSID matched previous entry. Overwrite it. */
7530 BSSIDMatched = 1;
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307531 vos_mem_copy(PMKIDCache[j].BSSID,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007532 pmksa->bssid, WNI_CFG_BSSID_LEN);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307533 vos_mem_copy(PMKIDCache[j].PMKID,
7534 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007535 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307536 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Reusing cache entry %d.",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007537 __func__, j );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007538 dump_bssid(pmksa->bssid);
7539 dump_pmkid(halHandle, pmksa->pmkid);
7540 break;
7541 }
7542 }
7543
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007544 /* Check we compared all entries,if then take the first slot now */
Wilson Yang6507c4e2013-10-01 20:11:19 -07007545 if(j == MAX_PMKSAIDS_IN_CACHE) PMKIDCacheIndex=0;
Madan Mohan Koyyalamudic4b317d2012-10-18 19:43:08 -07007546
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007547 if (!BSSIDMatched)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307548 {
7549 // Now, we DON'T have a BSSID match, so take a new entry in the cache.
Wilson Yang6507c4e2013-10-01 20:11:19 -07007550 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].BSSID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307551 pmksa->bssid, ETHER_ADDR_LEN);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007552 vos_mem_copy(PMKIDCache[PMKIDCacheIndex].PMKID,
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307553 pmksa->pmkid,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007554 CSR_RSN_PMKID_SIZE);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307555 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Adding a new cache entry %d.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007556 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007557 dump_bssid(pmksa->bssid);
7558 dump_pmkid(halHandle, pmksa->pmkid);
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307559 // Increment the HDD Local Cache index
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007560 // The "i=0" doesn't work for the call to sme_RoamSetPMKIDCache() - LFR FIXME
Wilson Yang6507c4e2013-10-01 20:11:19 -07007561 if (PMKIDCacheIndex <= (MAX_PMKSAIDS_IN_CACHE-1)) PMKIDCacheIndex++; else PMKIDCacheIndex = 0;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007562 }
7563
7564
7565 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307566 //hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with %d cache entries."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07007567 // __func__, i );
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307568 hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Calling csrRoamSetPMKIDCache with %d cache entries.",
Wilson Yang6507c4e2013-10-01 20:11:19 -07007569 __func__, PMKIDCacheIndex );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007570 // Finally set the PMKSA ID Cache in CSR
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307571 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
7572 PMKIDCache,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007573 PMKIDCacheIndex);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007574 return 0;
7575}
7576
7577
Wilson Yang6507c4e2013-10-01 20:11:19 -07007578
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007579static int wlan_hdd_cfg80211_del_pmksa(struct wiphy *wiphy, struct net_device *dev,
Wilson Yang6507c4e2013-10-01 20:11:19 -07007580 struct cfg80211_pmksa *pmksa)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007581{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007582 tANI_U32 j=0;
7583 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7584 tHalHandle halHandle;
7585 int status;
7586 tANI_U8 BSSIDMatched = 0;
Wilson Yang6507c4e2013-10-01 20:11:19 -07007587 hdd_context_t *pHddCtx;
7588 int result = 0;
7589
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007590 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: deleting PMKSA for " MAC_ADDRESS_STR,
7591 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007592
7593 /* Validate pAdapter */
7594 if (NULL == pAdapter)
7595 {
7596 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Adapter" ,__func__);
7597 return -EINVAL;
7598 }
7599
7600 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7601 status = wlan_hdd_validate_context(pHddCtx);
7602
7603 if (0 != status)
7604 {
7605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7606 "%s: HDD context is not valid", __func__);
7607 return status;
7608 }
7609
7610 /*Retrieve halHandle*/
7611 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7612
7613 /*in case index is 0,no entry to delete*/
7614 if (0 == PMKIDCacheIndex)
7615 {
7616 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7617 __func__);
7618 return -EINVAL;
7619 }
7620
7621 /*find the matching PMKSA entry from j=0 to (index-1),
7622 * and delete the matched one
7623 */
7624 for (j = 0; j<PMKIDCacheIndex; j++)
7625 {
7626 if (vos_mem_compare(PMKIDCache[j].BSSID,
7627 pmksa->bssid,
7628 WNI_CFG_BSSID_LEN))
7629 {
7630 /* BSSID matched entry */
7631 BSSIDMatched = 1;
7632
7633 if (j<PMKIDCacheIndex-1)
7634 {
7635 /*replace the matching entry with the last entry in HDD local cache*/
7636 vos_mem_copy(PMKIDCache[j].BSSID,
7637 PMKIDCache[PMKIDCacheIndex-1].BSSID,
7638 WNI_CFG_BSSID_LEN);
7639 vos_mem_copy(PMKIDCache[j].PMKID,
7640 PMKIDCache[PMKIDCacheIndex-1].PMKID,
7641 CSR_RSN_PMKID_SIZE);
7642 }
7643
7644 /*clear the last entry in HDD cache ---[index-1]*/
Wilson Yang6507c4e2013-10-01 20:11:19 -07007645 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].BSSID, WNI_CFG_BSSID_LEN);
7646 vos_mem_zero(PMKIDCache[PMKIDCacheIndex-1].PMKID, CSR_RSN_PMKID_SIZE);
7647
7648 /*reduce the PMKID array index*/
7649 PMKIDCacheIndex--;
7650
7651 /*delete the last PMKID cache in CSR*/
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307652 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pmksa->bssid);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007653 if (0 != result)
7654 {
7655 hddLog(VOS_TRACE_LEVEL_ERROR,"%s: cannot delete PMKSA %d CONTENT.",
7656 __func__,PMKIDCacheIndex);
7657 }
7658
7659 dump_bssid(pmksa->bssid);
7660 dump_pmkid(halHandle,pmksa->pmkid);
7661
7662 break;
7663 }
7664 }
7665
7666 /* we compare all entries,but cannot find matching entry */
7667 if (j == MAX_PMKSAIDS_IN_CACHE && !BSSIDMatched)
7668 {
Jeff Johnson0299d0a2013-10-30 12:37:43 -07007669 hddLog(VOS_TRACE_LEVEL_FATAL,
7670 "%s: No such PMKSA entry existed " MAC_ADDRESS_STR,
7671 __func__, MAC_ADDR_ARRAY(pmksa->bssid));
Wilson Yang6507c4e2013-10-01 20:11:19 -07007672 dump_bssid(pmksa->bssid);
7673 dump_pmkid(halHandle, pmksa->pmkid);
7674 return -EINVAL;
7675 }
7676 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007677}
7678
Wilson Yang6507c4e2013-10-01 20:11:19 -07007679
7680
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007681static int wlan_hdd_cfg80211_flush_pmksa(struct wiphy *wiphy, struct net_device *dev)
7682{
Wilson Yang6507c4e2013-10-01 20:11:19 -07007683 tANI_U32 j=0;
7684 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7685 tHalHandle halHandle;
7686 hdd_context_t *pHddCtx;
7687 tANI_U8 *pBSSId;
7688 int status;
7689 int result;
7690
7691 hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: flushing PMKSA ",__func__);
7692
7693 /* Validate pAdapter */
7694 if (NULL == pAdapter)
7695 {
7696 hddLog(VOS_TRACE_LEVEL_ERROR,
7697 "%s: Invalid Adapter" ,__func__);
7698 return -EINVAL;
7699 }
7700
7701 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7702 status = wlan_hdd_validate_context(pHddCtx);
7703
7704 if (0 != status)
7705 {
7706 hddLog(VOS_TRACE_LEVEL_ERROR,
7707 "%s: HDD context is not valid", __func__);
7708 return status;
7709 }
7710
7711 /*Retrieve halHandle*/
7712 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
7713
7714 /*in case index is 0,no entry to delete*/
7715 if (0 == PMKIDCacheIndex)
7716 {
7717 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid entry to delete" ,
7718 __func__);
7719 return -EINVAL;
7720 }
7721
7722 /*delete all the PMKSA one by one */
7723 for (j = 0; j<PMKIDCacheIndex; j++)
7724 {
Wilson Yang6507c4e2013-10-01 20:11:19 -07007725 pBSSId =(tANI_U8 *)(PMKIDCache[j].BSSID);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007726
7727 /*delete the PMKID in CSR*/
7728 result = sme_RoamDelPMKIDfromCache(halHandle, pAdapter->sessionId, pBSSId);
7729
7730 if (0!= result)
7731 {
7732 hddLog(VOS_TRACE_LEVEL_ERROR ,"%s cannot flush PMKIDCache %d.",
7733 __func__,j);
7734 }
Kiet Lam8d21d5b2013-10-31 17:18:29 +05307735 /*clear the entry in HDD cache 0--index-1 */
7736 vos_mem_zero(PMKIDCache[j].BSSID, WNI_CFG_BSSID_LEN);
7737 vos_mem_zero(PMKIDCache[j].PMKID, CSR_RSN_PMKID_SIZE);
Wilson Yang6507c4e2013-10-01 20:11:19 -07007738 }
7739
7740 PMKIDCacheIndex = 0;
7741 return result;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007742}
7743#endif
7744
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007745#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307746static int wlan_hdd_cfg80211_update_ft_ies(struct wiphy *wiphy,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007747 struct net_device *dev, struct cfg80211_update_ft_ies_params *ftie)
7748{
7749 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7750 hdd_station_ctx_t *pHddStaCtx;
7751
7752 if (NULL == pAdapter)
7753 {
7754 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Adapter is NULL\n", __func__);
7755 return -ENODEV;
7756 }
7757
7758 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
7759
7760 // Added for debug on reception of Re-assoc Req.
7761 if (eConnectionState_Associated != pHddStaCtx->conn_info.connState)
7762 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307763 hddLog(LOGE, FL("Called with Ie of length = %d when not associated\n"),
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007764 ftie->ie_len);
7765 hddLog(LOGE, FL("Should be Re-assoc Req IEs\n"));
7766 }
7767
7768#ifdef WLAN_FEATURE_VOWIFI_11R_DEBUG
Gopichand Nakkala747461f2013-04-24 19:24:45 +05307769 hddLog(LOGE, FL("%s called with Ie of length = %d\n"), __func__,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007770 ftie->ie_len);
7771#endif
7772
7773 // Pass the received FT IEs to SME
Gopichand Nakkala356fb102013-03-06 12:34:04 +05307774 sme_SetFTIEs( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
7775 (const u8 *)ftie->ie,
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07007776 ftie->ie_len);
7777 return 0;
7778}
7779#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007780
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307781#ifdef FEATURE_WLAN_SCAN_PNO
7782
7783void hdd_cfg80211_sched_scan_done_callback(void *callbackContext,
7784 tSirPrefNetworkFoundInd *pPrefNetworkFoundInd)
7785{
7786 int ret;
7787 hdd_adapter_t* pAdapter = (hdd_adapter_t*)callbackContext;
7788 hdd_context_t *pHddCtx;
7789
7790 if (NULL == pAdapter)
7791 {
7792 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7793 "%s: HDD adapter is Null", __func__);
7794 return ;
7795 }
7796
7797 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
7798 if (NULL == pHddCtx)
7799 {
7800 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7801 "%s: HDD context is Null!!!", __func__);
7802 return ;
7803 }
7804
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307805 spin_lock(&pHddCtx->schedScan_lock);
7806 if (TRUE == pHddCtx->isWiphySuspended)
7807 {
7808 pHddCtx->isSchedScanUpdatePending = TRUE;
7809 spin_unlock(&pHddCtx->schedScan_lock);
7810 hddLog(VOS_TRACE_LEVEL_INFO,
7811 "%s: Update cfg80211 scan database after it resume", __func__);
7812 return ;
7813 }
7814 spin_unlock(&pHddCtx->schedScan_lock);
7815
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307816 ret = wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter);
7817
7818 if (0 > ret)
7819 hddLog(VOS_TRACE_LEVEL_INFO, "%s: NO SCAN result", __func__);
7820
7821 cfg80211_sched_scan_results(pHddCtx->wiphy);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7823 "%s: cfg80211 scan result database updated", __func__);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307824}
7825
7826/*
7827 * FUNCTION: wlan_hdd_cfg80211_sched_scan_start
7828 * NL interface to enable PNO
7829 */
7830static int wlan_hdd_cfg80211_sched_scan_start(struct wiphy *wiphy,
7831 struct net_device *dev, struct cfg80211_sched_scan_request *request)
7832{
7833 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
7834 tpSirPNOScanReq pPnoRequest = NULL;
7835 hdd_context_t *pHddCtx;
7836 tHalHandle hHal;
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307837 v_U32_t i, indx, num_ch, tempInterval;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307838 u8 valid_ch[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7839 u8 channels_allowed[WNI_CFG_VALID_CHANNEL_LIST_LEN];
7840 v_U32_t num_channels_allowed = WNI_CFG_VALID_CHANNEL_LIST_LEN;
7841 eHalStatus status = eHAL_STATUS_FAILURE;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307842 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307843
7844 if (NULL == pAdapter)
7845 {
7846 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7847 "%s: HDD adapter is Null", __func__);
7848 return -ENODEV;
7849 }
7850
7851 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307852 ret = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307853
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307854 if (0 != ret)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307855 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05307856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7857 "%s: HDD context is not valid", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307858 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307859 }
7860
7861 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
7862 if (NULL == hHal)
7863 {
7864 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7865 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05307866 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307867 }
7868
7869 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
7870 if (NULL == pPnoRequest)
7871 {
7872 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
7873 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307874 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307875 }
7876
Madan Mohan Koyyalamudic3f04352013-09-26 19:21:48 +05307877 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307878 pPnoRequest->enable = 1; /*Enable PNO */
7879 pPnoRequest->ucNetworksCount = request->n_match_sets;
7880
7881 if (( !pPnoRequest->ucNetworksCount ) ||
7882 ( pPnoRequest->ucNetworksCount > SIR_PNO_MAX_SUPP_NETWORKS ))
7883 {
7884 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7885 "Network input is not correct");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307886 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307887 goto error;
7888 }
7889
7890 if ( SIR_PNO_MAX_NETW_CHANNELS_EX < request->n_channels )
7891 {
7892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7893 "Incorrect number of channels");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307894 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307895 goto error;
7896 }
7897
7898 /* Framework provides one set of channels(all)
7899 * common for all saved profile */
7900 if (0 != ccmCfgGetStr(hHal, WNI_CFG_VALID_CHANNEL_LIST,
7901 channels_allowed, &num_channels_allowed))
7902 {
7903 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7904 "%s: failed to get valid channel list", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307905 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307906 goto error;
7907 }
7908 /* Checking each channel against allowed channel list */
7909 num_ch = 0;
7910 for (i = 0; i < request->n_channels; i++)
7911 {
7912 for (indx = 0; indx < num_channels_allowed; indx++)
7913 {
7914 if (request->channels[i]->hw_value == channels_allowed[indx])
7915 {
7916 valid_ch[num_ch++] = request->channels[i]->hw_value;
7917 break ;
7918 }
7919 }
7920 }
7921
7922 /* Filling per profile params */
7923 for (i = 0; i < pPnoRequest->ucNetworksCount; i++)
7924 {
7925 pPnoRequest->aNetworks[i].ssId.length =
7926 request->match_sets[i].ssid.ssid_len;
7927
7928 if (( 0 == pPnoRequest->aNetworks[i].ssId.length ) ||
7929 ( pPnoRequest->aNetworks[i].ssId.length > 32 ) )
7930 {
7931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
7932 "SSID Len %d is not correct for network %d",
7933 pPnoRequest->aNetworks[i].ssId.length, i);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05307934 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307935 goto error;
7936 }
7937
7938 memcpy(pPnoRequest->aNetworks[i].ssId.ssId,
7939 request->match_sets[i].ssid.ssid,
7940 request->match_sets[i].ssid.ssid_len);
7941 pPnoRequest->aNetworks[i].authentication = 0; /*eAUTH_TYPE_ANY*/
7942 pPnoRequest->aNetworks[i].encryption = 0; /*eED_ANY*/
7943 pPnoRequest->aNetworks[i].bcastNetwType = 0; /*eBCAST_UNKNOWN*/
7944
7945 /*Copying list of valid channel into request */
7946 memcpy(pPnoRequest->aNetworks[i].aChannels, valid_ch, num_ch);
7947 pPnoRequest->aNetworks[i].ucChannelCount = num_ch;
7948
7949 pPnoRequest->aNetworks[i].rssiThreshold = 0; //Default value
7950 }
7951
Madan Mohan Koyyalamudia7765d52013-09-18 16:49:56 +05307952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7953 "request->ie_len = %d", request->ie_len);
7954 if ((0 < request->ie_len) && (NULL != request->ie))
7955 {
7956 pPnoRequest->us24GProbeTemplateLen = request->ie_len;
7957 memcpy(&pPnoRequest->p24GProbeTemplate, request->ie,
7958 pPnoRequest->us24GProbeTemplateLen);
7959
7960 pPnoRequest->us5GProbeTemplateLen = request->ie_len;
7961 memcpy(&pPnoRequest->p5GProbeTemplate, request->ie,
7962 pPnoRequest->us5GProbeTemplateLen);
7963 }
7964
Madan Mohan Koyyalamudi1d16f462013-08-27 16:25:34 +05307965 /* Driver gets only one time interval which is hardcoded in
7966 * supplicant for 10000ms. Taking power consumption into account 6 timers
7967 * will be used, Timervalue is increased exponentially i.e 10,20,40,
7968 * 80,160,320 secs. And number of scan cycle for each timer
7969 * is configurable through INI param gPNOScanTimerRepeatValue.
7970 * If it is set to 0 only one timer will be used and PNO scan cycle
7971 * will be repeated after each interval specified by supplicant
7972 * till PNO is disabled.
7973 */
7974 if (0 == pHddCtx->cfg_ini->configPNOScanTimerRepeatValue)
7975 pPnoRequest->scanTimers.ucScanTimersCount = HDD_PNO_SCAN_TIMERS_SET_ONE;
7976 else
7977 pPnoRequest->scanTimers.ucScanTimersCount =
7978 HDD_PNO_SCAN_TIMERS_SET_MULTIPLE;
7979
7980 tempInterval = (request->interval)/1000;
7981 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
7982 "Base scan interval = %d PNOScanTimerRepeatValue = %d",
7983 tempInterval, pHddCtx->cfg_ini->configPNOScanTimerRepeatValue);
7984 for ( i = 0; i < pPnoRequest->scanTimers.ucScanTimersCount; i++)
7985 {
7986 pPnoRequest->scanTimers.aTimerValues[i].uTimerRepeat =
7987 pHddCtx->cfg_ini->configPNOScanTimerRepeatValue;
7988 pPnoRequest->scanTimers.aTimerValues[i].uTimerValue = tempInterval;
7989 tempInterval *= 2;
7990 }
7991 //Repeat last timer until pno disabled.
7992 pPnoRequest->scanTimers.aTimerValues[i-1].uTimerRepeat = 0;
7993
Madan Mohan Koyyalamudid206c7b2013-09-26 22:54:51 +05307994 pPnoRequest->modePNO = SIR_PNO_MODE_IMMEDIATE;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05307995
7996 status = sme_SetPreferredNetworkList(WLAN_HDD_GET_HAL_CTX(pAdapter),
7997 pPnoRequest, pAdapter->sessionId,
7998 hdd_cfg80211_sched_scan_done_callback, pAdapter);
7999 if (eHAL_STATUS_SUCCESS != status)
8000 {
8001 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8002 "Failed to enable PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308003 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308004 goto error;
8005 }
8006
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8008 "PNO scanRequest offloaded");
8009
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308010error:
8011 vos_mem_free(pPnoRequest);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308012 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308013}
8014
8015/*
8016 * FUNCTION: wlan_hdd_cfg80211_sched_scan_stop
8017 * NL interface to disable PNO
8018 */
8019static int wlan_hdd_cfg80211_sched_scan_stop(struct wiphy *wiphy,
8020 struct net_device *dev)
8021{
8022 eHalStatus status = eHAL_STATUS_FAILURE;
8023 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8024 hdd_context_t *pHddCtx;
8025 tHalHandle hHal;
8026 tpSirPNOScanReq pPnoRequest = NULL;
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308027 int ret = 0;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308028
8029 ENTER();
8030
8031 if (NULL == pAdapter)
8032 {
8033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8034 "%s: HDD adapter is Null", __func__);
8035 return -ENODEV;
8036 }
8037
8038 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308039
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308040 if (NULL == pHddCtx)
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308041 {
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308042 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308043 "%s: HDD context is Null", __func__);
8044 return -ENODEV;
8045 }
8046
8047 /* The return 0 is intentional when isLogpInProgress and
8048 * isLoadUnloadInProgress. We did observe a crash due to a return of
8049 * failure in sched_scan_stop , especially for a case where the unload
8050 * of the happens at the same time. The function __cfg80211_stop_sched_scan
8051 * was clearing rdev->sched_scan_req only when the sched_scan_stop returns
8052 * success. If it returns a failure , then its next invocation due to the
8053 * clean up of the second interface will have the dev pointer corresponding
8054 * to the first one leading to a crash.
8055 */
8056 if (pHddCtx->isLogpInProgress)
8057 {
8058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8059 "%s: LOGP in Progress. Ignore!!!", __func__);
8060 return ret;
8061 }
8062
8063 if (pHddCtx->isLoadUnloadInProgress)
8064 {
8065 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8066 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
8067 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308068 }
8069
8070 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8071 if (NULL == hHal)
8072 {
8073 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8074 "%s: HAL context is Null!!!", __func__);
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308075 return -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308076 }
8077
8078 pPnoRequest = (tpSirPNOScanReq) vos_mem_malloc(sizeof (tSirPNOScanReq));
8079 if (NULL == pPnoRequest)
8080 {
8081 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8082 "%s: vos_mem_malloc failed", __func__);
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308083 return -ENOMEM;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308084 }
8085
8086 memset(pPnoRequest, 0, sizeof (tSirPNOScanReq));
8087 pPnoRequest->enable = 0; /* Disable PNO */
8088 pPnoRequest->ucNetworksCount = 0;
8089
8090 status = sme_SetPreferredNetworkList(hHal, pPnoRequest,
8091 pAdapter->sessionId,
8092 NULL, pAdapter);
8093 if (eHAL_STATUS_SUCCESS != status)
8094 {
8095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8096 "Failed to disabled PNO");
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308097 ret = -EINVAL;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308098 }
8099
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05308100 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8101 "%s: PNO scan disabled", __func__);
8102
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308103 vos_mem_free(pPnoRequest);
8104
8105 EXIT();
Kamath Vinayakba5313f2013-08-22 15:52:39 +05308106 return ret;
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05308107}
8108
8109#endif /*FEATURE_WLAN_SCAN_PNO*/
8110
8111
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008112#ifdef FEATURE_WLAN_TDLS
8113static int wlan_hdd_cfg80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
8114 u8 *peer, u8 action_code, u8 dialog_token,
8115 u16 status_code, const u8 *buf, size_t len)
8116{
8117
8118 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8119 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008120 u8 peerMac[6];
8121 VOS_STATUS status;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008122 int max_sta_failed = 0;
Hoonki Leea34dd892013-02-05 22:56:02 -08008123 int responder;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008124 long rc;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008125
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008126 if (NULL == pHddCtx || NULL == pHddCtx->cfg_ini)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008127 {
Gopichand Nakkala747461f2013-04-24 19:24:45 +05308128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008129 "Invalid arguments");
8130 return -EINVAL;
8131 }
8132
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008133 if (pHddCtx->isLogpInProgress)
8134 {
8135 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8136 "%s:LOGP in Progress. Ignore!!!", __func__);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008137 wlan_hdd_tdls_set_link_status(pAdapter, peer, eTDLS_LINK_IDLE);
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008138 return -EBUSY;
8139 }
8140
Hoonki Lee27511902013-03-14 18:19:06 -07008141 if (eTDLS_SUPPORT_NOT_ENABLED == pHddCtx->tdls_mode)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008142 {
Hoonki Lee27511902013-03-14 18:19:06 -07008143 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8144 "%s: TDLS mode is disabled OR not enabled in FW."
8145 MAC_ADDRESS_STR " action %d declined.",
8146 __func__, MAC_ADDR_ARRAY(peer), action_code);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008147 return -ENOTSUPP;
8148 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008149
Hoonki Lee27511902013-03-14 18:19:06 -07008150 /* other than teardown frame, other mgmt frames are not sent if disabled */
8151 if (SIR_MAC_TDLS_TEARDOWN != action_code)
8152 {
8153 /* if tdls_mode is disabled to respond to peer's request */
8154 if (eTDLS_SUPPORT_DISABLED == pHddCtx->tdls_mode)
8155 {
8156 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
8157 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008158 " TDLS mode is disabled. action %d declined.",
8159 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee27511902013-03-14 18:19:06 -07008160
8161 return -ENOTSUPP;
8162 }
8163 }
8164
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008165 if (WLAN_IS_TDLS_SETUP_ACTION(action_code))
8166 {
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308167 if (NULL != wlan_hdd_tdls_is_progress(pHddCtx, peer, TRUE))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008168 {
8169 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008170 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008171 " TDLS setup is ongoing. action %d declined.",
8172 __func__, MAC_ADDR_ARRAY(peer), action_code);
8173 return -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008174 }
8175 }
8176
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008177 if (SIR_MAC_TDLS_SETUP_REQ == action_code ||
8178 SIR_MAC_TDLS_SETUP_RSP == action_code )
Lee Hoonkic1262f22013-01-24 21:59:00 -08008179 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008180 if (HDD_MAX_NUM_TDLS_STA <= wlan_hdd_tdlsConnectedPeers(pAdapter))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008181 {
8182 /* supplicant still sends tdls_mgmt(SETUP_REQ) even after
8183 we return error code at 'add_station()'. Hence we have this
8184 check again in addtion to add_station().
8185 Anyway, there is no hard to double-check. */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008186 if (SIR_MAC_TDLS_SETUP_REQ == action_code)
Lee Hoonkic1262f22013-01-24 21:59:00 -08008187 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008188 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8189 "%s: " MAC_ADDRESS_STR
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008190 " TDLS Max peer already connected. action %d declined.",
8191 __func__, MAC_ADDR_ARRAY(peer), action_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008192 goto error;
Lee Hoonkic1262f22013-01-24 21:59:00 -08008193 }
8194 else
8195 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008196 /* maximum reached. tweak to send error code to peer and return
8197 error code to supplicant */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008198 status_code = eSIR_MAC_UNSPEC_FAILURE_STATUS;
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8200 "%s: " MAC_ADDRESS_STR
8201 " TDLS Max peer already connected send response status %d",
8202 __func__, MAC_ADDR_ARRAY(peer), status_code);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008203 max_sta_failed = -EPERM;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008204 /* fall through to send setup resp with failure status
8205 code */
Lee Hoonkic1262f22013-01-24 21:59:00 -08008206 }
8207 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008208 else
8209 {
8210 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308211 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008212 if (pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008213 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008214 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkala34d1b062013-03-19 15:28:33 -07008215 "%s:" MAC_ADDRESS_STR " already connected. action %d declined.",
8216 __func__, MAC_ADDR_ARRAY(peer), action_code);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008217 return -EPERM;
8218 }
8219 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008220 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008221 vos_mem_copy(peerMac, peer, 6);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008222
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008223#ifdef WLAN_FEATURE_TDLS_DEBUG
8224 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008225 "%s: " MAC_ADDRESS_STR " action %d, dialog_token %d status %d, len = %d",
8226 "tdls_mgmt", MAC_ADDR_ARRAY(peer),
8227 action_code, dialog_token, status_code, len);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008228#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008229
Hoonki Leea34dd892013-02-05 22:56:02 -08008230 /*Except teardown responder will not be used so just make 0*/
8231 responder = 0;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08008232 if (SIR_MAC_TDLS_TEARDOWN == action_code)
Hoonki Leea34dd892013-02-05 22:56:02 -08008233 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008234
8235 hddTdlsPeer_t *pTdlsPeer;
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308236 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peerMac, TRUE);
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008237
8238 if(pTdlsPeer && TDLS_IS_CONNECTED(pTdlsPeer))
8239 responder = pTdlsPeer->is_responder;
8240 else
Hoonki Leea34dd892013-02-05 22:56:02 -08008241 {
Gopichand Nakkala97a65fd2013-04-16 16:59:38 -07008242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8243 "%s: " MAC_ADDRESS_STR " peer doesn't exist or not connected %d dialog_token %d status %d, len = %d",
8244 __func__, MAC_ADDR_ARRAY(peer), (NULL == pTdlsPeer) ? -1 : pTdlsPeer->link_status,
8245 dialog_token, status_code, len);
8246 return -EPERM;
Hoonki Leea34dd892013-02-05 22:56:02 -08008247 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008248 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008249
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308250 /* For explicit trigger of DIS_REQ come out of BMPS for
8251 successfully receiving DIS_RSP from peer. */
Hoonki Lee14621352013-04-16 17:51:19 -07008252 if ((SIR_MAC_TDLS_SETUP_RSP == action_code) ||
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308253 (SIR_MAC_TDLS_DIS_RSP == action_code) ||
8254 (SIR_MAC_TDLS_DIS_REQ == action_code))
Hoonki Lee14621352013-04-16 17:51:19 -07008255 {
8256 if (TRUE == sme_IsPmcBmps(WLAN_HDD_GET_HAL_CTX(pAdapter)))
8257 {
8258 VOS_TRACE( VOS_MODULE_ID_HDD, TDLS_LOG_LEVEL,
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308259 "%s: Sending frame action_code %u.Disable BMPS", __func__, action_code);
Hoonki Lee14621352013-04-16 17:51:19 -07008260 hdd_disable_bmps_imps(pHddCtx, WLAN_HDD_INFRA_STATION);
8261 }
Gopichand Nakkala2f1ff152013-07-01 11:27:43 +05308262 if (SIR_MAC_TDLS_DIS_REQ != action_code)
8263 wlan_hdd_tdls_set_cap(pAdapter, peerMac, eTDLS_CAP_SUPPORTED);
Hoonki Lee14621352013-04-16 17:51:19 -07008264 }
8265
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008266 /* make sure doesn't call send_mgmt() while it is pending */
8267 if (TDLS_CTX_MAGIC == pAdapter->mgmtTxCompletionStatus)
8268 {
8269 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8270 "%s: " MAC_ADDRESS_STR " action %d couldn't sent, as one is pending. return EBUSY\n",
8271 __func__, MAC_ADDR_ARRAY(peer), action_code);
8272 return -EBUSY;
8273 }
8274
8275 pAdapter->mgmtTxCompletionStatus = TDLS_CTX_MAGIC;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008276 INIT_COMPLETION(pAdapter->tdls_mgmt_comp);
8277
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008278 status = sme_SendTdlsMgmtFrame(WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId,
Hoonki Leea34dd892013-02-05 22:56:02 -08008279 peerMac, action_code, dialog_token, status_code, (tANI_U8 *)buf, len, responder);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008280
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008281 if (VOS_STATUS_SUCCESS != status)
8282 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008283 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8284 "%s: sme_SendTdlsMgmtFrame failed!", __func__);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008285 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Lee14621352013-04-16 17:51:19 -07008286 wlan_hdd_tdls_check_bmps(pAdapter);
8287 goto error;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008288 }
8289
Hoonki Leed37cbb32013-04-20 00:31:14 -07008290 rc = wait_for_completion_interruptible_timeout(&pAdapter->tdls_mgmt_comp,
8291 msecs_to_jiffies(WAIT_TIME_TDLS_MGMT));
8292
8293 if ((rc <= 0) || (TRUE != pAdapter->mgmtTxCompletionStatus))
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008294 {
Hoonki Leed37cbb32013-04-20 00:31:14 -07008295 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07008296 "%s: Mgmt Tx Completion failed status %ld TxCompletion %u",
Hoonki Leed37cbb32013-04-20 00:31:14 -07008297 __func__, rc, pAdapter->mgmtTxCompletionStatus);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008298 pAdapter->mgmtTxCompletionStatus = FALSE;
Hoonki Leed37cbb32013-04-20 00:31:14 -07008299 wlan_hdd_tdls_check_bmps(pAdapter);
8300 goto error;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008301 }
8302
Gopichand Nakkala05922802013-03-14 12:23:19 -07008303 if (max_sta_failed)
Hoonki Lee14621352013-04-16 17:51:19 -07008304 {
8305 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala05922802013-03-14 12:23:19 -07008306 return max_sta_failed;
Hoonki Lee14621352013-04-16 17:51:19 -07008307 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008308
Hoonki Leea34dd892013-02-05 22:56:02 -08008309 if (SIR_MAC_TDLS_SETUP_RSP == action_code)
8310 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008311 wlan_hdd_tdls_set_responder(pAdapter, peerMac, TRUE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008312 }
8313 else if (SIR_MAC_TDLS_SETUP_CNF == action_code)
8314 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08008315 wlan_hdd_tdls_set_responder(pAdapter, peerMac, FALSE);
Hoonki Leea34dd892013-02-05 22:56:02 -08008316 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008317
8318 return 0;
Gopichand Nakkala05922802013-03-14 12:23:19 -07008319error:
8320 /* max_sta_failed ; we didn't set to CONNECTING for this case,
8321 because we already know that this transaction will be failed,
8322 but we weren't sure if supplicant call DISABLE_LINK or not. So,
8323 to be safe, do not change the state mahine.
8324 */
8325 if(max_sta_failed == 0 &&
8326 (WLAN_IS_TDLS_SETUP_ACTION(action_code)))
8327 wlan_hdd_tdls_set_link_status(pAdapter, peerMac, eTDLS_LINK_IDLE);
8328 return -EPERM;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008329}
8330
8331static int wlan_hdd_cfg80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
8332 u8 *peer, enum nl80211_tdls_operation oper)
8333{
8334 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8335 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308336 int status;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008337#ifdef WLAN_FEATURE_TDLS_DEBUG
8338 const char *tdls_oper_str[]= {
8339 "NL80211_TDLS_DISCOVERY_REQ",
8340 "NL80211_TDLS_SETUP",
8341 "NL80211_TDLS_TEARDOWN",
8342 "NL80211_TDLS_ENABLE_LINK",
8343 "NL80211_TDLS_DISABLE_LINK",
Gopichand Nakkala29d00192013-06-20 19:03:52 +05308344 "NL80211_TDLS_UNKNOWN_OPER"};
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008345#endif
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008346 hddTdlsPeer_t *pTdlsPeer;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008347
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308348 if ( NULL == peer )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008349 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08008350 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008351 "%s: Invalid arguments", __func__);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008352 return -EINVAL;
8353 }
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008354
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308355 status = wlan_hdd_validate_context(pHddCtx);
8356
8357 if (0 != status)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008358 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8360 "%s: HDD context is not valid", __func__);
8361 return status;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08008362 }
8363
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05308364 pTdlsPeer = wlan_hdd_tdls_find_peer(pAdapter, peer, TRUE);
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008365
8366 if ( NULL == pTdlsPeer ) {
8367 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: " MAC_ADDRESS_STR " (oper %d) not exsting. ignored",
8368 __func__, MAC_ADDR_ARRAY(peer), (int)oper);
8369 return -EINVAL;
8370 }
8371
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008372#ifdef WLAN_FEATURE_TDLS_DEBUG
8373 if((int)oper > 4)
8374 oper = 5;
8375
8376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008377 "%s: " MAC_ADDRESS_STR " link_status %d (%s) ", "tdls_oper",
8378 MAC_ADDR_ARRAY(peer), pTdlsPeer->link_status,
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008379 tdls_oper_str[(int)oper]);
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008380#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008381
8382 if( FALSE == pHddCtx->cfg_ini->fEnableTDLSSupport ||
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008383 FALSE == sme_IsFeatureSupportedByFW(TDLS))
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008384 {
Hoonki Lee1090c6a2013-01-16 17:40:54 -08008385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Chilam Ngc4244af2013-04-01 15:37:32 -07008386 "TDLS Disabled in INI OR not enabled in FW. "
8387 "Cannot process TDLS commands");
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008388 return -ENOTSUPP;
8389 }
8390
8391 switch (oper) {
8392 case NL80211_TDLS_ENABLE_LINK:
8393 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008394 VOS_STATUS status;
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308395 tCsrTdlsLinkEstablishParams tdlsLinkEstablishParams;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008396
Gopichand Nakkala2f4a2822013-04-17 11:22:01 -07008397 if (!TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
8398 {
8399 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Invalid Staion Index %u "
8400 MAC_ADDRESS_STR " failed",
8401 __func__, pTdlsPeer->staId, MAC_ADDR_ARRAY(peer));
8402 return -EINVAL;
8403 }
8404
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008405 if (eTDLS_LINK_CONNECTED != pTdlsPeer->link_status)
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008406 {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308407 long ret;
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308408 if (IS_ADVANCE_TDLS_ENABLE) {
Gopichand Nakkala24be5312013-07-02 16:47:12 +05308409
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308410 if (0 != wlan_hdd_tdls_get_link_establish_params(
8411 pAdapter, peer,&tdlsLinkEstablishParams)) {
8412 return -EINVAL;
8413 }
8414 INIT_COMPLETION(pAdapter->tdls_link_establish_req_comp);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308415
Madan Mohan Koyyalamudice419872013-09-13 19:36:52 +05308416 sme_SendTdlsLinkEstablishParams(WLAN_HDD_GET_HAL_CTX(pAdapter),
8417 pAdapter->sessionId, peer, &tdlsLinkEstablishParams);
8418 /* Send TDLS peer UAPSD capabilities to the firmware and
8419 * register with the TL on after the response for this operation
8420 * is received .
8421 */
8422 ret = wait_for_completion_interruptible_timeout(
8423 &pAdapter->tdls_link_establish_req_comp,
8424 msecs_to_jiffies(WAIT_TIME_TDLS_LINK_ESTABLISH_REQ));
8425 if (ret <= 0)
8426 {
8427 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8428 "%s: Link Establish Request Faled Status %ld",
8429 __func__, ret);
8430 return -EINVAL;
8431 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308432 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008433 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_CONNECTED);
Gopichand Nakkala471708b2013-06-04 20:03:01 +05308434 /* Mark TDLS client Authenticated .*/
8435 status = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
8436 pTdlsPeer->staId,
8437 WLANTL_STA_AUTHENTICATED);
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008438 if (VOS_STATUS_SUCCESS == status)
8439 {
Hoonki Lee14621352013-04-16 17:51:19 -07008440 if (pTdlsPeer->is_responder == 0)
8441 {
8442 v_U8_t staId = (v_U8_t)pTdlsPeer->staId;
8443
8444 wlan_hdd_tdls_timer_restart(pAdapter,
8445 &pTdlsPeer->initiatorWaitTimeoutTimer,
8446 WAIT_TIME_TDLS_INITIATOR);
8447 /* suspend initiator TX until it receives direct packet from the
8448 reponder or WAIT_TIME_TDLS_INITIATOR timer expires */
8449 WLANTL_SuspendDataTx( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8450 &staId, NULL);
8451 }
Gopichand Nakkalaccd3a382013-03-19 13:56:10 -07008452 wlan_hdd_tdls_increment_peer_count(pAdapter);
8453 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008454 wlan_hdd_tdls_check_bmps(pAdapter);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308455
8456 /* Update TL about the UAPSD masks , to route the packets to firmware */
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308457 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSBufferSta)
8458 || pHddCtx->cfg_ini->fTDLSUapsdMask )
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308459 {
Gopichand Nakkala574f6d12013-06-27 19:38:43 +05308460 int ac;
8461 uint8 ucAc[4] = { WLANTL_AC_VO,
8462 WLANTL_AC_VI,
8463 WLANTL_AC_BK,
8464 WLANTL_AC_BE };
8465 uint8 tlTid[4] = { 7, 5, 2, 3 } ;
8466 for(ac=0; ac < 4; ac++)
8467 {
8468 status = WLANTL_EnableUAPSDForAC( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
8469 pTdlsPeer->staId, ucAc[ac],
8470 tlTid[ac], tlTid[ac], 0, 0,
8471 WLANTL_BI_DIR );
8472 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05308473 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008474 }
8475
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008476 }
8477 break;
8478 case NL80211_TDLS_DISABLE_LINK:
Lee Hoonkic1262f22013-01-24 21:59:00 -08008479 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008480 if(TDLS_STA_INDEX_VALID(pTdlsPeer->staId))
Lee Hoonkic1262f22013-01-24 21:59:00 -08008481 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008482 long status;
8483
8484 INIT_COMPLETION(pAdapter->tdls_del_station_comp);
8485
Lee Hoonkic1262f22013-01-24 21:59:00 -08008486 sme_DeleteTdlsPeerSta( WLAN_HDD_GET_HAL_CTX(pAdapter),
8487 pAdapter->sessionId, peer );
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008488
8489 status = wait_for_completion_interruptible_timeout(&pAdapter->tdls_del_station_comp,
8490 msecs_to_jiffies(WAIT_TIME_TDLS_DEL_STA));
8491 if (status <= 0)
8492 {
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008493 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07008494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8495 "%s: Del station failed status %ld",
8496 __func__, status);
8497 return -EPERM;
8498 }
Hoonki Lee5305c3a2013-04-29 23:28:59 -07008499 wlan_hdd_tdls_set_peer_link_status(pTdlsPeer, eTDLS_LINK_IDLE);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008500 }
8501 else
8502 {
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008503 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8504 "%s: TDLS Peer Station doesn't exist.", __func__);
Lee Hoonkic1262f22013-01-24 21:59:00 -08008505 }
Lee Hoonkic1262f22013-01-24 21:59:00 -08008506 }
Gopichand Nakkalac87400e2013-03-13 18:51:00 -07008507 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008508 case NL80211_TDLS_TEARDOWN:
8509 case NL80211_TDLS_SETUP:
8510 case NL80211_TDLS_DISCOVERY_REQ:
8511 /* We don't support in-driver setup/teardown/discovery */
8512 return -ENOTSUPP;
8513 default:
8514 return -ENOTSUPP;
8515 }
8516 return 0;
8517}
Chilam NG571c65a2013-01-19 12:27:36 +05308518
8519int wlan_hdd_cfg80211_send_tdls_discover_req(struct wiphy *wiphy,
8520 struct net_device *dev, u8 *peer)
8521{
Arif Hussaina7c8e412013-11-20 11:06:42 -08008522 hddLog(VOS_TRACE_LEVEL_INFO,
8523 "tdls send discover req: "MAC_ADDRESS_STR,
8524 MAC_ADDR_ARRAY(peer));
Chilam NG571c65a2013-01-19 12:27:36 +05308525
8526 return wlan_hdd_cfg80211_tdls_mgmt(wiphy, dev, peer,
8527 WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, NULL, 0);
8528}
Mohit Khanna698ba2a2012-12-04 15:08:18 -08008529#endif
8530
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308531#ifdef WLAN_FEATURE_GTK_OFFLOAD
8532/*
8533 * FUNCTION: wlan_hdd_cfg80211_update_replayCounterCallback
8534 * Callback rountine called upon receiving response for
8535 * get offload info
8536 */
8537void wlan_hdd_cfg80211_update_replayCounterCallback(void *callbackContext,
8538 tpSirGtkOffloadGetInfoRspParams pGtkOffloadGetInfoRsp)
8539{
8540
8541 hdd_adapter_t *pAdapter = (hdd_adapter_t *)callbackContext;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308542 tANI_U8 tempReplayCounter[8];
8543 hdd_station_ctx_t *pHddStaCtx;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308544
8545 ENTER();
8546
8547 if (NULL == pAdapter)
8548 {
8549 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8550 "%s: HDD adapter is Null", __func__);
8551 return ;
8552 }
8553
8554 if (NULL == pGtkOffloadGetInfoRsp)
8555 {
8556 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8557 "%s: pGtkOffloadGetInfoRsp is Null", __func__);
8558 return ;
8559 }
8560
8561 if (VOS_STATUS_SUCCESS != pGtkOffloadGetInfoRsp->ulStatus)
8562 {
8563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8564 "%s: wlan Failed to get replay counter value",
8565 __func__);
8566 return ;
8567 }
8568
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308569 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8570 /* Update replay counter */
8571 pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter =
8572 pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8573
8574 {
8575 /* changing from little to big endian since supplicant
8576 * works on big endian format
8577 */
8578 int i;
8579 tANI_U8 *p = (tANI_U8 *)&pGtkOffloadGetInfoRsp->ullKeyReplayCounter;
8580
8581 for (i = 0; i < 8; i++)
8582 {
8583 tempReplayCounter[7-i] = (tANI_U8)p[i];
8584 }
8585 }
8586
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308587 /* Update replay counter to NL */
8588 cfg80211_gtk_rekey_notify(pAdapter->dev, pGtkOffloadGetInfoRsp->bssId,
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308589 tempReplayCounter, GFP_KERNEL);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308590}
8591
8592/*
8593 * FUNCTION: wlan_hdd_cfg80211_set_rekey_data
8594 * This function is used to offload GTK rekeying job to the firmware.
8595 */
8596int wlan_hdd_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *dev,
8597 struct cfg80211_gtk_rekey_data *data)
8598{
8599 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8600 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
8601 hdd_station_ctx_t *pHddStaCtx;
8602 tHalHandle hHal;
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308603 int result;
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308604 tSirGtkOffloadParams hddGtkOffloadReqParams;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308605 eHalStatus status = eHAL_STATUS_FAILURE;
8606
8607 ENTER();
8608
8609 if (NULL == pAdapter)
8610 {
8611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8612 "%s: HDD adapter is Null", __func__);
8613 return -ENODEV;
8614 }
8615
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308616 result = wlan_hdd_validate_context(pHddCtx);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308617
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308618 if (0 != result)
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308619 {
Gopichand Nakkalaf502e2b2013-05-24 18:34:25 +05308620 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8621 "%s: HDD context is not valid", __func__);
8622 return result;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308623 }
8624
8625 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8626 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
8627 if (NULL == hHal)
8628 {
8629 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8630 "%s: HAL context is Null!!!", __func__);
8631 return -EAGAIN;
8632 }
8633
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308634 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_ENABLE;
8635 memcpy(pHddStaCtx->gtkOffloadReqParams.aKCK, data->kck, NL80211_KCK_LEN);
8636 memcpy(pHddStaCtx->gtkOffloadReqParams.aKEK, data->kek, NL80211_KEK_LEN);
8637 memcpy(pHddStaCtx->gtkOffloadReqParams.bssId, &pHddStaCtx->conn_info.bssId,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308638 WNI_CFG_BSSID_LEN);
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308639 {
8640 /* changing from big to little endian since driver
8641 * works on little endian format
8642 */
8643 tANI_U8 *p =
8644 (tANI_U8 *)&pHddStaCtx->gtkOffloadReqParams.ullKeyReplayCounter;
8645 int i;
8646
8647 for (i = 0; i < 8; i++)
8648 {
8649 p[7-i] = data->replay_ctr[i];
8650 }
8651 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308652
8653 if (TRUE == pHddCtx->hdd_wlan_suspended)
8654 {
8655 /* if wlan is suspended, enable GTK offload directly from here */
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308656 memcpy(&hddGtkOffloadReqParams, &pHddStaCtx->gtkOffloadReqParams,
8657 sizeof (tSirGtkOffloadParams));
8658 status = sme_SetGTKOffload(hHal, &hddGtkOffloadReqParams,
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308659 pAdapter->sessionId);
8660
8661 if (eHAL_STATUS_SUCCESS != status)
8662 {
8663 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8664 "%s: sme_SetGTKOffload failed, returned %d",
8665 __func__, status);
8666 return status;
8667 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308668 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8669 "%s: sme_SetGTKOffload successfull", __func__);
8670 }
8671 else
8672 {
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308673 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8674 "%s: wlan not suspended GTKOffload request is stored",
8675 __func__);
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308676 }
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05308677
8678 return eHAL_STATUS_SUCCESS;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05308679}
8680#endif /*WLAN_FEATURE_GTK_OFFLOAD*/
8681
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05308682/*
8683 * FUNCTION: wlan_hdd_cfg80211_set_mac_acl
8684 * This function is used to set access control policy
8685 */
8686static int wlan_hdd_cfg80211_set_mac_acl(struct wiphy *wiphy,
8687 struct net_device *dev, const struct cfg80211_acl_data *params)
8688{
8689 int i;
8690 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8691 hdd_hostapd_state_t *pHostapdState;
8692 tsap_Config_t *pConfig;
8693 v_CONTEXT_t pVosContext = NULL;
8694 hdd_context_t *pHddCtx;
8695 int status;
8696
8697 ENTER();
8698
8699 if (NULL == pAdapter)
8700 {
8701 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8702 "%s: HDD adapter is Null", __func__);
8703 return -ENODEV;
8704 }
8705
8706 if (NULL == params)
8707 {
8708 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8709 "%s: params is Null", __func__);
8710 return -EINVAL;
8711 }
8712
8713 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8714 status = wlan_hdd_validate_context(pHddCtx);
8715
8716 if (0 != status)
8717 {
8718 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8719 "%s: HDD context is not valid", __func__);
8720 return status;
8721 }
8722
8723 pVosContext = pHddCtx->pvosContext;
8724 pHostapdState = WLAN_HDD_GET_HOSTAP_STATE_PTR(pAdapter);
8725
8726 if (NULL == pHostapdState)
8727 {
8728 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8729 "%s: pHostapdState is Null", __func__);
8730 return -EINVAL;
8731 }
8732
8733 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"acl policy: = %d"
8734 "no acl entries = %d", params->acl_policy, params->n_acl_entries);
8735
8736 if (WLAN_HDD_SOFTAP == pAdapter->device_mode)
8737 {
8738 pConfig = &pAdapter->sessionCtx.ap.sapConfig;
8739
8740 /* default value */
8741 pConfig->num_accept_mac = 0;
8742 pConfig->num_deny_mac = 0;
8743
8744 /**
8745 * access control policy
8746 * @NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED: Deny stations which are
8747 * listed in hostapd.deny file.
8748 * @NL80211_ACL_POLICY_DENY_UNLESS_LISTED: Allow stations which are
8749 * listed in hostapd.accept file.
8750 */
8751 if (NL80211_ACL_POLICY_DENY_UNLESS_LISTED == params->acl_policy)
8752 {
8753 pConfig->SapMacaddr_acl = eSAP_DENY_UNLESS_ACCEPTED;
8754 }
8755 else if (NL80211_ACL_POLICY_ACCEPT_UNLESS_LISTED == params->acl_policy)
8756 {
8757 pConfig->SapMacaddr_acl = eSAP_ACCEPT_UNLESS_DENIED;
8758 }
8759 else
8760 {
8761 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8762 "%s:Acl Policy : %d is not supported",
8763 __func__, params->acl_policy);
8764 return -ENOTSUPP;
8765 }
8766
8767 if (eSAP_DENY_UNLESS_ACCEPTED == pConfig->SapMacaddr_acl)
8768 {
8769 pConfig->num_accept_mac = params->n_acl_entries;
8770 for (i = 0; i < params->n_acl_entries; i++)
8771 {
8772 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8773 "** Add ACL MAC entry %i in WhiletList :"
8774 MAC_ADDRESS_STR, i,
8775 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8776
8777 vos_mem_copy(&pConfig->accept_mac[i], params->mac_addrs[i].addr,
8778 sizeof(qcmacaddr));
8779 }
8780 }
8781 else if (eSAP_ACCEPT_UNLESS_DENIED == pConfig->SapMacaddr_acl)
8782 {
8783 pConfig->num_deny_mac = params->n_acl_entries;
8784 for (i = 0; i < params->n_acl_entries; i++)
8785 {
8786 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
8787 "** Add ACL MAC entry %i in BlackList :"
8788 MAC_ADDRESS_STR, i,
8789 MAC_ADDR_ARRAY(params->mac_addrs[i].addr));
8790
8791 vos_mem_copy(&pConfig->deny_mac[i], params->mac_addrs[i].addr,
8792 sizeof(qcmacaddr));
8793 }
8794 }
8795
8796 if (VOS_STATUS_SUCCESS != WLANSAP_SetMacACL(pVosContext, pConfig))
8797 {
8798 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8799 "%s: SAP Set Mac Acl fail", __func__);
8800 return -EINVAL;
8801 }
8802 }
8803 else
8804 {
8805 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8806 "%s: Invalid device_mode = %d",
8807 __func__, pAdapter->device_mode);
8808 return -EINVAL;
8809 }
8810
8811 return 0;
8812}
8813
Leo Chang9056f462013-08-01 19:21:11 -07008814#ifdef WLAN_NL80211_TESTMODE
8815#ifdef FEATURE_WLAN_LPHB
Leo Changd9df8aa2013-09-26 13:32:26 -07008816void wlan_hdd_cfg80211_lphb_ind_handler
Leo Chang9056f462013-08-01 19:21:11 -07008817(
8818 void *pAdapter,
8819 void *indCont
8820)
8821{
Leo Changd9df8aa2013-09-26 13:32:26 -07008822 tSirLPHBInd *lphbInd;
8823 struct sk_buff *skb;
Leo Chang9056f462013-08-01 19:21:11 -07008824
8825 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008826 "LPHB indication arrived");
Leo Chang9056f462013-08-01 19:21:11 -07008827
8828 if (NULL == indCont)
8829 {
8830 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Leo Changd9df8aa2013-09-26 13:32:26 -07008831 "LPHB IND, invalid argument");
Leo Chang9056f462013-08-01 19:21:11 -07008832 return;
8833 }
8834
Leo Changd9df8aa2013-09-26 13:32:26 -07008835 lphbInd = (tSirLPHBInd *)indCont;
Leo Chang9056f462013-08-01 19:21:11 -07008836 skb = cfg80211_testmode_alloc_event_skb(
8837 ((hdd_adapter_t *)pAdapter)->wdev.wiphy,
Leo Changd9df8aa2013-09-26 13:32:26 -07008838 sizeof(tSirLPHBInd),
Leo Chang9056f462013-08-01 19:21:11 -07008839 GFP_ATOMIC);
8840 if (!skb)
8841 {
8842 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8843 "LPHB timeout, NL buffer alloc fail");
8844 return;
8845 }
8846
Leo Changac3ba772013-10-07 09:47:04 -07008847 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_CMD, WLAN_HDD_TM_CMD_WLAN_HB))
Leo Changd9df8aa2013-09-26 13:32:26 -07008848 {
8849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8850 "WLAN_HDD_TM_ATTR_CMD put fail");
8851 goto nla_put_failure;
8852 }
Leo Changac3ba772013-10-07 09:47:04 -07008853 if(nla_put_u32(skb, WLAN_HDD_TM_ATTR_TYPE, lphbInd->protocolType))
Leo Changd9df8aa2013-09-26 13:32:26 -07008854 {
8855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8856 "WLAN_HDD_TM_ATTR_TYPE put fail");
8857 goto nla_put_failure;
8858 }
Leo Changac3ba772013-10-07 09:47:04 -07008859 if(nla_put(skb, WLAN_HDD_TM_ATTR_DATA,
Leo Changd9df8aa2013-09-26 13:32:26 -07008860 sizeof(tSirLPHBInd), lphbInd))
8861 {
8862 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8863 "WLAN_HDD_TM_ATTR_DATA put fail");
8864 goto nla_put_failure;
8865 }
Leo Chang9056f462013-08-01 19:21:11 -07008866 cfg80211_testmode_event(skb, GFP_ATOMIC);
8867 return;
8868
8869nla_put_failure:
8870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8871 "NLA Put fail");
8872 kfree_skb(skb);
8873
8874 return;
8875}
8876#endif /* FEATURE_WLAN_LPHB */
8877
8878static int wlan_hdd_cfg80211_testmode(struct wiphy *wiphy, void *data, int len)
8879{
8880 struct nlattr *tb[WLAN_HDD_TM_ATTR_MAX + 1];
8881 int err = 0;
8882#ifdef FEATURE_WLAN_LPHB
8883 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
Leo Changd9df8aa2013-09-26 13:32:26 -07008884 eHalStatus smeStatus;
Leo Chang9056f462013-08-01 19:21:11 -07008885#endif /* FEATURE_WLAN_LPHB */
8886
8887 err = nla_parse(tb, WLAN_HDD_TM_ATTR_MAX, data, len, wlan_hdd_tm_policy);
8888 if (err)
8889 {
8890 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8891 "%s Testmode INV ATTR", __func__);
8892 return err;
8893 }
8894
8895 if (!tb[WLAN_HDD_TM_ATTR_CMD])
8896 {
8897 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8898 "%s Testmode INV CMD", __func__);
8899 return -EINVAL;
8900 }
8901
8902 switch (nla_get_u32(tb[WLAN_HDD_TM_ATTR_CMD]))
8903 {
8904#ifdef FEATURE_WLAN_LPHB
8905 /* Low Power Heartbeat configuration request */
8906 case WLAN_HDD_TM_CMD_WLAN_HB:
8907 {
8908 int buf_len;
8909 void *buf;
8910 tSirLPHBReq *hb_params = NULL;
8911
8912 if (!tb[WLAN_HDD_TM_ATTR_DATA])
8913 {
8914 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8915 "%s Testmode INV DATA", __func__);
8916 return -EINVAL;
8917 }
8918
8919 buf = nla_data(tb[WLAN_HDD_TM_ATTR_DATA]);
8920 buf_len = nla_len(tb[WLAN_HDD_TM_ATTR_DATA]);
8921 hb_params = (tSirLPHBReq *)vos_mem_malloc(sizeof(tSirLPHBReq));
8922 if (NULL == hb_params)
8923 {
8924 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8925 "%s Request Buffer Alloc Fail", __func__);
8926 return -EINVAL;
8927 }
8928
8929 vos_mem_copy(hb_params, buf, buf_len);
Leo Changd9df8aa2013-09-26 13:32:26 -07008930 smeStatus = sme_LPHBConfigReq((tHalHandle)(pHddCtx->hHal),
8931 hb_params,
8932 wlan_hdd_cfg80211_lphb_ind_handler);
8933 if (eHAL_STATUS_SUCCESS != smeStatus)
Leo Chang9056f462013-08-01 19:21:11 -07008934 {
Leo Changd9df8aa2013-09-26 13:32:26 -07008935 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8936 "LPHB Config Fail, disable");
Leo Chang9056f462013-08-01 19:21:11 -07008937 vos_mem_free(hb_params);
8938 }
Leo Chang9056f462013-08-01 19:21:11 -07008939 return 0;
8940 }
8941#endif /* FEATURE_WLAN_LPHB */
8942 default:
8943 return -EOPNOTSUPP;
8944 }
8945
8946 return err;
8947}
8948#endif /* CONFIG_NL80211_TESTMODE */
8949
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308950static int wlan_hdd_cfg80211_dump_survey(struct wiphy *wiphy,
8951 struct net_device *dev,
8952 int idx, struct survey_info *survey)
8953{
8954 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
8955 hdd_context_t *pHddCtx;
Mihir Sheted9072e02013-08-21 17:02:29 +05308956 hdd_station_ctx_t *pHddStaCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308957 tHalHandle halHandle;
Mihir Sheted9072e02013-08-21 17:02:29 +05308958 v_U32_t channel = 0, freq = 0; /* Initialization Required */
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308959 v_S7_t snr,rssi;
8960 int status, i, j, filled = 0;
8961
8962 ENTER();
8963
8964
8965 if (NULL == pAdapter)
8966 {
8967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8968 "%s: HDD adapter is Null", __func__);
8969 return -ENODEV;
8970 }
8971
8972 if (NULL == wiphy)
8973 {
8974 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
8975 "%s: wiphy is Null", __func__);
8976 return -ENODEV;
8977 }
8978
8979 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
8980 status = wlan_hdd_validate_context(pHddCtx);
8981
8982 if (0 != status)
8983 {
8984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
8985 "%s: HDD context is not valid", __func__);
8986 return status;
8987 }
8988
Mihir Sheted9072e02013-08-21 17:02:29 +05308989 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
8990
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308991 if (0 == pHddCtx->cfg_ini->fEnableSNRMonitoring ||
Mihir Sheted9072e02013-08-21 17:02:29 +05308992 0 != pAdapter->survey_idx ||
8993 eConnectionState_Associated != pHddStaCtx->conn_info.connState)
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308994 {
8995 /* The survey dump ops when implemented completely is expected to
8996 * return a survey of all channels and the ops is called by the
8997 * kernel with incremental values of the argument 'idx' till it
8998 * returns -ENONET. But we can only support the survey for the
8999 * operating channel for now. survey_idx is used to track
9000 * that the ops is called only once and then return -ENONET for
9001 * the next iteration
9002 */
9003 pAdapter->survey_idx = 0;
9004 return -ENONET;
9005 }
9006
9007 halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
9008
9009 wlan_hdd_get_snr(pAdapter, &snr);
9010 wlan_hdd_get_rssi(pAdapter, &rssi);
9011
9012 sme_GetOperationChannel(halHandle, &channel, pAdapter->sessionId);
9013 hdd_wlan_get_freq(channel, &freq);
9014
9015
9016 for (i = 0; i < IEEE80211_NUM_BANDS; i++)
9017 {
9018 if (NULL == wiphy->bands[i])
9019 {
9020 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_INFO,
9021 "%s: wiphy->bands[i] is NULL, i = %d", __func__, i);
9022 continue;
9023 }
9024
9025 for (j = 0; j < wiphy->bands[i]->n_channels; j++)
9026 {
9027 struct ieee80211_supported_band *band = wiphy->bands[i];
9028
9029 if (band->channels[j].center_freq == (v_U16_t)freq)
9030 {
9031 survey->channel = &band->channels[j];
9032 /* The Rx BDs contain SNR values in dB for the received frames
9033 * while the supplicant expects noise. So we calculate and
9034 * return the value of noise (dBm)
9035 * SNR (dB) = RSSI (dBm) - NOISE (dBm)
9036 */
9037 survey->noise = rssi - snr;
9038 survey->filled = SURVEY_INFO_NOISE_DBM;
9039 filled = 1;
9040 }
9041 }
9042 }
9043
9044 if (filled)
9045 pAdapter->survey_idx = 1;
9046 else
9047 {
9048 pAdapter->survey_idx = 0;
9049 return -ENONET;
9050 }
9051
9052 return 0;
9053}
9054
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309055/*
9056 * FUNCTION: wlan_hdd_cfg80211_resume_wlan
9057 * this is called when cfg80211 driver resume
9058 * driver updates latest sched_scan scan result(if any) to cfg80211 database
9059 */
9060int wlan_hdd_cfg80211_resume_wlan(struct wiphy *wiphy)
9061{
9062 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9063 hdd_adapter_t *pAdapter;
9064 hdd_adapter_list_node_t *pAdapterNode, *pNext;
9065 VOS_STATUS status = VOS_STATUS_SUCCESS;
9066
9067 ENTER();
9068
9069 if ( NULL == pHddCtx )
9070 {
9071 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9072 "%s: HddCtx validation failed", __func__);
9073 return 0;
9074 }
9075
9076 if (pHddCtx->isLogpInProgress)
9077 {
9078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9079 "%s: LOGP in Progress. Ignore!!!", __func__);
9080 return 0;
9081 }
9082
9083 if (pHddCtx->isLoadUnloadInProgress)
9084 {
9085 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
9086 "%s: Unloading/Loading in Progress. Ignore!!!", __func__);
9087 return 0;
9088 }
9089
9090 spin_lock(&pHddCtx->schedScan_lock);
9091 pHddCtx->isWiphySuspended = FALSE;
9092 if (TRUE != pHddCtx->isSchedScanUpdatePending)
9093 {
9094 spin_unlock(&pHddCtx->schedScan_lock);
9095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9096 "%s: Return resume is not due to PNO indication", __func__);
9097 return 0;
9098 }
9099 // Reset flag to avoid updatating cfg80211 data old results again
9100 pHddCtx->isSchedScanUpdatePending = FALSE;
9101 spin_unlock(&pHddCtx->schedScan_lock);
9102
9103 status = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
9104
9105 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == status )
9106 {
9107 pAdapter = pAdapterNode->pAdapter;
9108 if ( (NULL != pAdapter) &&
9109 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) )
9110 {
9111 if (0 != wlan_hdd_cfg80211_update_bss(pHddCtx->wiphy, pAdapter))
9112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
9113 "%s: NO SCAN result", __func__);
9114 else
9115 cfg80211_sched_scan_results(pHddCtx->wiphy);
9116
9117 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9118 "%s : cfg80211 scan result database updated", __func__);
9119
9120 return 0;
9121
9122 }
9123 status = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
9124 pAdapterNode = pNext;
9125 }
9126
9127 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
9128 "%s: Failed to find Adapter", __func__);
9129 return 0;
9130}
9131
9132/*
9133 * FUNCTION: wlan_hdd_cfg80211_suspend_wlan
9134 * this is called when cfg80211 driver suspends
9135 */
9136int wlan_hdd_cfg80211_suspend_wlan(struct wiphy *wiphy,
9137 struct cfg80211_wowlan *wow)
9138{
9139 hdd_context_t *pHddCtx = wiphy_priv(wiphy);
9140
9141 ENTER();
9142 if (NULL == pHddCtx)
9143 {
9144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
9145 "%s: HddCtx validation failed", __func__);
9146 return 0;
9147 }
9148
9149 pHddCtx->isWiphySuspended = TRUE;
9150
9151 EXIT();
9152
9153 return 0;
9154}
9155
Jeff Johnson295189b2012-06-20 16:38:30 -07009156/* cfg80211_ops */
Gopichand Nakkala747461f2013-04-24 19:24:45 +05309157static struct cfg80211_ops wlan_hdd_cfg80211_ops =
Jeff Johnson295189b2012-06-20 16:38:30 -07009158{
9159 .add_virtual_intf = wlan_hdd_add_virtual_intf,
9160 .del_virtual_intf = wlan_hdd_del_virtual_intf,
9161 .change_virtual_intf = wlan_hdd_cfg80211_change_iface,
9162 .change_station = wlan_hdd_change_station,
9163#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
9164 .add_beacon = wlan_hdd_cfg80211_add_beacon,
9165 .del_beacon = wlan_hdd_cfg80211_del_beacon,
9166 .set_beacon = wlan_hdd_cfg80211_set_beacon,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009167#else
9168 .start_ap = wlan_hdd_cfg80211_start_ap,
9169 .change_beacon = wlan_hdd_cfg80211_change_beacon,
9170 .stop_ap = wlan_hdd_cfg80211_stop_ap,
Jeff Johnson295189b2012-06-20 16:38:30 -07009171#endif
9172 .change_bss = wlan_hdd_cfg80211_change_bss,
9173 .add_key = wlan_hdd_cfg80211_add_key,
9174 .get_key = wlan_hdd_cfg80211_get_key,
9175 .del_key = wlan_hdd_cfg80211_del_key,
9176 .set_default_key = wlan_hdd_cfg80211_set_default_key,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009177#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0))
Jeff Johnson295189b2012-06-20 16:38:30 -07009178 .set_channel = wlan_hdd_cfg80211_set_channel,
Jeff Johnson3bbe4bf2013-01-18 17:05:29 -08009179#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009180 .scan = wlan_hdd_cfg80211_scan,
9181 .connect = wlan_hdd_cfg80211_connect,
9182 .disconnect = wlan_hdd_cfg80211_disconnect,
9183 .join_ibss = wlan_hdd_cfg80211_join_ibss,
9184 .leave_ibss = wlan_hdd_cfg80211_leave_ibss,
9185 .set_wiphy_params = wlan_hdd_cfg80211_set_wiphy_params,
9186 .set_tx_power = wlan_hdd_cfg80211_set_txpower,
9187 .get_tx_power = wlan_hdd_cfg80211_get_txpower,
Jeff Johnson295189b2012-06-20 16:38:30 -07009188 .remain_on_channel = wlan_hdd_cfg80211_remain_on_channel,
9189 .cancel_remain_on_channel = wlan_hdd_cfg80211_cancel_remain_on_channel,
9190 .mgmt_tx = wlan_hdd_action,
9191#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38))
9192 .mgmt_tx_cancel_wait = wlan_hdd_cfg80211_mgmt_tx_cancel_wait,
9193 .set_default_mgmt_key = wlan_hdd_set_default_mgmt_key,
9194 .set_txq_params = wlan_hdd_set_txq_params,
9195#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009196 .get_station = wlan_hdd_cfg80211_get_station,
9197 .set_power_mgmt = wlan_hdd_cfg80211_set_power_mgmt,
9198 .del_station = wlan_hdd_cfg80211_del_station,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009199 .add_station = wlan_hdd_cfg80211_add_station,
9200#ifdef FEATURE_WLAN_LFR
9201 .set_pmksa = wlan_hdd_cfg80211_set_pmksa,
9202 .del_pmksa = wlan_hdd_cfg80211_del_pmksa,
9203 .flush_pmksa = wlan_hdd_cfg80211_flush_pmksa,
9204#endif
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07009205#if defined(WLAN_FEATURE_VOWIFI_11R) && defined(KERNEL_SUPPORT_11R_CFG80211)
9206 .update_ft_ies = wlan_hdd_cfg80211_update_ft_ies,
9207#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08009208#ifdef FEATURE_WLAN_TDLS
9209 .tdls_mgmt = wlan_hdd_cfg80211_tdls_mgmt,
9210 .tdls_oper = wlan_hdd_cfg80211_tdls_oper,
9211#endif
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05309212#ifdef WLAN_FEATURE_GTK_OFFLOAD
9213 .set_rekey_data = wlan_hdd_cfg80211_set_rekey_data,
9214#endif /* WLAN_FEATURE_GTK_OFFLOAD */
Gopichand Nakkala8e93fde2013-05-10 17:40:12 +05309215#ifdef FEATURE_WLAN_SCAN_PNO
9216 .sched_scan_start = wlan_hdd_cfg80211_sched_scan_start,
9217 .sched_scan_stop = wlan_hdd_cfg80211_sched_scan_stop,
9218#endif /*FEATURE_WLAN_SCAN_PNO */
Kamath Vinayak4000c9a2013-08-23 14:24:27 +05309219 .resume = wlan_hdd_cfg80211_resume_wlan,
9220 .suspend = wlan_hdd_cfg80211_suspend_wlan,
Gopichand Nakkalac005b7c2013-05-14 16:04:14 +05309221 .set_mac_acl = wlan_hdd_cfg80211_set_mac_acl,
Leo Chang9056f462013-08-01 19:21:11 -07009222#ifdef WLAN_NL80211_TESTMODE
9223 .testmode_cmd = wlan_hdd_cfg80211_testmode,
9224#endif
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309225 .dump_survey = wlan_hdd_cfg80211_dump_survey,
Jeff Johnson295189b2012-06-20 16:38:30 -07009226};
9227